package api

// ImportRequest is the gateway → repo-sync import payload (contract v1.1).
type ImportRequest struct {
	ImportJobID  string          `json:"importJobId"`
	OrgID        string          `json:"orgId"`
	ConnectionID string          `json:"connectionId"`
	Provider     string          `json:"provider"`
	CloneAuth    CloneAuth       `json:"cloneAuth"`
	Repos        []ImportRepoRef `json:"repos"`
}

// CloneAuth holds short-lived git credentials — must not be persisted.
type CloneAuth struct {
	Username  string `json:"username"`
	Password  string `json:"password"`
	ExpiresAt string `json:"expiresAt"`
}

// ImportRepoRef identifies a repository to import.
type ImportRepoRef struct {
	ProviderRepoID string `json:"providerRepoId"`
	FullName       string `json:"fullName"`
	DefaultBranch  string `json:"defaultBranch"`
	CloneURL       string `json:"cloneUrl"`
}

// ImportAcceptedResponse is returned when an import is accepted (202).
type ImportAcceptedResponse struct {
	ImportJobID string            `json:"importJobId"`
	Status      string            `json:"status"`
	Jobs        []ImportRepoJob   `json:"jobs"`
}

// ImportRepoJob tracks per-repo import job status in the response.
type ImportRepoJob struct {
	JobID          string `json:"jobId"`
	ProviderRepoID string `json:"providerRepoId"`
	FullName       string `json:"fullName"`
	RepoID         string `json:"repoId"`
	Status         string `json:"status"`
}

// RepoStatusResponse is returned by GET /repos/{repo_id}/status.
type RepoStatusResponse struct {
	RepoID        string `json:"repo_id"`
	Status        string `json:"status"`
	LastCommitSHA string `json:"last_commit_sha,omitempty"`
	LastSyncAt    string `json:"last_sync_at,omitempty"`
	DefaultRef    string `json:"default_ref,omitempty"`
}
