using ZB.MOM.WW.ScadaBridge.Commons.Entities.Notifications;

namespace ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories;

public interface INotificationRepository
{
    // NotificationList
    /// <summary>Gets a notification list by ID.</summary>
    /// <param name="id">The notification list ID.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>The notification list, or null if not found.</returns>
    Task<NotificationList?> GetNotificationListByIdAsync(int id, CancellationToken cancellationToken = default);

    /// <summary>Gets all notification lists.</summary>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A read-only list of notification lists.</returns>
    Task<IReadOnlyList<NotificationList>> GetAllNotificationListsAsync(CancellationToken cancellationToken = default);

    /// <summary>Gets a notification list by name.</summary>
    /// <param name="name">The notification list name.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>The notification list, or null if not found.</returns>
    Task<NotificationList?> GetListByNameAsync(string name, CancellationToken cancellationToken = default);

    /// <summary>Adds a new notification list.</summary>
    /// <param name="list">The notification list to add.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the asynchronous operation.</returns>
    Task AddNotificationListAsync(NotificationList list, CancellationToken cancellationToken = default);

    /// <summary>Updates an existing notification list.</summary>
    /// <param name="list">The notification list to update.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the asynchronous operation.</returns>
    Task UpdateNotificationListAsync(NotificationList list, CancellationToken cancellationToken = default);

    /// <summary>Deletes a notification list by ID.</summary>
    /// <param name="id">The notification list ID.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the asynchronous operation.</returns>
    Task DeleteNotificationListAsync(int id, CancellationToken cancellationToken = default);

    // NotificationRecipient
    /// <summary>Gets a notification recipient by ID.</summary>
    /// <param name="id">The recipient ID.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>The notification recipient, or null if not found.</returns>
    Task<NotificationRecipient?> GetRecipientByIdAsync(int id, CancellationToken cancellationToken = default);

    /// <summary>Gets all recipients in a notification list.</summary>
    /// <param name="notificationListId">The notification list ID.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A read-only list of recipients.</returns>
    Task<IReadOnlyList<NotificationRecipient>> GetRecipientsByListIdAsync(int notificationListId, CancellationToken cancellationToken = default);

    /// <summary>Adds a new notification recipient.</summary>
    /// <param name="recipient">The recipient to add.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the asynchronous operation.</returns>
    Task AddRecipientAsync(NotificationRecipient recipient, CancellationToken cancellationToken = default);

    /// <summary>Updates an existing notification recipient.</summary>
    /// <param name="recipient">The recipient to update.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the asynchronous operation.</returns>
    Task UpdateRecipientAsync(NotificationRecipient recipient, CancellationToken cancellationToken = default);

    /// <summary>Deletes a notification recipient by ID.</summary>
    /// <param name="id">The recipient ID.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the asynchronous operation.</returns>
    Task DeleteRecipientAsync(int id, CancellationToken cancellationToken = default);

    // SmtpConfiguration
    /// <summary>Gets an SMTP configuration by ID.</summary>
    /// <param name="id">The SMTP configuration ID.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>The SMTP configuration, or null if not found.</returns>
    Task<SmtpConfiguration?> GetSmtpConfigurationByIdAsync(int id, CancellationToken cancellationToken = default);

    /// <summary>Gets all SMTP configurations.</summary>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A read-only list of SMTP configurations.</returns>
    Task<IReadOnlyList<SmtpConfiguration>> GetAllSmtpConfigurationsAsync(CancellationToken cancellationToken = default);

    /// <summary>Adds a new SMTP configuration.</summary>
    /// <param name="configuration">The SMTP configuration to add.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the asynchronous operation.</returns>
    Task AddSmtpConfigurationAsync(SmtpConfiguration configuration, CancellationToken cancellationToken = default);

    /// <summary>Updates an existing SMTP configuration.</summary>
    /// <param name="configuration">The SMTP configuration to update.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the asynchronous operation.</returns>
    Task UpdateSmtpConfigurationAsync(SmtpConfiguration configuration, CancellationToken cancellationToken = default);

    /// <summary>Deletes an SMTP configuration by ID.</summary>
    /// <param name="id">The SMTP configuration ID.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the asynchronous operation.</returns>
    Task DeleteSmtpConfigurationAsync(int id, CancellationToken cancellationToken = default);

    // SmsConfiguration
    /// <summary>Gets the SMS configuration, or null if none is configured.</summary>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>The SMS configuration, or null if not found.</returns>
    Task<SmsConfiguration?> GetSmsConfigurationAsync(CancellationToken cancellationToken = default);

    /// <summary>Gets an SMS configuration by ID.</summary>
    /// <param name="id">The SMS configuration ID.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>The SMS configuration, or null if not found.</returns>
    Task<SmsConfiguration?> GetSmsConfigurationByIdAsync(int id, CancellationToken cancellationToken = default);

    /// <summary>Gets all SMS configurations.</summary>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A read-only list of SMS configurations.</returns>
    Task<IReadOnlyList<SmsConfiguration>> GetAllSmsConfigurationsAsync(CancellationToken cancellationToken = default);

    /// <summary>Adds a new SMS configuration.</summary>
    /// <param name="smsConfiguration">The SMS configuration to add.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the asynchronous operation.</returns>
    Task AddSmsConfigurationAsync(SmsConfiguration smsConfiguration, CancellationToken cancellationToken = default);

    /// <summary>Updates an existing SMS configuration.</summary>
    /// <param name="smsConfiguration">The SMS configuration to update.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the asynchronous operation.</returns>
    Task UpdateSmsConfigurationAsync(SmsConfiguration smsConfiguration, CancellationToken cancellationToken = default);

    /// <summary>Deletes an SMS configuration by ID.</summary>
    /// <param name="id">The SMS configuration ID.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>A task representing the asynchronous operation.</returns>
    Task DeleteSmsConfigurationAsync(int id, CancellationToken cancellationToken = default);

    /// <summary>Saves pending changes to the repository.</summary>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>The number of entities saved.</returns>
    Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
}
