diff --git a/src/SteamWebAPI2/AutoMapperConfiguration.cs b/src/SteamWebAPI2/AutoMapperConfiguration.cs index a4e9a7c..27b298d 100644 --- a/src/SteamWebAPI2/AutoMapperConfiguration.cs +++ b/src/SteamWebAPI2/AutoMapperConfiguration.cs @@ -87,7 +87,6 @@ public static void Initialize() CreateSteamWebResponseMap>(x); CreateSteamWebResponseMap>(x); CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); CreateSteamWebResponseMap(x); CreateSteamWebResponseMap(x); CreateSteamWebResponseMap(x); @@ -139,7 +138,6 @@ public static void Initialize() x.CreateMap().ConvertUsing(src => src.Result != null ? src.Result.Path : null); - x.CreateMap(); x.CreateMap(); x.CreateMap(); x.CreateMap(); @@ -159,9 +157,6 @@ public static void Initialize() x.CreateMap(); x.CreateMap(); x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); // TODO: Rework the way Schema models are used for different games (TF2 / DOTA2) //x.CreateMap() diff --git a/src/SteamWebAPI2/Interfaces/EconItems.cs b/src/SteamWebAPI2/Interfaces/EconItems.cs index 413dd07..8edec42 100644 --- a/src/SteamWebAPI2/Interfaces/EconItems.cs +++ b/src/SteamWebAPI2/Interfaces/EconItems.cs @@ -86,34 +86,32 @@ public async Task> GetPlayerItemsAsync(ul } /// - /// Returns the economy / item schema for a specific App ID. + /// Returns the item schema for TF2 specifically. /// /// /// - public async Task> GetSchemaAsync(string language = "en_us") + public async Task> GetSchemaItemsForTF2Async(string language = "en_us") { - if (!validSchemaAppIds.Contains(appId)) + if (this.appId != (int)EconItemsAppId.TeamFortress2) { - throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetSchema method.", appId)); + throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetSchemaTF2 method.", appId)); } List parameters = new List(); parameters.AddIfHasValue(language, "language"); - var steamWebResponse = await steamWebInterface.GetAsync("GetSchema", 1, parameters); + var steamWebResponse = await steamWebInterface.GetAsync("GetSchemaItems", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse; } - /// - /// Returns the economy / item schema for TF2 specifically. + /// + /// Returns the schema overview for TF2 specifically. /// /// /// - public async Task> GetSchemaForTF2Async(string language = "en_us") + public async Task> GetSchemaOverviewForTF2Async(string language = "en_us") { if (this.appId != (int)EconItemsAppId.TeamFortress2) { @@ -124,11 +122,9 @@ public async Task> GetPlayerItemsAsync(ul parameters.AddIfHasValue(language, "language"); - var steamWebResponse = await steamWebInterface.GetAsync("GetSchema", 1, parameters); - - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); + var steamWebResponse = await steamWebInterface.GetAsync("GetSchemaOverview", 1, parameters); - return steamWebResponseModel; + return steamWebResponse; } /// diff --git a/src/SteamWebAPI2/Interfaces/IEconItems.cs b/src/SteamWebAPI2/Interfaces/IEconItems.cs index c063be0..88c1861 100644 --- a/src/SteamWebAPI2/Interfaces/IEconItems.cs +++ b/src/SteamWebAPI2/Interfaces/IEconItems.cs @@ -9,9 +9,9 @@ public interface IEconItems { Task> GetPlayerItemsAsync(ulong steamId); - Task> GetSchemaAsync(string language = "en_us"); + Task> GetSchemaItemsForTF2Async(string language = "en_us"); - Task> GetSchemaForTF2Async(string language = "en_us"); + Task> GetSchemaOverviewForTF2Async(string language = "en_us"); Task> GetSchemaUrlAsync(); diff --git a/src/SteamWebAPI2/Models/GameEconomy/SchemaItemResultContainer.cs b/src/SteamWebAPI2/Models/GameEconomy/SchemaItemResultContainer.cs new file mode 100644 index 0000000..bd1bb66 --- /dev/null +++ b/src/SteamWebAPI2/Models/GameEconomy/SchemaItemResultContainer.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace SteamWebAPI2.Models.GameEconomy +{ + public class SchemaItemsResult + { + [JsonProperty("status")] + public uint Status { get; set; } + [JsonProperty("items_game_url")] + public string ItemsGameUrl { get; set; } + [JsonProperty("items")] + public IList Items { get; set; } + [JsonProperty("next")] + public uint Next { get; set; } + } + + public class SchemaItemsResultContainer + { + [JsonProperty("result")] + public SchemaItemsResult Result { get; set; } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/GameEconomy/SchemaOverviewResultContainer.cs b/src/SteamWebAPI2/Models/GameEconomy/SchemaOverviewResultContainer.cs new file mode 100644 index 0000000..1105c9f --- /dev/null +++ b/src/SteamWebAPI2/Models/GameEconomy/SchemaOverviewResultContainer.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace SteamWebAPI2.Models.GameEconomy +{ + public class SchemaOverviewResult + { + [JsonProperty("status")] + public uint Status { get; set; } + [JsonProperty("items_game_url")] + public string ItemsGameUrl { get; set; } + [JsonProperty("qualities")] + public SchemaQualities Qualities { get; set; } + [JsonProperty("originNames")] + public IList OriginNames { get; set; } + [JsonProperty("attributes")] + public IList Attributes { get; set; } + [JsonProperty("item_sets")] + public IList ItemSets { get; set; } + [JsonProperty("attribute_controlled_attached_particles")] + public IList AttributeControlledAttachedParticles { get; set; } + [JsonProperty("item_levels")] + public IList ItemLevels { get; set; } + [JsonProperty("kill_eater_score_types")] + public IList KillEaterScoreTypes { get; set; } + [JsonProperty("string_lookups")] + public IList StringLookups { get; set; } + } + + public class SchemaOverviewResultContainer + { + [JsonProperty("result")] + public SchemaOverviewResult Result { get; set; } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/GameEconomy/SchemaResultContainer.cs b/src/SteamWebAPI2/Models/GameEconomy/SchemaResultContainer.cs index 09635b2..e89e0c1 100644 --- a/src/SteamWebAPI2/Models/GameEconomy/SchemaResultContainer.cs +++ b/src/SteamWebAPI2/Models/GameEconomy/SchemaResultContainer.cs @@ -3,7 +3,7 @@ namespace SteamWebAPI2.Models.GameEconomy { - internal class SchemaQualities + public class SchemaQualities { /// /// Normal item rarity: https://wiki.teamfortress.com/wiki/Normal @@ -99,7 +99,7 @@ internal class SchemaQualities public uint PaintKitWeapon { get; set; } } - internal class SchemaOriginName + public class SchemaOriginName { [JsonProperty("origin")] public uint Origin { get; set; } @@ -108,7 +108,7 @@ internal class SchemaOriginName public string Name { get; set; } } - internal class SchemaCapabilities + public class SchemaCapabilities { [JsonProperty("nameable")] public bool Nameable { get; set; } @@ -171,7 +171,7 @@ internal class SchemaCapabilities public bool? Decodable { get; set; } } - internal class SchemaAdditionalHiddenBodygroups + public class SchemaAdditionalHiddenBodygroups { [JsonProperty("hat")] public uint Hat { get; set; } @@ -183,7 +183,7 @@ internal class SchemaAdditionalHiddenBodygroups public uint? Head { get; set; } } - internal class SchemaStyle + public class SchemaStyle { [JsonProperty("name")] public string Name { get; set; } @@ -192,7 +192,7 @@ internal class SchemaStyle public SchemaAdditionalHiddenBodygroups AdditionalHiddenBodygroups { get; set; } } - internal class SchemaItemAttribute + public class SchemaItemAttribute { [JsonProperty("name")] public string Name { get; set; } @@ -204,7 +204,7 @@ internal class SchemaItemAttribute public double Value { get; set; } } - internal class SchemaPerClassLoadoutSlots + public class SchemaPerClassLoadoutSlots { [JsonProperty("Soldier")] public string Soldier { get; set; } @@ -222,7 +222,7 @@ internal class SchemaPerClassLoadoutSlots public string Demoman { get; set; } } - internal class SchemaUsageCapabilities + public class SchemaUsageCapabilities { [JsonProperty("nameable")] public bool Nameable { get; set; } @@ -264,7 +264,7 @@ internal class SchemaUsageCapabilities public bool? CanConsume { get; set; } } - internal class SchemaTool + public class SchemaTool { [JsonProperty("type")] public string Type { get; set; } @@ -279,7 +279,7 @@ internal class SchemaTool public string Restriction { get; set; } } - internal class SchemaItem + public class SchemaItem { [JsonProperty("defindex")] public uint DefIndex { get; set; } @@ -363,7 +363,7 @@ internal class SchemaItem public SchemaTool Tool { get; set; } } - internal class SchemaAttribute + public class SchemaAttribute { [JsonProperty("name")] public string Name { get; set; } @@ -390,7 +390,7 @@ internal class SchemaAttribute public bool StoredAsInteger { get; set; } } - internal class SchemaItemSetAttribute + public class SchemaItemSetAttribute { [JsonProperty("name")] public string Name { get; set; } @@ -402,7 +402,7 @@ internal class SchemaItemSetAttribute public double Value { get; set; } } - internal class SchemaItemSet + public class SchemaItemSet { [JsonProperty("item_set")] public string ItemSet { get; set; } @@ -420,7 +420,7 @@ internal class SchemaItemSet public string StoreBundleName { get; set; } } - internal class SchemaAttributeControlledAttachedParticle + public class SchemaAttributeControlledAttachedParticle { [JsonProperty("system")] public string System { get; set; } @@ -438,7 +438,7 @@ internal class SchemaAttributeControlledAttachedParticle public string Attachment { get; set; } } - internal class SchemaLevel + public class SchemaLevel { [JsonProperty("level")] public uint Level { get; set; } @@ -450,7 +450,7 @@ internal class SchemaLevel public string Name { get; set; } } - internal class SchemaItemLevel + public class SchemaItemLevel { [JsonProperty("name")] public string Name { get; set; } @@ -459,7 +459,7 @@ internal class SchemaItemLevel public IList Levels { get; set; } } - internal class SchemaKillEaterScoreType + public class SchemaKillEaterScoreType { [JsonProperty("type")] public uint Type { get; set; } @@ -471,7 +471,7 @@ internal class SchemaKillEaterScoreType public string LevelData { get; set; } } - internal class SchemaString + public class SchemaString { [JsonProperty("index")] public uint Index { get; set; } @@ -480,7 +480,7 @@ internal class SchemaString public string String { get; set; } } - internal class SchemaStringLookup + public class SchemaStringLookup { [JsonProperty("table_name")] public string TableName { get; set; } @@ -488,46 +488,4 @@ internal class SchemaStringLookup [JsonProperty("strings")] public IList Strings { get; set; } } - - internal class SchemaResult - { - [JsonProperty("status")] - public uint Status { get; set; } - - [JsonProperty("items_game_url")] - public string ItemsGameUrl { get; set; } - - [JsonProperty("qualities")] - public SchemaQualities Qualities { get; set; } - - [JsonProperty("originNames")] - public IList OriginNames { get; set; } - - [JsonProperty("items")] - public IList Items { get; set; } - - [JsonProperty("attributes")] - public IList Attributes { get; set; } - - [JsonProperty("item_sets")] - public IList ItemSets { get; set; } - - [JsonProperty("attribute_controlled_attached_particles")] - public IList AttributeControlledAttachedParticles { get; set; } - - [JsonProperty("item_levels")] - public IList ItemLevels { get; set; } - - [JsonProperty("kill_eater_score_types")] - public IList KillEaterScoreTypes { get; set; } - - [JsonProperty("string_lookups")] - public IList StringLookups { get; set; } - } - - internal class SchemaResultContainer - { - [JsonProperty("result")] - public SchemaResult Result { get; set; } - } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Utilities/SteamWebInterfaceFactory.cs b/src/SteamWebAPI2/Utilities/SteamWebInterfaceFactory.cs index 75e85c9..4820f7e 100644 --- a/src/SteamWebAPI2/Utilities/SteamWebInterfaceFactory.cs +++ b/src/SteamWebAPI2/Utilities/SteamWebInterfaceFactory.cs @@ -41,6 +41,18 @@ public T CreateSteamWebInterface(HttpClient httpClient) return (T)Activator.CreateInstance(typeof(T), steamWebRequest, null); } + /// + /// Creates a web interface object connected to a specific Steam Web API interfac endpoint + /// + /// Custom http client injected with your customization (if necessary) + /// Type of the web interface to create + /// Instance of the web interface + public T CreateSteamWebInterface(HttpClient httpClient, EconItemsAppId appId) + { + var steamWebRequest = CreateSteamWebRequest(httpClient); + return (T)Activator.CreateInstance(typeof(T), steamWebRequest, appId, null); + } + private ISteamWebRequest CreateSteamWebRequest(HttpClient httpClient) { SteamWebHttpClient steamWebHttpClient = new SteamWebHttpClient(httpClient);