/// <summary> /// Retrieves a list of featured items, grouped by category. Some of the data in response /// may vary for a given country code and language. /// </summary> /// <param name="countryCode"> /// Two letter country code to customise currency and date values. /// </param> /// <param name="language"> /// Full name of the language in english used for string localization e.g. name, /// description. /// </param> /// <param name="token">Propogates notification that operation should be cancelled.</param> /// <returns>A list of featured items, grouped by category, in the steam store.</returns> public async Task <FeaturedCategories> GetFeaturedCategoriesAsync(CountryCode countryCode, Language language, CancellationToken token = default) { var queryParameters = new QueryParametersBuilder(); if (countryCode != CountryCode.Unknown) { queryParameters.AppendParameter( "cc", CountryCodeConverter.GetCountryCodeStringValue(countryCode) ); } if (language != Language.Unknown) { queryParameters.AppendParameter("l", language.ToString().ToLower()); } using (var response = await GetRetryPolicy().ExecuteAsync( () => _httpClient.GetAsync(_config.SteamStoreBaseUrl + "/api/featuredcategories" + queryParameters.ToString(), token))) { response.EnsureSuccessStatusCode(); var result = await response.Content.ReadAsStringAsync(); var jsonData = JObject.Parse(result); if (jsonData["status"].ToString() != "1") { throw new SteamApiBadRequestException( "Bad request status. Check if you specified right parameters." ); } return(jsonData.ToObject <FeaturedCategories>()); } }
/// <summary> /// Retrieves details for the specified package. Some of the data in response may vary for /// a given country code and language. /// </summary> /// <param name="packageId">Steam package ID.</param> /// <param name="countryCode"> /// Two letter country code to customise currency and date values. /// </param> /// <param name="language"> /// Full name of the language in english used for string localization e.g. title, /// description, release dates. /// </param> /// <param name="token">Propogates notification that operation should be cancelled.</param> /// <returns>Details for a package in the steam store.</returns> public async Task <PackageInfo> GetPackageInfoAsync(int packageId, CountryCode countryCode, Language language, CancellationToken token = default) { var queryParameters = new QueryParametersBuilder(); queryParameters.AppendParameter("packageids", packageId.ToString()); if (countryCode != CountryCode.Unknown) { queryParameters.AppendParameter( "cc", CountryCodeConverter.GetCountryCodeStringValue(countryCode) ); } if (language != Language.Unknown) { queryParameters.AppendParameter("l", language.ToString().ToLower()); } using (var response = await GetRetryPolicy().ExecuteAsync( () => _httpClient.GetAsync(_config.SteamStoreBaseUrl + "/api/packagedetails" + queryParameters.ToString(), token))) { response.EnsureSuccessStatusCode(); var result = await response.Content.ReadAsStringAsync(); // The actual payload is wrapped, drill down to the third level to get to it var jsonData = JToken.Parse(result).First.First; if (!bool.Parse(jsonData["success"].ToString())) { throw new SteamApiBadRequestException( "Bad request status. Check if you specified right PackageID." ); } var package = jsonData["data"].ToObject <PackageInfo>(); package.SteamPackageId = packageId; return(package); } }