using WhatsAppService.Domain.SeedWork;

namespace WhatsAppService.Domain.AggregatesModel.ConversationAggregate;

/// <summary>
/// EN: Repository interface for Conversation aggregate root.
/// VI: Interface repository cho Conversation aggregate root.
/// </summary>
public interface IConversationRepository : IRepository<Conversation>
{
    /// <summary>
    /// EN: Add a new conversation.
    /// VI: Thêm một conversation mới.
    /// </summary>
    Task<Conversation> AddAsync(Conversation conversation, CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Update an existing conversation.
    /// VI: Cập nhật một conversation đã tồn tại.
    /// </summary>
    void Update(Conversation conversation);

    /// <summary>
    /// EN: Get a conversation by ID with messages.
    /// VI: Lấy một conversation theo ID kèm messages.
    /// </summary>
    Task<Conversation?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Get active conversation for a customer in a shop.
    /// VI: Lấy conversation đang hoạt động cho một khách hàng trong shop.
    /// </summary>
    Task<Conversation?> GetActiveByCustomerAsync(Guid shopId, string customerWaId, CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Get conversations by shop ID with pagination.
    /// VI: Lấy conversations theo shop ID với phân trang.
    /// </summary>
    Task<IReadOnlyList<Conversation>> GetByShopIdAsync(Guid shopId, int skip, int take, ConversationStatus? status = null, CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Get expired conversations that need to be closed.
    /// VI: Lấy các conversations đã hết hạn cần được đóng.
    /// </summary>
    Task<IReadOnlyList<Conversation>> GetExpiredConversationsAsync(CancellationToken cancellationToken = default);
}
