/// <summary> /// Retrieves the attributes for a given champ (ability cooldowns, mana costs, etc.) /// </summary> /// <param name="championName">Internal champion name (i.e. Vel'Koz -> Velkoz)</param> /// <returns></returns> private async Task <ChampionAttributes> GetChampionInformation(string championName) { string latestVersion; try { string versionJSON = await WebRequestUtil.GetResponse(VERSION_ENDPOINT); List <string> versions = JsonConvert.DeserializeObject <List <string> >(versionJSON); latestVersion = versions[0]; } catch (WebException e) { throw new InvalidOperationException("Error retrieving game version", e); } string championJSON; try { championJSON = await WebRequestUtil.GetResponse(String.Format(CHAMPION_INFO_ENDPOINT, latestVersion, championName)); } catch (WebException e) { throw new InvalidOperationException("Error retrieving champion data for '" + championName + "'", e); } dynamic championData = JsonConvert.DeserializeObject <dynamic>(championJSON); return(ChampionAttributes.FromData(championData.data[championName])); }
private static async void RetrieveItemInfo() { string latestVersion; try { string versionJSON = await WebRequestUtil.GetResponse(VERSION_ENDPOINT); List <string> versions = JsonConvert.DeserializeObject <List <string> >(versionJSON); latestVersion = versions[0]; } catch (WebException e) { throw new InvalidOperationException("Error retrieving game version", e); } string itemsJSON; try { itemsJSON = await WebRequestUtil.GetResponse(String.Format(ITEM_INFO_ENDPOINT, latestVersion)); } catch (WebException e) { throw new InvalidOperationException("Error retrieving item data", e); } dynamic itemsData = JsonConvert.DeserializeObject <dynamic>(itemsJSON); ParseItemInfo(itemsData); }