/// <summary> /// Invokes the Games/ByGameName API /// </summary> /// <param name="name">Game Name to search for</param> /// <param name="platform">Platform ID to filter</param> /// <param name="includeOptional">Include optional parameters</param> /// <returns>ByGameName result</returns> public async Task <ByGameName> GetByGameNameAsync(string name, int platform = -1, bool includeOptional = true) { if (!IsInitialized()) { throw new InvalidOperationException("API is not initialized"); } var uriString = new StringBuilder(); uriString.Append(_BASE_URL); uriString.Append(_GAMES_BY_GAME_NAME); uriString.Append(String.Format(_API_KEY_FMT, ApiKey)); uriString.Append(String.Format(_NAME_FMT, name)); if (includeOptional) { uriString.Append(_GAMES_BY_GAME_NAME_OPTIONAL_FIELDS); } if (platform != -1) { uriString.Append(String.Format(_PLATFORM_FMT, platform)); } var uri = new Uri(uriString.ToString()); var jsonResult = await _httpClient.GetStringAsync(uri); return(ByGameName.FromJson(jsonResult)); }
public static string ToJson(this ByGameName self) => JsonConvert.SerializeObject(self, Converter.Settings);