Ejemplo n.º 1
0
        public List <LeagueEntry> GetLeagueEntriesOfSummoner(string summonerId, string region)
        {
            var pathBuilder   = new UrlPathBuilder();
            var leagueEntries = new List <LeagueEntry>();

            using (var client = new HttpClient())
            {
                try
                {
                    client.DefaultRequestHeaders.Add("X-Riot-Token", ConfigWrapper.ApiKey);
                    var response = client.GetAsync(new Uri(pathBuilder.GetLeagueEntriesBySummonerIdUrl(summonerId, region)));
                    response.Wait();

                    var result = response.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        var readData = result.Content.ReadAsStringAsync();
                        readData.Wait();

                        leagueEntries = JsonConvert.DeserializeObject <List <LeagueEntry> >(readData.Result);
                    }
                }
                catch (Exception) {}
            }

            SummonerInfoUtils.SetLeagueEntriesWinRates(leagueEntries);
            return(leagueEntries);
        }