Пример #1
0
        public async Task <MatchDetailAdvanced> RetrieveMatch(CreepScore.Region region, long matchId, bool includeTimeline = false)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.matchAPIVersion, UrlConstants.matchPart)
                      .AppendPathSegment(matchId.ToString());

            url.SetQueryParams(new
            {
                includeTimeline = includeTimeline.ToString(),
                api_key         = apiKey
            });
            Uri uri = new Uri(url.ToString());

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadMatchDetailAdvanced(JObject.Parse(responseString)));
        }
Пример #2
0
        public async Task <League> RetrieveChallengerLeague(CreepScore.Region region, GameConstants.Queue queue)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.leagueAPIVersion, UrlConstants.leaguePart).AppendPathSegment("challenger");

            url.SetQueryParams(new
            {
                type    = GameConstants.GetQueue(queue),
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadLeague(JObject.Parse(responseString)));
        }
Пример #3
0
        public async Task <List <Champion> > RetrieveChampions(CreepScore.Region region, bool freeToPlay = false)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.championAPIVersion, UrlConstants.championPart);

            url.SetQueryParams(new
            {
                freeToPlay = freeToPlay.ToString(),
                api_key    = apiKey
            });
            Uri uri = new Uri(url.ToString());

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadChampions(JObject.Parse(responseString)));
        }
Пример #4
0
        public async Task <RecentGames> RetrieveRecentGames()
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.gameAPIVersion, UrlConstants.gamePart)
                      .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString(), UrlConstants.recentPart);

            url.SetQueryParams(new
            {
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());

            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadRecentGames(JObject.Parse(responseString)));
        }
Пример #5
0
        public async Task <Dictionary <string, List <Team> > > RetrieveTeams()
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.teamAPIVersion, UrlConstants.teamPart)
                      .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString());

            url.SetQueryParams(new
            {
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());

            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadTeams(responseString));
        }
Пример #6
0
        public async Task <Dictionary <string, RunePages> > RetrieveRunePages()
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.summonerAPIVersion, UrlConstants.summonerPart)
                      .AppendPathSegments(id.ToString(), UrlConstants.runesPart);

            url.SetQueryParams(new
            {
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());

            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadRunePages(responseString));
        }
Пример #7
0
        public async Task <PlayerStatsSummaryList> RetrievePlayerStatsSummaries(CreepScore.Season season)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.statsAPIVersion, UrlConstants.statsPart)
                      .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString(), UrlConstants.summaryPart);

            url.SetQueryParams(new
            {
                season  = CreepScore.GetSeason(season),
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());
            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadPlayerStatSummariesList(JObject.Parse(responseString), season));
        }
Пример #8
0
        public async Task <RankedStats> RetrieveRankedStats(CreepScore.Season season)
        {
            if (summonerLevel == 30)
            {
                Url url = UrlConstants.UrlBuilder(region, UrlConstants.statsAPIVersion, UrlConstants.statsPart)
                          .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString(), UrlConstants.rankedPart);
                url.SetQueryParams(new
                {
                    season  = CreepScore.GetSeason(season),
                    api_key = CreepScore.apiKey
                });
                Uri uri = new Uri(url.ToString());
                await CreepScore.GetPermission(region);

                string responseString;
                try
                {
                    responseString = await CreepScore.GetWebData(uri);
                }
                catch (CreepScoreException)
                {
                    throw;
                }
                return(LoadRankedStats(JObject.Parse(responseString), season));
            }
            else
            {
                throw new CreepScoreException("The summoner is not level 30. They do not have ranked stats.");
            }
        }
Пример #9
0
        public async Task <List <Summoner> > RetrieveSummoners(CreepScore.Region region, List <long> summonerIds)
        {
            string ids = "";

            if (summonerIds.Count > 40)
            {
                throw new CreepScoreException("Cannot retrieve more than 40 summoners at once.");
            }

            for (int i = 0; i < summonerIds.Count; i++)
            {
                if (i != summonerIds.Count - 1)
                {
                    ids += summonerIds[i].ToString() + ",";
                }
                else
                {
                    ids += summonerIds[i].ToString();
                }
            }

            Uri uri;

            if (ids != "")
            {
                Url url = UrlConstants.UrlBuilder(region, UrlConstants.summonerAPIVersion, UrlConstants.summonerPart)
                          .AppendPathSegment(ids);
                url.SetQueryParams(new
                {
                    api_key = apiKey
                });
                uri = new Uri(url.ToString());
            }
            else
            {
                throw new CreepScoreException("Cannot have an empty list of summoner IDs.");
            }

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            List <Summoner> summoners           = new List <Summoner>();
            Dictionary <string, JObject> values = JsonConvert.DeserializeObject <Dictionary <string, JObject> >(responseString);

            foreach (KeyValuePair <string, JObject> value in values)
            {
                summoners.Add(new Summoner(value.Value, region));
            }
            return(summoners);
        }
Пример #10
0
        public async Task <Dictionary <string, Team> > RetrieveTeam(CreepScore.Region region, List <string> teamIds)
        {
            string ids = "";

            if (teamIds.Count > 10)
            {
                throw new CreepScoreException("Cannot retrieve more than 10 teams at once.");
            }

            for (int i = 0; i < teamIds.Count; i++)
            {
                if (i != teamIds.Count - 1)
                {
                    ids += teamIds[i] + ",";
                }
                else
                {
                    ids += teamIds[i];
                }
            }

            Uri uri;

            if (ids != "")
            {
                Url url = UrlConstants.UrlBuilder(region, UrlConstants.teamAPIVersion, UrlConstants.teamPart)
                          .AppendPathSegment(ids);
                url.SetQueryParams(new
                {
                    api_key = apiKey
                });
                uri = new Uri(url.ToString());
            }
            else
            {
                throw new CreepScoreException("Cannot have an empty list of team IDs.");
            }

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadTeam(responseString));
        }
Пример #11
0
        public async Task <Dictionary <long, string> > RetrieveSummonerNames(CreepScore.Region region, List <long> summonerIds)
        {
            string summonerIdsPart = "";

            if (summonerIds.Count > 40)
            {
                throw new CreepScoreException("Cannot retrieve more than 40 summoners at once.");
            }

            for (int i = 0; i < summonerIds.Count; i++)
            {
                if (i != summonerIds.Count - 1)
                {
                    summonerIdsPart += summonerIds[i].ToString() + ",";
                }
                else
                {
                    summonerIdsPart += summonerIds[i].ToString();
                }
            }

            Url url = UrlConstants.UrlBuilder(region, UrlConstants.summonerAPIVersion, UrlConstants.summonerPart)
                      .AppendPathSegments(summonerIdsPart, UrlConstants.namePart);

            url.SetQueryParams(new
            {
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(JsonConvert.DeserializeObject <Dictionary <long, string> >(responseString));
        }
Пример #12
0
        public async Task <Champion> RetrieveChampion(CreepScore.Region region, int id)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.championAPIVersion, UrlConstants.championPart).AppendPathSegment(id.ToString());

            url.SetQueryParams(new
            {
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            await GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadChampion(JObject.Parse(responseString)));
        }