protected RiotRestAPI.MatchDTO LoadMatchFromAPI(SeedData.MatchListing listing, string matchId, ref string rawResponse) { RiotRestAPI.MatchDTO match = null; bool rateLimitHit = true; while (rateLimitHit) { string resource = "/" + listing.region + "/v2.2/match/" + matchId; Dictionary <string, string> queryParams = new Dictionary <string, string>(); queryParams["includeTimeline"] = "true"; match = _apiConnection.Get <RiotRestAPI.MatchDTO>(resource, queryParams, ref rateLimitHit, ref rawResponse); if (match != null) { LogProgress("Loaded match " + listing.region + "-" + matchId + " from the API."); } else if (rateLimitHit) { LogProgress("Hit rate limit. Waiting to retry."); System.Threading.Thread.Sleep(RATE_LIMIT_WAIT_IN_MS); } else { LogProgress("Unable to load match: " + listing.region + " - " + matchId); } } return(match); }
public List <string> LoadVersions(string region) { List <string> versions = null; bool rateLimitHit = true; while (rateLimitHit) { string resource = "/static-data/" + region + "/v1.2/versions"; Dictionary <string, string> queryParams = new Dictionary <string, string>(); string rawResponse = ""; versions = _apiConnection.Get <List <string> >(resource, queryParams, ref rateLimitHit, ref rawResponse); if (versions != null) { LogManager.LogMessage("Loaded versions for " + region + " from the API."); } else if (rateLimitHit) { LogManager.LogMessage("Hit rate limit. Waiting to retry."); System.Threading.Thread.Sleep(RATE_LIMIT_WAIT_IN_MS); } else { LogManager.LogMessage("Unable to load versions for region: " + region + "."); } } return(versions); }
public List <int> LoadIds(string region, string version) { List <int> championIds = null; bool rateLimitHit = true; while (rateLimitHit) { string resource = "/static-data/" + region + "/v1.2/champion/"; string rawResponse = ""; Dictionary <string, string> queryParams = new Dictionary <string, string>(); queryParams["version"] = version; _apiConnection.Get <RiotRestAPI.ChampionsDTO>(resource, queryParams, ref rateLimitHit, ref rawResponse); // Use JSON.NET serializer for this, because DataSerializer doesn't get the dictionary right ChampionsDTO champions = JsonConvert.DeserializeObject <ChampionsDTO>(rawResponse); if (champions != null) { LogManager.LogMessage("Loaded champions for " + region + "-" + version + " from the API."); championIds = new List <int>(); foreach (ChampionDTO champion in champions.Champions.Values) { championIds.Add(champion.Id); } championIds.Sort(); } else if (rateLimitHit) { LogManager.LogMessage("Hit rate limit. Waiting to retry."); System.Threading.Thread.Sleep(RATE_LIMIT_WAIT_IN_MS); } else { LogManager.LogMessage("Unable to load champion list for " + region + "-" + version); } } return(championIds); }
public List <int> LoadItemIds(string region, string version) { List <int> itemIds = null; bool rateLimitHit = true; while (rateLimitHit) { string resource = "/static-data/" + region + "/v1.2/item/"; string rawResponse = ""; Dictionary <string, string> queryParams = new Dictionary <string, string>(); queryParams["version"] = version; _apiConnection.Get <RiotRestAPI.ItemsDTO>(resource, queryParams, ref rateLimitHit, ref rawResponse); // Use JSON.NET serializer for this, because DataSerializer doesn't get the dictionary right ItemsDTO items = JsonConvert.DeserializeObject <ItemsDTO>(rawResponse); if (items != null) { LogManager.LogMessage("Loaded items for " + region + "-" + version + " from the API."); itemIds = new List <int>(); foreach (string itemId in items.Items.Keys) { itemIds.Add(Convert.ToInt32(itemId)); } itemIds.Sort(); } else if (rateLimitHit) { LogManager.LogMessage("Hit rate limit. Waiting to retry."); System.Threading.Thread.Sleep(RATE_LIMIT_WAIT_IN_MS); } else { LogManager.LogMessage("Unable to load item list for " + region + "-" + version); } } return(itemIds); }