public string GetSummonerGamesById() { try { using (this.client = new WebClient()) { summonerGamesResponse = client.DownloadString(URLManager.SummonerGamesById(summonerId)); } responseCode = "#02"; } catch (Exception ex) { return("#03"); } try { idName = ReaderManager.FileReader(jsonFilePath); SummonerGames summonerGamesModel = SerializerManager.SummonerGamesSerializer(summonerGamesResponse); this.SummonerGames = NameManager.GamesNameFiller(summonerGamesModel, this.summonerName, idName); } catch (Exception ex) { throw new ArgumentException("Either response serializing or finding name went wrong " + ex.Message); } return(responseCode); }
/// <summary>Gets the summoner stats.</summary> /// <param name="summonerName">Name of the summoner.</param> /// <param name="region">The region.</param> /// <returns></returns> public static AggregatedSummoner GetAggregatedSummonerStats(string summonerName, string region) { Summoner s = RiotAPIManager.GetSummonerBySummonerName(summonerName, region); SummonerGames sg = RiotAPIManager.GetGamesBySummonerId(s.Id.ToString(), region); SummonerDataAggregator sda = new SummonerDataAggregator(sg); return(sda.CalculateAverages()); }
public static SummonerGames GamesNameFiller(SummonerGames summonerGames, string summonerName, Dictionary <int, string> idAndName) { summonerGames.SummonerName = summonerName; try { foreach (var game in summonerGames.Games) { game.ChampionName = idAndName[game.ChampionId]; } } catch (Exception ex) { throw new ArgumentException("Error occured " + ex.Message); } return(summonerGames); }