namespace WhatsAppService.Infrastructure.ExternalServices;

/// <summary>
/// EN: Interface for WhatsApp Cloud API client.
/// VI: Interface cho WhatsApp Cloud API client.
/// </summary>
public interface IWhatsAppCloudApiClient
{
    /// <summary>
    /// EN: Send a text message.
    /// VI: Gửi tin nhắn văn bản.
    /// </summary>
    Task<SendMessageResult> SendTextMessageAsync(
        string phoneNumberId,
        string accessToken,
        string recipientWaId,
        string text,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Send a template message (for outside 24h window).
    /// VI: Gửi tin nhắn template (cho ngoài cửa sổ 24h).
    /// </summary>
    Task<SendMessageResult> SendTemplateMessageAsync(
        string phoneNumberId,
        string accessToken,
        string recipientWaId,
        string templateName,
        string languageCode,
        object[]? components = null,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Send a media message (image, video, document, audio).
    /// VI: Gửi tin nhắn media (ảnh, video, tài liệu, audio).
    /// </summary>
    Task<SendMessageResult> SendMediaMessageAsync(
        string phoneNumberId,
        string accessToken,
        string recipientWaId,
        string mediaType,
        string mediaUrl,
        string? caption = null,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Send an interactive message (buttons, list).
    /// VI: Gửi tin nhắn interactive (buttons, list).
    /// </summary>
    Task<SendMessageResult> SendInteractiveMessageAsync(
        string phoneNumberId,
        string accessToken,
        string recipientWaId,
        object interactiveContent,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Mark message as read.
    /// VI: Đánh dấu tin nhắn đã đọc.
    /// </summary>
    Task<bool> MarkMessageAsReadAsync(
        string phoneNumberId,
        string accessToken,
        string messageId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Get media URL by media ID.
    /// VI: Lấy URL media theo media ID.
    /// </summary>
    Task<string?> GetMediaUrlAsync(
        string accessToken,
        string mediaId,
        CancellationToken cancellationToken = default);
}

/// <summary>
/// EN: Result of sending a message.
/// VI: Kết quả gửi tin nhắn.
/// </summary>
public record SendMessageResult(
    bool Success,
    string? MessageId,
    string? ErrorCode,
    string? ErrorMessage);
