package api

import (
	"time"

	"bit.admedia.com/scm/ad/adpilot-indexing-repo-sync.com/internal/domain"
)

// SnapshotResponse is the REST representation of persisted snapshot metadata.
type SnapshotResponse struct {
	SnapshotID string    `json:"snapshot_id"`
	RepoID     string    `json:"repo_id"`
	CommitSHA  string    `json:"commit_sha"`
	Ref        string    `json:"ref"`
	FileCount  int       `json:"file_count"`
	Status     string    `json:"status"`
	CreatedAt  time.Time `json:"created_at"`
}

// SnapshotFromDomain maps domain snapshot metadata to an API response.
func SnapshotFromDomain(snap domain.Snapshot) SnapshotResponse {
	return SnapshotResponse{
		SnapshotID: snap.SnapshotID,
		RepoID:     snap.RepoID,
		CommitSHA:  snap.CommitSHA,
		Ref:        snap.Ref,
		FileCount:  snap.FileCount,
		Status:     snap.Status,
		CreatedAt:  snap.CreatedAt,
	}
}
