From 26dc983c1445827dd08ba7583ba93c83c1147485 Mon Sep 17 00:00:00 2001 From: mmuffins Date: Tue, 29 May 2018 23:12:11 +0200 Subject: [PATCH] Improved parameter handling. --- .../Classes/appdetails/Achievements.cs | 7 ++++- .../Classes/appdetails/Movie.cs | 7 ++++- .../Classes/appdetails/PackageGroup.cs | 7 ++++- .../Classes/appdetails/SteamApp.cs | 31 +++++++++++++------ .../Classes/featured/FeaturedApps.cs | 16 +++++++--- .../featuredcategories/FeaturedCategory.cs | 7 ++++- .../Classes/packagedetails/PackageInfo.cs | 8 ++++- .../Endpoints/FeaturedCategories.cs | 6 ++-- SteamStorefrontConsole/Program.cs | 4 +-- 9 files changed, 70 insertions(+), 23 deletions(-) diff --git a/SteamStorefrontAPI/Classes/appdetails/Achievements.cs b/SteamStorefrontAPI/Classes/appdetails/Achievements.cs index 33b1ee8..8ef890d 100644 --- a/SteamStorefrontAPI/Classes/appdetails/Achievements.cs +++ b/SteamStorefrontAPI/Classes/appdetails/Achievements.cs @@ -15,6 +15,11 @@ namespace SteamStorefrontAPI.Classes public long Total { get; set; } [JsonProperty("highlighted")] - public List Highlighted { get; set; } + public List Highlighted { get; } + + public Achievements() + { + this.Highlighted = new List(); + } } } diff --git a/SteamStorefrontAPI/Classes/appdetails/Movie.cs b/SteamStorefrontAPI/Classes/appdetails/Movie.cs index 2778206..9cd5577 100644 --- a/SteamStorefrontAPI/Classes/appdetails/Movie.cs +++ b/SteamStorefrontAPI/Classes/appdetails/Movie.cs @@ -21,10 +21,15 @@ namespace SteamStorefrontAPI.Classes public string Thumbnail { get; set; } [JsonProperty("webm")] - public Dictionary Webm { get; set; } + public Dictionary Webm { get; } [JsonProperty("highlight")] public bool Highlight { get; set; } + + public Movie() + { + this.Webm = new Dictionary(); + } } } diff --git a/SteamStorefrontAPI/Classes/appdetails/PackageGroup.cs b/SteamStorefrontAPI/Classes/appdetails/PackageGroup.cs index 9c59873..7cc9967 100644 --- a/SteamStorefrontAPI/Classes/appdetails/PackageGroup.cs +++ b/SteamStorefrontAPI/Classes/appdetails/PackageGroup.cs @@ -34,6 +34,11 @@ namespace SteamStorefrontAPI.Classes public string IsRecurringSubscription { get; set; } [JsonProperty("subs")] - public List Subs { get; set; } + public List Subs { get; } + + public PackageGroup() + { + this.Subs = new List(); + } } } diff --git a/SteamStorefrontAPI/Classes/appdetails/SteamApp.cs b/SteamStorefrontAPI/Classes/appdetails/SteamApp.cs index 0a3bab8..0a3d415 100644 --- a/SteamStorefrontAPI/Classes/appdetails/SteamApp.cs +++ b/SteamStorefrontAPI/Classes/appdetails/SteamApp.cs @@ -61,34 +61,34 @@ namespace SteamStorefrontAPI.Classes public string LegalNotice { get; set; } [JsonProperty("developers")] - public List Developers { get; set; } + public List Developers { get; } [JsonProperty("publishers")] - public List Publishers { get; set; } + public List Publishers { get; } [JsonProperty("price_overview")] public PriceOverview PriceOverview { get; set; } [JsonProperty("packages")] - public List Packages { get; set; } + public List Packages { get; } [JsonProperty("package_groups")] - public List PackageGroups { get; set; } + public List PackageGroups { get; } [JsonProperty("platforms")] public Platforms Platforms { get; set; } [JsonProperty("categories")] - public List Categories { get; set; } + public List Categories { get; } [JsonProperty("genres")] - public List Genres { get; set; } + public List Genres { get; } [JsonProperty("screenshots")] - public List Screenshots { get; set; } + public List Screenshots { get; } [JsonProperty("movies")] - public List Movies { get; set; } + public List Movies { get; } [JsonProperty("recommendations")] public Recommendations Recommendations { get; set; } @@ -110,11 +110,24 @@ namespace SteamStorefrontAPI.Classes public ControllerSupport? ControllerSupport { get; set; } [JsonProperty("dlc")] - public List DLC { get; set; } + public List DLC { get; } [JsonProperty("reviews")] public string Reviews { get; set; } + public SteamApp() + { + this.Developers = new List(); + this.Publishers = new List(); + this.Packages = new List(); + this.PackageGroups = new List(); + this.Categories = new List(); + this.Genres = new List(); + this.Screenshots = new List(); + this.Movies = new List(); + this.DLC = new List(); + } + public static SteamApp FromJson(string json) { var serializerSettings = new JsonSerializerSettings diff --git a/SteamStorefrontAPI/Classes/featured/FeaturedApps.cs b/SteamStorefrontAPI/Classes/featured/FeaturedApps.cs index 7565649..a537829 100644 --- a/SteamStorefrontAPI/Classes/featured/FeaturedApps.cs +++ b/SteamStorefrontAPI/Classes/featured/FeaturedApps.cs @@ -12,16 +12,16 @@ namespace SteamStorefrontAPI.Classes public class FeaturedApps { [JsonProperty("large_capsules")] - public List LargeCapsules { get; set; } + public List LargeCapsules { get; } [JsonProperty("featured_win")] - public List FeaturedWin { get; set; } + public List FeaturedWin { get; } [JsonProperty("featured_mac")] - public List FeaturedMac { get; set; } + public List FeaturedMac { get; } [JsonProperty("featured_linux")] - public List FeaturedLinux { get; set; } + public List FeaturedLinux { get; } [JsonProperty("layout")] public string Layout { get; set; } @@ -29,6 +29,14 @@ namespace SteamStorefrontAPI.Classes //[JsonProperty("status")] //public int Status { get; set; } + public FeaturedApps() + { + this.LargeCapsules = new List(); + this.FeaturedWin = new List(); + this.FeaturedMac = new List(); + this.FeaturedLinux = new List(); + } + public static FeaturedApps FromJson(string json) { diff --git a/SteamStorefrontAPI/Classes/featuredcategories/FeaturedCategory.cs b/SteamStorefrontAPI/Classes/featuredcategories/FeaturedCategory.cs index 422c465..ebf9211 100644 --- a/SteamStorefrontAPI/Classes/featuredcategories/FeaturedCategory.cs +++ b/SteamStorefrontAPI/Classes/featuredcategories/FeaturedCategory.cs @@ -18,7 +18,7 @@ namespace SteamStorefrontAPI.Classes public string Name { get; set; } [JsonProperty("items")] - public List Items { get; set; } + public List Items { get; } [JsonProperty("header_image")] public string HeaderImage { get; set; } @@ -29,6 +29,11 @@ namespace SteamStorefrontAPI.Classes [JsonProperty("url")] public string Url { get; set; } + public FeaturedCategory() + { + this.Items = new List(); + } + public static FeaturedCategory FromJson(string json) { var serializerSettings = new JsonSerializerSettings diff --git a/SteamStorefrontAPI/Classes/packagedetails/PackageInfo.cs b/SteamStorefrontAPI/Classes/packagedetails/PackageInfo.cs index f0e0a15..89c1b55 100644 --- a/SteamStorefrontAPI/Classes/packagedetails/PackageInfo.cs +++ b/SteamStorefrontAPI/Classes/packagedetails/PackageInfo.cs @@ -24,7 +24,7 @@ namespace SteamStorefrontAPI.Classes public string SmallLogo { get; set; } [JsonProperty("apps")] - public List Apps { get; set; } + public List Apps { get; } [JsonProperty("price")] public PriceOverview Price { get; set; } @@ -38,6 +38,12 @@ namespace SteamStorefrontAPI.Classes [JsonProperty("release_date")] public ReleaseDate ReleaseDate { get; set; } + public PackageInfo() + { + this.Apps = new List(); + + } + public static SteamApp FromJson(string json) { diff --git a/SteamStorefrontAPI/Endpoints/FeaturedCategories.cs b/SteamStorefrontAPI/Endpoints/FeaturedCategories.cs index c4c5f51..fa87bb1 100644 --- a/SteamStorefrontAPI/Endpoints/FeaturedCategories.cs +++ b/SteamStorefrontAPI/Endpoints/FeaturedCategories.cs @@ -18,7 +18,7 @@ namespace SteamStorefrontAPI /// /// Retrieves a list of featured items, grouped by category, via an asynchronous operation. - public static async Task> GetAsync() + public static async Task> GetAsync() { return await GetAsync(null, null); } @@ -26,7 +26,7 @@ namespace SteamStorefrontAPI /// /// Retrieves a list of featured items, grouped by category, via an asynchronous operation. /// Two letter country code to customise currency and date values. - public static async Task> GetAsync(string CountryCode) + public static async Task> GetAsync(string CountryCode) { return await GetAsync(CountryCode, null); } @@ -35,7 +35,7 @@ namespace SteamStorefrontAPI /// Retrieves a list of featured items, grouped by category, via an asynchronous operation. /// Two letter country code to customise currency and date values. /// Full name of the language in english used for string localization e.g. name, description. - public static async Task> GetAsync(string CountryCode, string Language) + public static async Task> GetAsync(string CountryCode, string Language) { string steamUri = steamBaseUri; steamUri = string.IsNullOrWhiteSpace(CountryCode) ? steamUri : $"{steamUri}?cc={CountryCode}"; diff --git a/SteamStorefrontConsole/Program.cs b/SteamStorefrontConsole/Program.cs index 2968fb3..13c65cb 100644 --- a/SteamStorefrontConsole/Program.cs +++ b/SteamStorefrontConsole/Program.cs @@ -43,10 +43,10 @@ namespace SteamStorefrontConsole FeaturedApps featured3 = await Featured.GetAsync("DE", "english"); // Get a list of featured games grouped by category - List featuredCategories = await FeaturedCategories.GetAsync(); + List featuredCategories = (await FeaturedCategories.GetAsync()).ToList(); // Get a list of featured games grouped by category for region US - List featuredCategories2 = await FeaturedCategories.GetAsync("DE"); + List featuredCategories2 = (await FeaturedCategories.GetAsync("DE")).ToList(); } } }