using Newtonsoft.Json.Linq;
using OF_DL.Enumerations;
using ArchivedEntities = OF_DL.Models.Entities.Archived;
using MessageEntities = OF_DL.Models.Entities.Messages;
using PostEntities = OF_DL.Models.Entities.Posts;
using PurchasedEntities = OF_DL.Models.Entities.Purchased;
using StreamEntities = OF_DL.Models.Entities.Streams;
using UserEntities = OF_DL.Models.Entities.Users;

namespace OF_DL.Services;

public interface IApiService
{
    /// <summary>
    /// Retrieves a decryption key using the local CDM integration.
    /// </summary>
    Task<string> GetDecryptionKeyCdm(Dictionary<string, string> drmHeaders, string licenceUrl, string pssh);

    /// <summary>
    /// Retrieves the last modified timestamp for a DRM MPD manifest.
    /// </summary>
    Task<DateTime> GetDrmMpdLastModified(string mpdUrl, string policy, string signature, string kvp);

    /// <summary>
    /// Retrieves the Widevine PSSH from an MPD manifest.
    /// </summary>
    Task<string> GetDrmMpdPssh(string mpdUrl, string policy, string signature, string kvp);

    /// <summary>
    /// Retrieves the user's lists.
    /// </summary>
    Task<Dictionary<string, long>?> GetLists(string endpoint);

    /// <summary>
    /// Retrieves usernames for a specific list.
    /// </summary>
    Task<List<string>?> GetListUsers(string endpoint);

    /// <summary>
    /// Retrieves media URLs for stories or highlights.
    /// </summary>
    Task<Dictionary<long, string>?> GetMedia(MediaType mediaType, string endpoint, string? username, string folder);

    /// <summary>
    /// Retrieves paid posts and their media.
    /// </summary>
    Task<PurchasedEntities.PaidPostCollection> GetPaidPosts(string endpoint, string folder, string username,
        List<long> paidPostIds,
        IStatusReporter statusReporter);

    /// <summary>
    /// Retrieves posts and their media.
    /// </summary>
    Task<PostEntities.PostCollection> GetPosts(string endpoint, string folder, List<long> paidPostIds,
        IStatusReporter statusReporter);

    /// <summary>
    /// Retrieves a single post and its media.
    /// </summary>
    Task<PostEntities.SinglePostCollection> GetPost(string endpoint, string folder);

    /// <summary>
    /// Retrieves streams and their media.
    /// </summary>
    Task<StreamEntities.StreamsCollection> GetStreams(string endpoint, string folder, List<long> paidPostIds,
        IStatusReporter statusReporter);

    /// <summary>
    /// Retrieves archived posts and their media.
    /// </summary>
    Task<ArchivedEntities.ArchivedCollection> GetArchived(string endpoint, string folder,
        IStatusReporter statusReporter);

    /// <summary>
    /// Retrieves messages and their media.
    /// </summary>
    Task<MessageEntities.MessageCollection> GetMessages(string endpoint, string folder, IStatusReporter statusReporter);

    /// <summary>
    /// Retrieves paid messages and their media.
    /// </summary>
    Task<PurchasedEntities.PaidMessageCollection> GetPaidMessages(string endpoint, string folder, string username,
        IStatusReporter statusReporter);

    /// <summary>
    /// Retrieves a single paid message and its media.
    /// </summary>
    Task<PurchasedEntities.SinglePaidMessageCollection> GetPaidMessage(string endpoint, string folder);

    /// <summary>
    /// Retrieves users that appear in the Purchased tab.
    /// </summary>
    Task<Dictionary<string, long>> GetPurchasedTabUsers(string endpoint, Dictionary<string, long> users);

    /// <summary>
    /// Retrieves Purchased tab content grouped by user.
    /// </summary>
    Task<List<PurchasedEntities.PurchasedTabCollection>> GetPurchasedTab(string endpoint, string folder,
        Dictionary<string, long> users);

    /// <summary>
    /// Retrieves user information.
    /// </summary>
    Task<UserEntities.User?> GetUserInfo(string endpoint);

    /// <summary>
    /// Retrieves user information by ID.
    /// </summary>
    Task<JObject?> GetUserInfoById(string endpoint);

    /// <summary>
    /// Builds signed headers for API requests.
    /// </summary>
    Dictionary<string, string> GetDynamicHeaders(string path, string queryParam);

    /// <summary>
    /// Retrieves active subscriptions.
    /// </summary>
    Task<Dictionary<string, long>?> GetActiveSubscriptions(string endpoint, bool includeRestrictedSubscriptions);

    /// <summary>
    /// Retrieves expired subscriptions.
    /// </summary>
    Task<Dictionary<string, long>?> GetExpiredSubscriptions(string endpoint, bool includeRestrictedSubscriptions);

    /// <summary>
    /// Retrieves a decryption key via the OF DL fallback service.
    /// </summary>
    Task<string> GetDecryptionKeyOfdl(Dictionary<string, string> drmHeaders, string licenceUrl, string pssh);
}
