예제 #1
0
        /// <summary>
        /// Retrieve all matchs by an user account id
        /// </summary>
        /// <param name="encryptedAccountId">Encrypted account id</param>
        /// <param name="queryParams">Match request parameters value</param>
        /// <returns>Match list</returns>
        public async Task <MatchList> GetMatchListByEncryptedAccountId(string encryptedAccountId, MatchRequestParameters queryParams = null)
        {
            if (base.ServiceConfigured)
            {
                HttpRequestMessage requestMessage;
                var pathParams = new Dictionary <string, object>()
                {
                    { nameof(encryptedAccountId), encryptedAccountId }
                };

                if (queryParams == null)
                {
                    requestMessage = new HttpRequestMessage(HttpMethod.Get, ApiService.BuildUri(RiotGames.Properties.Resources.MATCH_ALL_ACCOUNT_ID, pathParams));
                }
                else
                {
                    requestMessage = new HttpRequestMessage(HttpMethod.Get, ApiService.BuildUri(RiotGames.Properties.Resources.MATCH_ALL_ACCOUNT_ID, pathParams, queryParams));
                }

                var response = await base.Client.SendAsync(requestMessage);

                if (response.IsSuccessStatusCode)
                {
                    return(await response.Content.ReadAsAsync <MatchList>());
                }
                else
                {
                    throw new HttpRequestException($"Code: {(int)response.StatusCode}-{response.StatusCode}, Location: {GetType().FullName}, Description: {response.ReasonPhrase}");
                }
            }
            throw new HttpServiceNotConfiguredException(base.Client);
        }
        /// <summary>
        /// Create a tournament code
        /// </summary>
        /// <param name="queryParams">Tournament request parameters</param>
        /// <param name="body">Tournament code parameters</param>
        /// <returns>List of tournament codes</returns>
        public async Task <List <string> > CreateTournamentCode(TournamentRequestParameters queryParams, TournamentCodeParameters body)
        {
            if (base.ServiceConfigured)
            {
                if (body == null)
                {
                    throw new Exception("The body must not be null");
                }

                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, ApiService.BuildUri(RiotGames.Properties.Resources.TOURNAMENT_STUB_CODE, queryParameters: queryParams))
                {
                    Content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json")
                };

                var response = await base.Client.SendAsync(request);

                if (response.IsSuccessStatusCode)
                {
                    return(await response.Content.ReadAsAsync <List <string> >());
                }
                else
                {
                    throw new HttpRequestException($"Code: {(int)response.StatusCode}-{response.StatusCode}, Location: {GetType().FullName}, Description: {response.ReasonPhrase}");
                }
            }
            throw new HttpServiceNotConfiguredException(base.Client);
        }
예제 #3
0
        /// <summary>
        /// Update the tournament code
        /// </summary>
        /// <param name="tournamentCode">Code of the tournament</param>
        /// <param name="body">Tournament code parameters</param>
        public async void UpdateTournamentCode(string tournamentCode, TournamentCodeParameters body)
        {
            if (base.ServiceConfigured)
            {
                if (body == null)
                {
                    throw new Exception("The body must not be null");
                }

                var pathParams = new Dictionary <string, object>()
                {
                    { nameof(tournamentCode), tournamentCode }
                };

                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, ApiService.BuildUri(RiotGames.Properties.Resources.TOURNAMENT_PUT_TOURNAMENT_CODE, pathParams))
                {
                    Content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json")
                };

                var response = await base.Client.SendAsync(request);

                if (!response.IsSuccessStatusCode)
                {
                    throw new HttpRequestException($"Code: {(int)response.StatusCode}-{response.StatusCode}, Location: {GetType().FullName}, Description: {response.ReasonPhrase}");
                }
            }
            throw new HttpServiceNotConfiguredException(base.Client);
        }
예제 #4
0
        /// <summary>
        /// Retrieves all the league entries
        /// </summary>
        /// <param name="queue">Queue type</param>
        /// <param name="tier">Tier value</param>
        /// <param name="division">Division value</param>
        /// <param name="queryParams">League request parameters value</param>
        /// <returns></returns>
        public async Task <HashSet <LeagueEntry> > GetAllLeagueEntries(QueueEnum queue, TierEnum tier, DivisionEnum division, LeagueRequestParameters queryParams = null)
        {
            if (base.ServiceConfigured)
            {
                HttpRequestMessage requestMessage;
                var pathParams = new Dictionary <string, object>
                {
                    { nameof(queue), queue.ToString() },
                    { nameof(tier), tier.ToString() },
                    { nameof(division), division.ToString() }
                };

                if (queryParams == null)
                {
                    requestMessage = new HttpRequestMessage(HttpMethod.Get, ApiService.BuildUri(RiotGames.Properties.Resources.LEAGUE_QUEUE_TIER_DIVISION, pathParams));
                }
                else
                {
                    requestMessage = new HttpRequestMessage(HttpMethod.Get, ApiService.BuildUri(RiotGames.Properties.Resources.LEAGUE_QUEUE_TIER_DIVISION, pathParams, queryParams));
                }

                var response = await base.Client.SendAsync(requestMessage);

                if (response.IsSuccessStatusCode)
                {
                    return(await response.Content.ReadAsAsync <HashSet <LeagueEntry> >());
                }
                else
                {
                    throw new HttpRequestException($"Code: {(int)response.StatusCode}-{response.StatusCode}, Location: {GetType().FullName}, Description: {response.ReasonPhrase}");
                }
            }
            throw new HttpServiceNotConfiguredException(base.Client);
        }
