package api

import (
	"time"

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

// RepositoryResponse is the REST representation of persisted repository metadata.
type RepositoryResponse struct {
	RepoID        string    `json:"repo_id"`
	CloneURL      string    `json:"clone_url"`
	DefaultRef    string    `json:"default_ref"`
	LastCommitSHA string    `json:"last_commit_sha"`
	LastSyncAt    time.Time `json:"last_sync_at"`
	Status        string    `json:"status"`
	UpdatedAt     time.Time `json:"updated_at"`
}

// RepositoryFromDomain maps domain repository metadata to an API response.
func RepositoryFromDomain(repo domain.Repository) RepositoryResponse {
	return RepositoryResponse{
		RepoID:        repo.RepoID,
		CloneURL:      repo.CloneURL,
		DefaultRef:    repo.DefaultRef,
		LastCommitSHA: repo.LastCommitSHA,
		LastSyncAt:    repo.LastSyncAt,
		Status:        repo.Status,
		UpdatedAt:     repo.UpdatedAt,
	}
}
