using OF_DL.Models.Downloads;

namespace OF_DL.Services;

public interface IDownloadOrchestrationService
{
    /// <summary>
    ///     Fetch subscriptions, lists, filter ignored users.
    /// </summary>
    Task<UserListResult> GetAvailableUsersAsync();

    /// <summary>
    ///     Get users for a specific list by name.
    /// </summary>
    Task<Dictionary<string, long>> GetUsersForListAsync(
        string listName, Dictionary<string, long> allUsers, Dictionary<string, long> lists);

    /// <summary>
    ///     Resolve download path for a username based on config.
    /// </summary>
    string ResolveDownloadPath(string username);

    /// <summary>
    ///     Prepare user folder (create dir, check username, create DB).
    /// </summary>
    Task PrepareUserFolderAsync(string username, long userId, string path);

    /// <summary>
    ///     Download all configured content types for a single creator.
    /// </summary>
    Task<CreatorDownloadResult> DownloadCreatorContentAsync(
        string username, long userId, string path,
        Dictionary<string, long> users,
        bool clientIdBlobMissing, bool devicePrivateKeyMissing,
        IDownloadEventHandler eventHandler);

    /// <summary>
    ///     Download a single post by ID.
    /// </summary>
    Task DownloadSinglePostAsync(
        string username, long postId, string path,
        Dictionary<string, long> users,
        bool clientIdBlobMissing, bool devicePrivateKeyMissing,
        IDownloadEventHandler eventHandler);

    /// <summary>
    ///     Download purchased tab content for all users.
    /// </summary>
    Task DownloadPurchasedTabAsync(
        Dictionary<string, long> users,
        bool clientIdBlobMissing, bool devicePrivateKeyMissing,
        IDownloadEventHandler eventHandler);

    /// <summary>
    ///     Download a single paid message by message ID.
    /// </summary>
    Task DownloadSinglePaidMessageAsync(
        string username, long messageId, string path,
        Dictionary<string, long> users,
        bool clientIdBlobMissing, bool devicePrivateKeyMissing,
        IDownloadEventHandler eventHandler);

    /// <summary>
    ///     Resolve username from user ID via API.
    /// </summary>
    Task<string?> ResolveUsernameAsync(long userId);

    /// <summary>
    ///     Tracks paid post IDs across downloads.
    /// </summary>
    List<long> PaidPostIds { get; }
}
