Exemplo n.º 1
0
        public void GetShardStatusByRegion(RiotApiConfig.Regions region)
        {
            var dto = GlobalSetup.RiotHttpClient.LolStatus.GetShardStatusByRegion(region);

            Assert.NotNull(dto);
            Console.WriteLine(dto);
        }
Exemplo n.º 2
0
        public void PrepareModel(RiotApiConfig.Regions region, Enums.GameQueueType gameQueueType, LeaderboardModel model, List <LeagueDto.LeagueEntryDto> topEntries)
        {
            var ddragonVersions = _memoryCache.Get(CacheKeys.DataDragonVersionByRegionKey, DateTime.UtcNow.AddDays(1),
                                                   () => _riotClient.LolStaticData.GetVersionData(region));

            var summonerOrTeamIds = topEntries.Select(x => x.PlayerOrTeamId).ToArray();
            var summonerCacheKey  = string.Format(CacheKeys.SummonerByRegionAndIdCacheKey, region, summonerOrTeamIds);

            var summoners = _cacheManager.Get(summonerCacheKey, DateTime.UtcNow.AddDays(1),
                                              () => _riotClient.Summoner.GetSummonersById(region, summonerOrTeamIds));

            model.LeagueEntryModels = new List <LeaderboardModel.SummonerEntryModel>();
            foreach (var topEntry in topEntries)
            {
                LeaderboardModel.SummonerEntryModel summonerEntryModel = new LeaderboardModel.SummonerEntryModel();
                summonerEntryModel.LeagueEntry = topEntry;
                if (gameQueueType == Enums.GameQueueType.RANKED_SOLO_5x5)
                {
                    var summonerDto = summoners[topEntry.PlayerOrTeamId];
                    if (summonerDto != null)
                    {
                        summonerEntryModel.SummonerIcon =
                            $"http://ddragon.leagueoflegends.com/cdn/{ddragonVersions.FirstOrDefault()}/img/profileicon/{summonerDto.ProfileIconId}.png";
                    }
                }
                model.LeagueEntryModels.Add(summonerEntryModel);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Retrieves summoner spell list.
        /// Rate Limit Notes
        /// Requests to this API will not be counted in your Rate Limit.
        /// Implementation Notes
        /// Not all data specified below is returned by default. See the spellData parameter for more information.
        /// </summary>
        /// <param name="region">Region from which to retrieve data.</param>
        /// <param name="locale">Locale code for returned data (e.g., en_US, es_ES). If not specified, the default locale for the region is used.</param>
        /// <param name="version">Data dragon version for returned data. If not specified, the latest version for the region is used. List of valid versions can be obtained from the /versions endpoint.</param>
        /// <param name="dataById">If specified as true, the returned data map will use the spells' IDs as the keys. If not specified or specified as false, the returned data map will use the spells' keys instead.</param>
        /// <param name="spellData">Tags to return additional data. Only type, version, data, id, key, name, description, and summonerLevel are returned by default if this parameter isn't specified. To return all additional data, use the tag 'all'.</param>
        /// <returns>SummonerSpellListDto - This object contains summoner spell list data.</returns>
        public SummonerSpellListDto GetSummonerSpellList(RiotApiConfig.Regions region, string locale = null, string version = null,
                                                         bool?dataById = null, string spellData = null)
        {
            //https://global.api.pvp.net/api/lol/static-data/eune/v1.2/summoner-spell?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(RiotApiConfig.Regions.Global);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/static-data/{region.ToString().ToLower()}/v1.2/summoner-spell?api_key={this.ApiKey}";

            //add additional parameters
            if (!string.IsNullOrEmpty(locale))
            {
                apiCallPath += $"&locale={locale}";
            }
            if (!string.IsNullOrEmpty(version))
            {
                apiCallPath += $"&version={version}";
            }
            if (dataById.HasValue)
            {
                apiCallPath += $"&dataById={dataById}";
            }
            if (!string.IsNullOrEmpty(spellData))
            {
                apiCallPath += $"&spellData={spellData}";
            }
            //make the call
            var dto = MakeCallToRiotApi <SummonerSpellListDto>(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Retrieve match history by summoner ID.
        /// Implementation Notes
        /// The maximum range for begin and end index is 15. If the range is more than 15,
        /// the end index will be modified to enforce the 15 game limit.If only one of the index parameters is specified,
        /// the other will be computed accordingly.
        /// </summary>
        /// <param name="region">The region of the summoner.</param>
        /// <param name="summonerId">The ID of the summoner.</param>
        /// <param name="championIds">Comma-separated list of champion IDs to use for fetching games.</param>
        /// <param name="rankedQueues">Comma-separated list of ranked queue types to use for fetching games. Non-ranked queue types will be ignored.</param>
        /// <param name="beginIndex">The begin index to use for fetching games.</param>
        /// <param name="endIndex">The end index to use for fetching games.</param>
        /// <returns>PlayerHistory - This object contains player match history information</returns>
        public PlayerHistory GetMatchHistoryBySummonerId(RiotApiConfig.Regions region, long summonerId, string championIds = null, string rankedQueues = null, int?beginIndex = default(int?), int?endIndex = default(int?))
        {
            //https://eune.api.pvp.net/api/lol/eune/v2.2/matchhistory/22293716?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(region);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/{region.ToString().ToLower()}/v2.2/matchhistory/{summonerId}?api_key={this.ApiKey}";

            //add additional parameters
            if (!string.IsNullOrEmpty(championIds))
            {
                apiCallPath += $"&championIds={championIds}";
            }
            if (!string.IsNullOrEmpty(rankedQueues))
            {
                apiCallPath += $"&rankedQueues={rankedQueues}";
            }
            if (beginIndex.HasValue)
            {
                apiCallPath += $"&beginIndex={beginIndex}";
            }
            if (endIndex.HasValue)
            {
                apiCallPath += $"&endIndex={endIndex}";
            }
            //make the call
            var dto = MakeCallToRiotApi <PlayerHistory>(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Retrieves a champion by its id.
        /// Rate Limit Notes
        /// Requests to this API will not be counted in your Rate Limit.
        /// Implementation Notes
        /// Not all data specified below is returned by default. See the champData parameter for more information.
        /// </summary>
        /// <param name="region">Region from which to retrieve data.</param>
        /// <param name="id">Champion ID</param>
        /// <param name="locale">Locale code for returned data (e.g., en_US, es_ES). If not specified, the default locale for the region is used.</param>
        /// <param name="version">Data dragon version for returned data. If not specified, the latest version for the region is used. List of valid versions can be obtained from the /versions endpoint.</param>
        /// <param name="champData">Tags to return additional data. Only id, key, name, and title are returned by default if this parameter isn't specified. To return all additional data, use the tag 'all'.</param>
        /// <returns></returns>
        public ChampionDto GetChampionById(RiotApiConfig.Regions region, int id, string locale = null, string version = null, string champData = null)
        {
            //https://global.api.pvp.net/api/lol/static-data/eune/v1.2/champion/254?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(RiotApiConfig.Regions.Global);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/static-data/{region.ToString().ToLower()}/v1.2/champion/{id}?api_key={this.ApiKey}";

            //add additional parameters
            if (!string.IsNullOrEmpty(locale))
            {
                apiCallPath += $"&locale={locale}";
            }
            if (!string.IsNullOrEmpty(version))
            {
                apiCallPath += $"&version={version}";
            }
            if (!string.IsNullOrEmpty(champData))
            {
                apiCallPath += $"&champData={champData}";
            }
            //make the call
            var dto = MakeCallToRiotApi <ChampionDto>(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get a player's total champion mastery score, which is sum of individual champion mastery levels (RPC)
        /// </summary>
        /// <param name="region">Region where to retrieve the data.</param>
        /// <param name="playerID">Summoner ID associated with the player.</param>
        /// <returns>int</returns>
        public int RetrieveChampionMasterScore(RiotApiConfig.Regions region, long playerID)
        {
            var endPoint    = RiotApiConfig.GetRegionalEndPointByRegion(region);
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"championmastery/location/{endPoint.PlatformId.ToLower()}/player/{playerID}/score?api_key={this.ApiKey}";

            return(MakeCallToRiotApi <int>(baseUrl, apiCallPath));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Get specified number of top champion mastery entries sorted by number of champion points descending (RPC)
        /// </summary>
        /// <param name="region">Region where to retrieve the data.</param>
        /// <param name="playerID">Summoner ID associated with the player.</param>
        /// <returns>Collection of ChampionMasteryDTOs - This object contains single Champion Mastery information for player and champion combination.</returns>
        public IEnumerable <ChampionMasteryDto> RetrieveTopChampions(RiotApiConfig.Regions region, long playerID, int?count)
        {
            var endPoint    = RiotApiConfig.GetRegionalEndPointByRegion(region);
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"championmastery/location/{endPoint.PlatformId.ToLower()}/player/{playerID}/topchampions?api_key={this.ApiKey}";

            if (count.HasValue)
            {
                apiCallPath += $"&count={count}";
            }

            return(MakeCallToRiotApi <IEnumerable <ChampionMasteryDto> >(baseUrl, apiCallPath));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Get leagues mapped by summoner ID for a given list of summoner IDs.
        /// Implementation Notes :
        /// Returns all leagues for specified summoners and summoners' teams. Entries for each requested participant
        /// (i.e., each summoner and related teams) will be included in the returned leagues data,
        /// whether or not the participant is inactive. However, no entries for other inactive summoners or teams in the leagues will be included.
        /// </summary>
        /// <param name="region">The region of the leagues.</param>
        /// <param name="summonerIds">Comma-separated list of summoner IDs. Maximum allowed at once is 10.</param>
        /// <returns>Map[string, List[LeagueDto]] LeagueDto - This object contains league information.</returns>
        public Dictionary <string, IEnumerable <LeagueDto> > GetSummonerLeaguesByIds(RiotApiConfig.Regions region, params long[] summonerIds)
        {
            //https://eune.api.pvp.net/api/lol/eune/v2.5/league/by-summoner/22293716,41488614?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(region);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/{region.ToString().ToLower()}/v2.5/league/by-summoner/{string.Join(",", summonerIds)}?api_key={this.ApiKey}";
            //make the call
            var dto = MakeCallToRiotApi <Dictionary <string, IEnumerable <LeagueDto> > >(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Get master tier leagues.
        /// </summary>
        /// <param name="region">Region where to retrieve the data.</param>
        /// <param name="type">Game queue type.</param>
        /// <returns>LeagueDto - This object contains league information.</returns>
        public LeagueDto GetMasterTierLeagues(RiotApiConfig.Regions region, Enums.GameQueueType type)
        {
            //https://eune.api.pvp.net/api/lol/eune/v2.5/league/master?type=RANKED_TEAM_5x5&api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(region);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/{region.ToString().ToLower()}/v2.5/league/master?type={type}&api_key={this.ApiKey}";
            //make the call
            var dto = MakeCallToRiotApi <LeagueDto>(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Retrieve champion by ID.
        /// </summary>
        /// <param name="region">Region where to retrieve the data.</param>
        /// <param name="id">ID of the champion to retrieve.</param>
        /// <returns>ChampionDto - This object contains champion information.</returns>
        public ChampionListDto.ChampionDto RetrieveChampionById(RiotApiConfig.Regions region, int id)
        {
            //https://eune.api.pvp.net/api/lol/eune/v1.2/champion/1?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(region);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/{endPoint.Region.ToLower()}/v1.2/champion/{id}?api_key={this.ApiKey}";
            //make the call
            var dto = MakeCallToRiotApi <ChampionListDto.ChampionDto>(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Get recent games by summoner ID.
        /// </summary>
        /// <param name="region">Region where to retrieve the data.</param>
        /// <param name="summonerId">ID of the summoner for which to retrieve recent games.</param>
        /// <returns>RecentGamesDto - This object contains recent games information.</returns>
        public RecentGamesDto GetRecentGamesBySummonerId(RiotApiConfig.Regions region, long summonerId)
        {
            //https://eune.api.pvp.net/api/lol/eune/v1.3/game/by-summoner/41488614/recent?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(region);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/{region.ToString().ToLower()}/v1.3/game/by-summoner/{summonerId}/recent?api_key={this.ApiKey}";
            //make the call
            var dto = MakeCallToRiotApi <RecentGamesDto>(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Get summoner names mapped by summoner ID for a given list of summoner IDs.
        /// </summary>
        /// <param name="region">Region where to retrieve the data.</param>
        /// <param name="summonerIds">Comma-separated list of summoner IDs associated with summoner names to retrieve. Maximum allowed at once is 40.</param>
        /// <returns>Return Value: Map[string, string]</returns>
        public Dictionary <string, string> GetSummonerNamesBySummonerId(RiotApiConfig.Regions region, params string[] summonerIds)
        {
            //https://eune.api.pvp.net/api/lol/eune/v1.4/summoner/41488614,41468510/name?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(region);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/{region.ToString().ToLower()}/v1.4/summoner/{string.Join(",", summonerIds)}/name?api_key={this.ApiKey}";
            //make the call
            var dto = MakeCallToRiotApi <Dictionary <string, string> >(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Get shard status.Returns the data available on the status.leagueoflegends.com website for the given region.
        /// Rate Limit Notes
        /// Requests to this API will not be counted in your Rate Limit.
        /// </summary>
        /// <param name="region">The region for which to fetch data.</param>
        /// <returns>Return Value: ShardStatus</returns>
        public ShardStatusDto GetShardStatusByRegion(RiotApiConfig.Regions region)
        {
            //http://status.leagueoflegends.com/shards/eune
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.StatusUrl;
            //compose url
            var baseUrl     = $"http://{endPoint}/";
            var apiCallPath = $"shards/{region.ToString().ToLower()}";
            //make the call
            var dto = MakeCallToRiotApi <ShardStatusDto>(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Get leagues mapped by team ID for a given list of team IDs.
        /// Implementation Notes :
        /// Returns all leagues for specified teams.Entries for each requested team will be included in the returned leagues data,
        /// whether or not the team is inactive.However, no entries for other inactive teams in the leagues will be included.
        /// </summary>
        /// <param name="region">The region of the leagues.</param>
        /// <param name="teamIds">Comma-separated list of team IDs. Maximum allowed at once is 10.</param>
        /// <returns>Map[string, List[LeagueDto]] LeagueDto - This object contains league information.</returns>
        public Dictionary <string, IEnumerable <LeagueDto> > GetTeamLeaguesbyIds(RiotApiConfig.Regions region, params string[] teamIds)
        {
            //https://eune.api.pvp.net/api/lol/eune/v2.5/league/by-team/TEAM-18cc5c20-b4f9-11e4-80a9-782bcb46f3e4,TEAM-b999b8d0-18d8-11e5-8e2b-782bcb46f3e4?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(region);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/{region.ToString().ToLower()}/v2.5/league/by-team/{string.Join(",", teamIds)}?api_key={this.ApiKey}";
            //make the call
            var dto = MakeCallToRiotApi <Dictionary <string, IEnumerable <LeagueDto> > >(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Get list of featured games
        /// </summary>
        /// <param name="region">Region where to retrieve the data.</param>
        /// <returns>FeaturedGames</returns>
        public Dto.FeaturedGames.FeaturedGames GetListOfFeaturedGames(RiotApiConfig.Regions region)
        {
            //https://eune.api.pvp.net/observer-mode/rest/featured?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(region);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"observer-mode/rest/featured?api_key={this.ApiKey}";
            //make the call
            var dto = MakeCallToRiotApi <Dto.FeaturedGames.FeaturedGames>(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Retrieve version data.
        /// Rate Limit Notes
        /// Requests to this API will not be counted in your Rate Limit.
        /// </summary>
        /// <param name="region"></param>
        /// <returns>Return Value: List[string]</returns>
        public IEnumerable <string> GetVersionData(RiotApiConfig.Regions region)
        {
            //https://global.api.pvp.net/api/lol/static-data/eune/v1.2/versions?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(RiotApiConfig.Regions.Global);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/static-data/{region.ToString().ToLower()}/v1.2/versions?api_key={this.ApiKey}";
            //make the call
            var dto = MakeCallToRiotApi <IEnumerable <string> >(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Get player stats summaries by summoner ID.
        /// </summary>
        /// <param name="region">Region where to retrieve the data.</param>
        /// <param name="summonerId">ID of the summoner for which to retrieve player stats.</param>
        /// <param name="season">If specified, stats for the given season are returned. Otherwise, stats for the current season are returned.</param>
        /// <returns>PlayerStatsSummaryListDto - This object contains a collection of player stats summary information.</returns>
        public PlayerStatsSummaryListDto GetPlayerStatsBySummonerId(RiotApiConfig.Regions region, long summonerId, string season = null)
        {
            //https://eune.api.pvp.net/api/lol/eune/v1.3/stats/by-summoner/22293716/summary?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(region);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/{region.ToString().ToLower()}/v1.3/stats/by-summoner/{summonerId}/summary?api_key={this.ApiKey}";

            //add additional parameters
            if (!string.IsNullOrEmpty(season))
            {
                apiCallPath += $"&season={season}";
            }
            //make the call
            var dto = MakeCallToRiotApi <PlayerStatsSummaryListDto>(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Retrieve all champions. (REST)
        /// </summary>
        /// <param name="region">Region where to retrieve the data.</param>
        /// <param name="freeToPlay">Optional filter param to retrieve only free to play champions.</param>
        /// <returns>ChampionListDto - This object contains a collection of champion information.</returns>
        public ChampionListDto RetrieveAllChampions(RiotApiConfig.Regions region, bool?freeToPlay = null)
        {
            //https://eune.api.pvp.net/api/lol/eune/v1.2/champion?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(region);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/{endPoint.Region.ToLower()}/v1.2/champion?api_key={this.ApiKey}";

            //add additional parameters
            if (freeToPlay.HasValue)
            {
                apiCallPath += $"&freeToPlay={freeToPlay}";
            }
            //make the call
            var dto = MakeCallToRiotApi <ChampionListDto>(baseUrl, apiCallPath);

            return(dto);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Retrieve match by match ID.
        /// Implementation Notes
        /// Not all matches have timeline data.If timeline data is requested, but doesn't exist, then the response won't include it.
        /// </summary>
        /// <param name="region">The region of the summoner.</param>
        /// <param name="matchId">The ID of the match.</param>
        /// <param name="includeTimeline">Flag indicating whether or not to include match timeline data</param>
        /// <returns>MatchDetail - This object contains match detail information</returns>
        public MatchDetail GetMatchById(RiotApiConfig.Regions region, long matchId, bool?includeTimeline = null)
        {
            //https://eune.api.pvp.net/api/lol/eune/v2.2/match/1?api_key=
            //find the appropriate end point depending the region
            var endPoint = RiotApiConfig.GetRegionalEndPointByRegion(region);
            //compose url
            var baseUrl     = $"https://{endPoint.Host}/";
            var apiCallPath = $"api/lol/{region.ToString().ToLower()}/v2.2/match/{matchId}?api_key={this.ApiKey}";

            //add additional parameters
            if (includeTimeline.HasValue)
            {
                apiCallPath += $"&includeTimeline={includeTimeline}";
            }
            //make the call
            var dto = MakeCallToRiotApi <MatchDetail>(baseUrl, apiCallPath);

            return(dto);
        }