Exemplo n.º 1
0
        public async Task <Dictionary <string, List <League> > > RetrieveLeague()
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.leagueAPIVersion, UrlConstants.leaguePart)
                      .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.LoadLeague(responseString));
        }
Exemplo n.º 2
0
        public async Task <Dictionary <string, List <League> > > RetrieveLeagueEntry(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.leagueAPIVersion, UrlConstants.leaguePart)
                          .AppendPathSegments(UrlConstants.byTeamPart, ids, UrlConstants.entryPart);
                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.LoadLeague(responseString));
        }