import type { DecideDonnaBindingPayload, DonnaBindingOverview, DonnaBindingProposal, DonnaBindingProposalStatus, DonnaCreditRequest, DonnaCreditRequestStatus, DonnaCreditRequestsPage, DonnaCandidate, DonnaClientDetail, DonnaCorrectionDetail, DonnaCorrectionStatus, DonnaCorrectionsOverview, DonnaJudgementsOverview, DonnaMessagesPage, DonnaMessagesParams, DonnaSettings, DonnaUsageMonth, UpdateDonnaClientPayload, UpdateDonnaCorrectionPayload } from "@/domain/entities/donna";

export interface DonnaRepository {
  getUsage(params: { month?: string; search?: string }): Promise<DonnaUsageMonth>;
  findClient(companyId: number, month?: string): Promise<DonnaClientDetail>;
  /** Temporary: the price per vehicle typed by hand until the pricing module gives it. */
  updateClient(companyId: number, payload: UpdateDonnaClientPayload): Promise<DonnaClientDetail>;
  /** Grants this month's gift now (for a client priced after the 1st). */
  grantGift(companyId: number): Promise<DonnaClientDetail>;
  /** A gift of a typed amount for this month: a one-off, or the computed gift corrected. */
  customGift(companyId: number, payload: { amount_eur: number; note?: string | null }): Promise<DonnaClientDetail>;
  /** This month's gift for every priced client that does not have it yet. */
  grantAll(): Promise<{ granted: number; amount_eur: number }>;
  /** The companies not on the list yet. */
  getCandidates(search?: string): Promise<DonnaCandidate[]>;
  /** Puts a company on the list, with a gift of the amount typed (or the computed one without it). */
  addClient(payload: { company_id: number; donna_price_per_vehicle?: number | null; amount_eur?: number | null; note?: string | null }): Promise<DonnaClientDetail>;
  /** Takes a company off the list and takes back this month's gift. */
  removeClient(companyId: number): Promise<void>;
  getSettings(): Promise<DonnaSettings>;
  updateSettings(payload: Partial<DonnaSettings>): Promise<DonnaSettings>;
  revokeGift(grantId: number): Promise<DonnaClientDetail>;
  restoreGift(grantId: number): Promise<DonnaClientDetail>;
  /** What the clients asked Donna, her answers and their rating. */
  getMessages(params: DonnaMessagesParams): Promise<DonnaMessagesPage>;
  /** The corrections clients made to the agents' answers, of one agent or of all. */
  getCorrections(params: { status?: DonnaCorrectionStatus | "all"; agent?: string }): Promise<DonnaCorrectionsOverview>;
  /** What Donna's judge said of a sample of her answers: the latest verdicts and their summary. */
  getJudgements(params: { limit?: number; only?: "failed" }): Promise<DonnaJudgementsOverview>;
  /** The auditor's binding against the platform's catalog, and the proposals for what it lacks. */
  getBindings(status?: DonnaBindingProposalStatus): Promise<DonnaBindingOverview>;
  refreshBindings(): Promise<{ proposals: DonnaBindingProposal[] }>;
  decideBindingProposal(id: number, payload: DecideDonnaBindingPayload): Promise<{ proposal: DonnaBindingProposal }>;
  getCorrection(agent: string, id: number): Promise<DonnaCorrectionDetail>;
  updateCorrection(agent: string, id: number, payload: UpdateDonnaCorrectionPayload): Promise<DonnaCorrectionDetail>;
  deleteCorrection(agent: string, id: number): Promise<void>;
  /** Prospects and former clients asking Dadycar for credit to try Donna. */
  getCreditRequests(status?: DonnaCreditRequestStatus | "all"): Promise<DonnaCreditRequestsPage>;
  approveCreditRequest(id: number, payload: { amount_eur: number; note?: string | null }): Promise<DonnaCreditRequest>;
  refuseCreditRequest(id: number, payload?: { note?: string | null }): Promise<DonnaCreditRequest>;
}
