Improved handling for empty parameters.

This commit is contained in:
mmuffins 2018-05-26 18:55:26 +02:00
parent e89704bd97
commit 3ca8090202
4 changed files with 10 additions and 10 deletions

View File

@ -16,19 +16,19 @@ namespace SteamStorefrontAPI
public static async Task<SteamApp> GetAsync(int AppId)
{
return await GetAsync(AppId, null, null);
return await GetAsync(AppId, "", "");
}
public static async Task<SteamApp> GetAsync(int AppId, string CountryCode)
{
return await GetAsync(AppId, CountryCode, null);
return await GetAsync(AppId, CountryCode, "");
}
public static async Task<SteamApp> GetAsync(int AppId, string CountryCode, string Language)
{
string steamUri = $"{steamBaseUri}?appids={AppId}";
steamUri = CountryCode is null ? steamUri : $"{steamUri}&cc={CountryCode}";
steamUri = Language is null ? steamUri : $"{steamUri}&l={Language}";
steamUri = string.IsNullOrWhiteSpace(CountryCode) ? steamUri : $"{steamUri}&cc={CountryCode}";
steamUri = string.IsNullOrWhiteSpace(Language) ? steamUri : $"{steamUri}&l={Language}";
var response = await client.GetAsync(steamUri);
if (!response.IsSuccessStatusCode) { return null; }

View File

@ -28,8 +28,8 @@ namespace SteamStorefrontAPI
public static async Task<FeaturedApps> GetAsync(string CountryCode, string Language)
{
string steamUri = steamBaseUri;
steamUri = CountryCode is null ? steamUri : $"{steamUri}&cc={CountryCode}";
steamUri = Language is null ? steamUri : $"{steamUri}&l={Language}";
steamUri = string.IsNullOrWhiteSpace(CountryCode) ? steamUri : $"{steamUri}&cc={CountryCode}";
steamUri = string.IsNullOrWhiteSpace(Language) ? steamUri : $"{steamUri}&l={Language}";
var response = await client.GetAsync(steamUri);
if (!response.IsSuccessStatusCode) { return null; }

View File

@ -27,8 +27,8 @@ namespace SteamStorefrontAPI
public static async Task<List<FeaturedCategory>> GetAsync(string CountryCode, string Language)
{
string steamUri = steamBaseUri;
steamUri = CountryCode is null ? steamUri : $"{steamUri}&cc={CountryCode}";
steamUri = Language is null ? steamUri : $"{steamUri}&l={Language}";
steamUri = string.IsNullOrWhiteSpace(CountryCode) ? steamUri : $"{steamUri}&cc={CountryCode}";
steamUri = string.IsNullOrWhiteSpace(Language) ? steamUri : $"{steamUri}&l={Language}";
var response = await client.GetAsync(steamUri);
if (!response.IsSuccessStatusCode) { return null; }

View File

@ -27,8 +27,8 @@ namespace SteamStorefrontAPI
public static async Task<PackageInfo> GetAsync(int PackageId, string CountryCode, string Language)
{
string steamUri = $"{steamBaseUri}?packageids={PackageId}";
steamUri = CountryCode is null ? steamUri : $"{steamUri}&cc={CountryCode}";
steamUri = Language is null ? steamUri : $"{steamUri}&l={Language}";
steamUri = string.IsNullOrWhiteSpace(CountryCode) ? steamUri : $"{steamUri}&cc={CountryCode}";
steamUri = string.IsNullOrWhiteSpace(Language) ? steamUri : $"{steamUri}&l={Language}";
var response = await client.GetAsync(steamUri);
if (!response.IsSuccessStatusCode) { return null; }