/// <summary> /// Initializes a new instance of <see cref="OsuClient"/> with the given configuration and the one for the rate limiter. /// </summary> /// <param name="osuSharpConfiguration">Configuration to use for this instance.</param> /// <param name="rateLimiterConfiguration">Rate limiting configuration.</param> public OsuClient(OsuSharpConfiguration osuSharpConfiguration, RateLimiterConfiguration rateLimiterConfiguration) { OsuSharpConfiguration = osuSharpConfiguration; RateLimiter = new RateLimiter(rateLimiterConfiguration); ReplayRateLimiter = new RateLimiter(new RateLimiterConfiguration { MaxRequest = 10, ThrowOnRatelimitHit = rateLimiterConfiguration.ThrowOnRatelimitHit }); if (string.IsNullOrWhiteSpace(OsuSharpConfiguration.ApiKey)) { throw new OsuSharpException("The given api key is not valid.", HttpStatusCode.Unauthorized); } if (OsuSharpConfiguration.HttpClient is null) { OsuSharpConfiguration.HttpClient = new HttpClient(); } Logger = new OsuSharpLogger(); }
/// <summary> /// Initializes a new instance of <see cref="OsuClient"/> with the given configuration and the default configuration for the rate limiter. /// </summary> /// <param name="osuSharpConfiguration">Configuration to use for this instance.</param> public OsuClient(OsuSharpConfiguration osuSharpConfiguration) : this(osuSharpConfiguration, new RateLimiterConfiguration()) { }