using CryptoExchange.Net.Objects;

namespace CryptoExchange.Net.RateLimiting.Interfaces
{
    /// <summary>
    /// Rate limit guard
    /// </summary>
    public interface IRateLimitGuard
    {
        /// <summary>
        /// Name
        /// </summary>
        string Name { get; }

        /// <summary>
        /// Description
        /// </summary>
        string Description { get; }

        /// <summary>
        /// Check whether a request can pass this rate limit guard
        /// </summary>
        /// <param name="type">The rate limit item type</param>
        /// <param name="definition">The request definition</param>
        /// <param name="host">The host address</param>
        /// <param name="apiKey">The API key</param>
        /// <param name="requestWeight">The request weight</param>
        /// <param name="keySuffix">An additional optional suffix for the key selector. Can be used to make rate limiting work based on parameters.</param>
        /// <returns></returns>
        LimitCheck Check(RateLimitItemType type, RequestDefinition definition, string host, string? apiKey, int requestWeight, string? keySuffix);

        /// <summary>
        /// Apply the request to this guard with the specified weight
        /// </summary>
        /// <param name="type">The rate limit item type</param>
        /// <param name="definition">The request definition</param>
        /// <param name="host">The host address</param>
        /// <param name="apiKey">The API key</param>
        /// <param name="requestWeight">The request weight</param>
        /// <param name="keySuffix">An additional optional suffix for the key selector. Can be used to make rate limiting work based on parameters.</param>
        /// <returns></returns>
        RateLimitState ApplyWeight(RateLimitItemType type, RequestDefinition definition, string host, string? apiKey, int requestWeight, string? keySuffix);

        /// <summary>
        /// Reset the limit for the specified parameters
        /// </summary>
        /// <param name="type">The rate limit item type</param>
        /// <param name="definition">The request definition</param>
        /// <param name="host">The host address</param>
        /// <param name="apiKey">The API key</param>
        /// <param name="keySuffix">An additional optional suffix for the key selector. Can be used to make rate limiting work based on parameters.</param>
        void Reset(RateLimitItemType type, RequestDefinition definition, string host, string? apiKey, string? keySuffix);
    }
}
