namespace ZB.MOM.WW.ScadaBridge.DelmiaNotifier;

/// <summary>Whether a single POST attempt reached the server (<see cref="Connected"/>) or never did (<see cref="ConnectFailed"/>).</summary>
internal enum AttemptKind
{
    Connected,
    ConnectFailed,
}

/// <summary>Result of one POST attempt against a single base URL.</summary>
/// <param name="Kind">Did the attempt reach the server?</param>
/// <param name="StatusCode">HTTP status when <see cref="AttemptKind.Connected"/>; 0 otherwise.</param>
/// <param name="Body">Parsed response body on a 2xx; null otherwise.</param>
/// <param name="Error">Connection/exception detail when <see cref="AttemptKind.ConnectFailed"/>; null otherwise.</param>
internal sealed record AttemptOutcome(AttemptKind Kind, int StatusCode, RecipeDownloadResult? Body, string? Error);

/// <summary>Seam over a single recipe-download POST attempt, so the failover loop is testable without real HTTP.</summary>
internal interface IRecipeSender
{
    /// <summary>Sends the recipe download payload to a single base URL as one POST attempt.</summary>
    /// <param name="baseUrl">The base URL to POST the recipe download to.</param>
    /// <param name="payload">The recipe download payload to send.</param>
    /// <param name="ct">Cancellation token.</param>
    /// <returns>The outcome of the attempt: connected (with status/body) or connect-failed (with error detail).</returns>
    Task<AttemptOutcome> SendAsync(string baseUrl, RecipeDownload payload, CancellationToken ct);
}
