namespace GerbilManagerWebAPI.Inbox
{
    /// <summary>Connection params for an IMAP fetch (decrypted password — never persisted/logged).</summary>
    public sealed record MailConnection(string GmailAddress, string AppPassword, string Folder);

    /// <summary>A fetched email reduced to what the Request entity needs.</summary>
    public sealed record MailSummary(
        string MessageId,
        string? ThreadId,
        string? InReplyTo,
        string? References,
        string FromAddress,
        string? FromName,
        string? Subject,
        string? BodyText,
        DateTimeOffset ReceivedAt,
        uint Uid);

    /// <summary>Reads mail from a folder. Abstracted so tests feed canned summaries
    /// (the live MailKit/Gmail path is gated on Julian's App Password).</summary>
    public interface IGmailMailReader
    {
        /// <summary>Fetch messages with UID &gt; <paramref name="sinceUid"/> from the configured folder.</summary>
        Task<IReadOnlyList<MailSummary>> FetchAsync(MailConnection connection, uint sinceUid, CancellationToken ct = default);
    }

    /// <summary>Outcome of a sync run.</summary>
    public sealed record SyncResult(int Imported, string? Error);
}
