diff --git a/src/Steam.Models/Steam.Models.csproj b/src/Steam.Models/Steam.Models.csproj
index 1d041a6..997bf55 100644
--- a/src/Steam.Models/Steam.Models.csproj
+++ b/src/Steam.Models/Steam.Models.csproj
@@ -4,4 +4,8 @@
netstandard2.0;netstandard2.1
+
+
+
+
diff --git a/src/Steam.Models/SteamInventory/AddItemResult.cs b/src/Steam.Models/SteamInventory/AddItemResult.cs
new file mode 100644
index 0000000..dc7a636
--- /dev/null
+++ b/src/Steam.Models/SteamInventory/AddItemResult.cs
@@ -0,0 +1,63 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Steam.Models.SteamInventory
+{
+ public class AddItemResult
+ {
+ public string item_json { get; set; }
+
+ [JsonIgnore]
+ public List Items
+ {
+ get
+ {
+ if (string.IsNullOrEmpty(item_json))
+ return new List();
+ return JsonConvert.DeserializeObject>(item_json);
+ }
+ }
+ }
+
+ public class SteamInventoryItem
+ {
+ [JsonProperty("accountid")]
+ public string AccountId { get; set; }
+
+ [JsonProperty("itemid")]
+ public string ItemId { get; set; }
+
+ [JsonProperty("quantity")]
+ public int Quantity { get; set; }
+
+ [JsonProperty("originalitemid")]
+ public string OriginalItemId { get; set; }
+
+ [JsonProperty("itemdefid")]
+ public string ItemDefId { get; set; }
+
+ [JsonProperty("appid")]
+ public int AppId { get; set; }
+
+ [JsonProperty("acquired")]
+ public string Acquired { get; set; }
+
+ [JsonProperty("state")]
+ public string State { get; set; }
+
+ [JsonProperty("origin")]
+ public string Origin { get; set; }
+
+ [JsonProperty("state_changed_timestamp")]
+ public string StateChangedTimestamp { get; set; }
+
+ [JsonProperty("dynamic_props")]
+ public DynamicProps DynamicProps { get; set; }
+ }
+
+ public class DynamicProps
+ {
+ [JsonProperty("code")]
+ public string Code { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Steam.Models/SteamInventory/AddItemResultModel.cs b/src/Steam.Models/SteamInventory/AddItemResultModel.cs
new file mode 100644
index 0000000..697af0e
--- /dev/null
+++ b/src/Steam.Models/SteamInventory/AddItemResultModel.cs
@@ -0,0 +1,7 @@
+namespace Steam.Models.SteamInventory
+{
+ public class AddItemResultModel
+ {
+ public AddItemResult Response { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/SteamWebAPI2/Interfaces/IInventoryService.cs b/src/SteamWebAPI2/Interfaces/IInventoryService.cs
new file mode 100644
index 0000000..88c7b3e
--- /dev/null
+++ b/src/SteamWebAPI2/Interfaces/IInventoryService.cs
@@ -0,0 +1,14 @@
+using System.Threading.Tasks;
+using Steam.Models.SteamInventory;
+using SteamWebAPI2.Utilities;
+
+namespace SteamWebAPI2.Interfaces
+{
+ public interface IInventoryService
+ {
+ Task> AddItem(ulong steamid, uint appid, int itemdefid, int notify = 0);
+ Task> ModifyItem(ulong steamid, uint appid, ulong itemId, string propertyName, string propertyValue);
+ Task> ConsumeItem(ulong steamid, uint appid, ulong itemId, int quantity);
+ Task> GetInventory(ulong steamid, uint appid, int includeProperties);
+ }
+}
\ No newline at end of file
diff --git a/src/SteamWebAPI2/Interfaces/ISteamUserAuth.cs b/src/SteamWebAPI2/Interfaces/ISteamUserAuth.cs
index 318e733..b03bf8c 100644
--- a/src/SteamWebAPI2/Interfaces/ISteamUserAuth.cs
+++ b/src/SteamWebAPI2/Interfaces/ISteamUserAuth.cs
@@ -12,6 +12,6 @@ public interface ISteamUserAuth
/// App ID of the game to authenticate against
/// Ticket from GetAuthSessionTicket
/// Results of authentication request
- Task> AuthenticateUserTicket(uint appId, string ticket);
+ Task> AuthenticateUserTicket(uint appId, string ticket, string identity = "");
}
}
\ No newline at end of file
diff --git a/src/SteamWebAPI2/Interfaces/InventoryService.cs b/src/SteamWebAPI2/Interfaces/InventoryService.cs
new file mode 100644
index 0000000..95fb7a8
--- /dev/null
+++ b/src/SteamWebAPI2/Interfaces/InventoryService.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using AutoMapper;
+using Steam.Models.SteamInventory;
+using SteamWebAPI2.Utilities;
+
+namespace SteamWebAPI2.Interfaces
+{
+ public class InventoryService : IInventoryService
+ {
+ private readonly IMapper mapper;
+ private ISteamWebInterface steamWebInterface;
+
+ ///
+ /// Default constructor established the Steam Web API key and initializes for subsequent method calls
+ ///
+ ///
+ public InventoryService(IMapper mapper, ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null)
+ {
+ this.mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
+
+ this.steamWebInterface = steamWebInterface == null
+ ? new SteamWebInterface("IInventoryService", steamWebRequest)
+ : steamWebInterface;
+ }
+
+ public async Task> AddItem(ulong steamid, uint appid, int itemdefid, int notify = 0)
+ {
+ List parameters = new List();
+ parameters.AddIfHasValue(appid, "appid");
+ parameters.AddIfHasValue(itemdefid, "itemdefid[0]");
+ parameters.AddIfHasValue(notify, "notify");
+ parameters.AddIfHasValue(steamid, "steamid");
+ var playingSharedGameResult = await steamWebInterface.PostAsync("AddItem", 1, parameters);
+ return playingSharedGameResult;
+ }
+
+ public async Task> ModifyItem(ulong steamid, uint appid, ulong itemId, string propertyName, string propertyValue)
+ {
+ List parameters = new List();
+ string fullJson = "{\"steamid\":\"" + steamid + "\", \"timestamp\":" + DateTimeOffset.UtcNow.ToUnixTimeSeconds() + ", \"updates\":[{\"itemid\":\"" + itemId + "\",\"property_name\":\"" + propertyName + "\",\"property_value_string\":\"" + propertyValue + "\"} ] }";
+ parameters.AddIfHasValue(fullJson, "input_json");
+ parameters.AddIfHasValue(appid, "appid");
+ var playingSharedGameResult = await steamWebInterface.PostAsync("ModifyItems", 1, parameters);
+ return playingSharedGameResult;
+ }
+
+ public async Task> ConsumeItem(ulong steamid, uint appid, ulong itemId, int quantity)
+ {
+ List parameters = new List();
+ parameters.AddIfHasValue(appid, "appid");
+ parameters.AddIfHasValue(steamid, "steamid");
+ parameters.AddIfHasValue(itemId, "itemid");
+ parameters.AddIfHasValue(quantity, "quantity");
+ var playingSharedGameResult = await steamWebInterface.PostAsync("ConsumeItem", 1, parameters);
+ return playingSharedGameResult;
+ }
+
+ public async Task> GetInventory(ulong steamid, uint appid, int includeProperties)
+ {
+ List parameters = new List();
+ parameters.AddIfHasValue(appid, "appid");
+ parameters.AddIfHasValue(steamid, "steamid");
+ parameters.AddIfHasValue(includeProperties, "include_properties");
+ var playingSharedGameResult = await steamWebInterface.GetAsync("GetInventory", 1, parameters);
+ return playingSharedGameResult;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/SteamWebAPI2/Interfaces/SteamUserAuth.cs b/src/SteamWebAPI2/Interfaces/SteamUserAuth.cs
index 24fc75f..f895591 100644
--- a/src/SteamWebAPI2/Interfaces/SteamUserAuth.cs
+++ b/src/SteamWebAPI2/Interfaces/SteamUserAuth.cs
@@ -31,11 +31,12 @@ public SteamUserAuth(IMapper mapper, ISteamWebRequest steamWebRequest, ISteamWeb
/// App ID of the game to authenticate against
/// Ticket from GetAuthSessionTicket
/// Results of authentication request
- public async Task> AuthenticateUserTicket(uint appId, string ticket)
+ public async Task> AuthenticateUserTicket(uint appId, string ticket, string identity = "")
{
List parameters = new List();
parameters.AddIfHasValue(appId, "appid");
parameters.AddIfHasValue(ticket, "ticket");
+ parameters.AddIfHasValue(identity, "identity");
var playingSharedGameResult = await steamWebInterface.GetAsync("AuthenticateUserTicket", 1, parameters);
return playingSharedGameResult;
}
diff --git a/src/SteamWebAPI2/SteamWebAPI2.csproj b/src/SteamWebAPI2/SteamWebAPI2.csproj
index ad4ad18..ebb629e 100644
--- a/src/SteamWebAPI2/SteamWebAPI2.csproj
+++ b/src/SteamWebAPI2/SteamWebAPI2.csproj
@@ -19,7 +19,7 @@
-
+