Ejemplo n.º 1
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));
        }