예제 #5
0
        /// <summary>
        /// Retrieve the masteries related to a specific summoner
        /// and on a specific champion
        /// </summary>
        /// <param name="championId">Champion id</param>
        /// <param name="encryptedSummonerId">Summoner id encrypted</param>
        /// <returns>Mastery on champion</returns>
        public async Task <ChampionMastery> GetChampionMasteryByChampionIdAndEncryptedSummonerId(long championId, string encryptedSummonerId)
        {
            if (base.ServiceConfigured)
            {
                var pathParams = new Dictionary <string, object>
                {
                    { nameof(encryptedSummonerId), encryptedSummonerId },
                    { nameof(championId), championId }
                };

                var response = await base.Client.SendAsync(new HttpRequestMessage(HttpMethod.Get, ApiService.BuildUri(RiotGames.Properties.Resources.CHAMPION_MASTERY_SUMMONER_CHAMPION_ID, pathParams)));

                if (response.IsSuccessStatusCode)
                {
                    return(await response.Content.ReadAsAsync <ChampionMastery>());
                }
                else
                {
                    throw new HttpRequestException($"Code: {(int)response.StatusCode}-{response.StatusCode}, Location: {GetType().FullName}, Description: {response.ReasonPhrase}");
                }
            }
            throw new HttpServiceNotConfiguredException(base.Client);
        }
        /// <summary>
        /// Retrieve a lobby event based on tournament code
        /// </summary>
        /// <param name="tournamentCode">code of the tournament</param>
        /// <returns>Lobby event object value</returns>
        public async Task <LobbyEventWrapper> GetLobbyEventWrapperByTournamentCode(string tournamentCode)
        {
            if (base.ServiceConfigured)
            {
                var pathParams = new Dictionary <string, object>()
                {
                    { nameof(tournamentCode), tournamentCode }
                };

                var response = await base.Client.SendAsync(new HttpRequestMessage(HttpMethod.Get, ApiService.BuildUri(RiotGames.Properties.Resources.TOURNAMENT_STUB_TOURNAMENT_CODE, pathParams)));

                if (response.IsSuccessStatusCode)
                {
                    return(await response.Content.ReadAsAsync <LobbyEventWrapper>());
                }
                else
                {
                    throw new HttpRequestException($"Code: {(int)response.StatusCode}-{response.StatusCode}, Location: {GetType().FullName}, Description: {response.ReasonPhrase}");
                }
            }
            throw new HttpServiceNotConfiguredException(base.Client);
        }
예제 #7
0
        /// <summary>
        /// Retrieve a match by his id
        /// </summary>
        /// <param name="matchId">Match id</param>
        /// <returns>Match value</returns>
        public async Task <Match> GetMatchById(long matchId)
        {
            if (base.ServiceConfigured)
            {
                var pathParams = new Dictionary <string, object>()
                {
                    { nameof(matchId), matchId }
                };

                var response = await base.Client.SendAsync(new HttpRequestMessage(HttpMethod.Get, ApiService.BuildUri(RiotGames.Properties.Resources.MATCH_MATCH_ID, pathParams)));

                if (response.IsSuccessStatusCode)
                {
                    return(await response.Content.ReadAsAsync <Match>());
                }
                else
                {
                    throw new HttpRequestException($"Code: {(int)response.StatusCode}-{response.StatusCode}, Location: {GetType().FullName}, Description: {response.ReasonPhrase}");
                }
            }
            throw new HttpServiceNotConfiguredException(base.Client);
        }
예제 #8
0
        /// <summary>
        /// Retrieve current game info by the summoner id
        /// </summary>
        /// <param name="encryptedSummonerId">Encrypted summoner id</param>
        /// <returns>Current game info values</returns>
        public async Task <CurrentGameInfo> GetCurrentGameInfoBySummonerId(string encryptedSummonerId)
        {
            if (base.ServiceConfigured)
            {
                var pathParams = new Dictionary <string, object>()
                {
                    { nameof(encryptedSummonerId), encryptedSummonerId }
                };

                var response = await base.Client.SendAsync(new HttpRequestMessage(HttpMethod.Get, ApiService.BuildUri(RiotGames.Properties.Resources.SPECTATOR_CURRENT_GAME_SUMMONER_ID, pathParams)));

                if (response.IsSuccessStatusCode)
                {
                    return(await response.Content.ReadAsAsync <CurrentGameInfo>());
                }
                else
                {
                    throw new HttpRequestException($"Code: {(int)response.StatusCode}-{response.StatusCode}, Location: {GetType().FullName}, Description: {response.ReasonPhrase}");
                }
            }
            throw new HttpServiceNotConfiguredException(base.Client);
        }
예제 #9
0
        /// <summary>
        /// Retrieve the grand master league based on queue
        /// </summary>
        /// <param name="queue">Queue type</param>
        /// <returns>Content of the league</returns>
        public async Task <LeagueList> GetGrandMasterLeagueByQueue(QueueEnum queue)
        {
            if (base.ServiceConfigured)
            {
                var pathParams = new Dictionary <string, object>
                {
                    { nameof(queue), queue.ToString() }
                };

                var response = await base.Client.SendAsync(new HttpRequestMessage(HttpMethod.Get, ApiService.BuildUri(RiotGames.Properties.Resources.LEAGUE_GRANDMASTER_QUEUE, pathParams)));

                if (response.IsSuccessStatusCode)
                {
                    return(await response.Content.ReadAsAsync <LeagueList>());
                }
                else
                {
                    throw new HttpRequestException($"Code: {(int)response.StatusCode}-{response.StatusCode}, Location: {GetType().FullName}, Description: {response.ReasonPhrase}");
                }
            }
            throw new HttpServiceNotConfiguredException(base.Client);
        }