Exemple #1
0
        /// <summary>
        /// Dependency injection constructor
        /// </summary>
        /// <param name="rateLimitedRequester">Rate limited requester for all endpoints except the static endpoint.</param>
        /// <param name="staticEndpointProvider">The static endpoint provider.</param>
        /// <param name="cache">The cache.</param>
        /// <exception cref="ArgumentNullException">
        /// rateLimitedRequester
        /// or
        /// staticEndpointProvider
        /// </exception>
        public RiotApi(IRateLimitedRequester rateLimitedRequester, IRequester requester, IStaticEndpointProvider staticEndpointProvider,
                       ICache cache = null)
        {
            if (rateLimitedRequester == null)
            {
                throw new ArgumentNullException(nameof(rateLimitedRequester));
            }
            if (staticEndpointProvider == null)
            {
                throw new ArgumentNullException(nameof(staticEndpointProvider));
            }

            _cache = cache ?? new PassThroughCache();

            Summoner        = new SummonerEndpoint(rateLimitedRequester, _cache);
            Champion        = new ChampionEndpoint(rateLimitedRequester);
            League          = new LeagueEndpoint(rateLimitedRequester);
            Match           = new MatchEndpoint(rateLimitedRequester, _cache);
            Spectator       = new SpectatorEndpoint(rateLimitedRequester);
            ChampionMastery = new ChampionMasteryEndpoint(rateLimitedRequester);
            ThirdParty      = new ThirdPartyEndpoint(rateLimitedRequester);

            DataDragon = new DataDragonEndpoints(staticEndpointProvider);
            Status     = new StatusEndpoint(requester);

            Clash = new ClashEndpoint(rateLimitedRequester, _cache);
        }
Exemple #2
0
        private RiotApi(string apiKey, IDictionary <TimeSpan, int> rateLimits, ICache cache)
        {
            _cache = cache ?? throw new ArgumentNullException(nameof(cache));
            Requesters.RiotApiRequester   = new RateLimitedRequester(apiKey, rateLimits);
            Requesters.StaticApiRequester = new Requester(apiKey);
            var requester = Requesters.RiotApiRequester;

            Summoner        = new SummonerEndpoint(requester, _cache);
            Champion        = new ChampionEndpoint(requester);
            League          = new LeagueEndpoint(requester);
            Match           = new MatchEndpoint(requester, _cache);
            Spectator       = new SpectatorEndpoint(requester);
            ChampionMastery = new ChampionMasteryEndpoint(requester);
            ThirdParty      = new ThirdPartyEndpoint(requester);

            DataDragon = new DataDragonEndpoints(Requesters.StaticApiRequester, _cache);
            Status     = new StatusEndpoint(Requesters.StaticApiRequester);

            Clash = new ClashEndpoint(requester, _cache);
        }