namespace GerbilManagerWebAPI.SaleAd
{
    /// <summary>
    /// FEAT-12a: request/response contract of POST /gerbils/sale-ad — FROZEN,
    /// mirror of the frontend (gerbil-manager-web/src/api/saleAd.ts).
    /// </summary>
    public sealed record SaleAdAnimal(
        string Name,
        string? Farbschlag,
        /// <summary>ISO "YYYY-MM-DD" (frontend sends the DTO string verbatim).</summary>
        string? DateOfBirth,
        string? Notes,
        /// <summary>FEAT-14: Charakterbogen trait LABELS (German, human-readable) for the prompt.</summary>
        List<string>? Traits = null,
        /// <summary>FEAT-14: free-text character note for the prompt.</summary>
        string? CharacterNote = null);

    public sealed record SaleAdRequest(
        List<SaleAdAnimal> Animals,
        /// <summary>e.g. "FREI" / "LOCKER RESERVIERT Anna" / "RESERVIERT".</summary>
        string StatusLine,
        /// <summary>Free-text style hints/wishes from the user.</summary>
        string Hints);

    public sealed record SaleAdResponse(string Text);

    /// <summary>
    /// Error body for the non-200 paths. The code string "AiKeyMissing" is FROZEN —
    /// Kevin's UI maps it to the German "API-Schlüssel noch nicht konfiguriert" hint.
    /// </summary>
    public sealed record SaleAdError(string Code, string Message);

    public enum SaleAdStatus
    {
        Ok,
        /// <summary>AI section not (fully) configured -> HTTP 503, code "AiKeyMissing".</summary>
        NotConfigured,
        /// <summary>Provider call failed -> HTTP 502, code "AiUpstreamError".</summary>
        UpstreamError,
    }

    public sealed record SaleAdResult(SaleAdStatus Status, string? Text, string? Error = null);
}
