diff --git a/Facepunch.Steamworks.Test/Facepunch.Steamworks.Test.csproj b/Facepunch.Steamworks.Test/Facepunch.Steamworks.Test.csproj
index 4901f2e..f0f5550 100644
--- a/Facepunch.Steamworks.Test/Facepunch.Steamworks.Test.csproj
+++ b/Facepunch.Steamworks.Test/Facepunch.Steamworks.Test.csproj
@@ -100,7 +100,8 @@
-
+
+
diff --git a/Facepunch.Steamworks.Test/Web/WebSteamApps.cs b/Facepunch.Steamworks.Test/Web/ISteamApps.cs
similarity index 98%
rename from Facepunch.Steamworks.Test/Web/WebSteamApps.cs
rename to Facepunch.Steamworks.Test/Web/ISteamApps.cs
index 73c43c3..df9d7db 100644
--- a/Facepunch.Steamworks.Test/Web/WebSteamApps.cs
+++ b/Facepunch.Steamworks.Test/Web/ISteamApps.cs
@@ -7,7 +7,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Facepunch.Steamworks.Test
{
[TestClass]
- public partial class WebSteamApps
+ public partial class ISteamApps
{
[TestInitialize]
public void Init()
diff --git a/Facepunch.Steamworks.Test/Web/ISteamEconomy.cs b/Facepunch.Steamworks.Test/Web/ISteamEconomy.cs
new file mode 100644
index 0000000..a4799b6
--- /dev/null
+++ b/Facepunch.Steamworks.Test/Web/ISteamEconomy.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Facepunch.Steamworks.Test
+{
+ [TestClass]
+ public partial class ISteamEconomy
+ {
+ [TestInitialize]
+ public void Init()
+ {
+ //
+ // For the sake of tests, we store our Key in an environment variable
+ // (so we don't end up shipping it to github and exposing it to everyone)
+ //
+ Facepunch.SteamApi.Config.Key = Environment.GetEnvironmentVariable( "SteamWebApi", EnvironmentVariableTarget.User );
+
+ //
+ // We're going to be using Newtonsoft to deserialize our json
+ //
+ Facepunch.SteamApi.Config.DeserializeJson = ( str, type ) =>
+ {
+ return Newtonsoft.Json.JsonConvert.DeserializeObject( str, type );
+ };
+ }
+
+ [TestMethod]
+ public void GetMarketPrices()
+ {
+ var response = Facepunch.SteamApi.ISteamEconomy.GetMarketPrices( 252490 );
+
+ var items = response.groups.OrderByDescending( x => x.sell_listings );
+
+ foreach ( var i in items )
+ {
+ Console.WriteLine( i.sell_listings + " " + i.name );
+ }
+ }
+
+ }
+}
diff --git a/Facepunch.Steamworks/SteamNative/SteamApi.Response.cs b/Facepunch.Steamworks/SteamNative/SteamApi.Response.cs
index 397c3bf..8b7c98b 100644
--- a/Facepunch.Steamworks/SteamNative/SteamApi.Response.cs
+++ b/Facepunch.Steamworks/SteamNative/SteamApi.Response.cs
@@ -8,7 +8,8 @@ namespace Facepunch.SteamApi
{
internal class ApiResponse
{
- public T Response { get; set; }
+ public T Response;
+ public T Result;
}
public partial class ISteamApps
@@ -17,10 +18,10 @@ namespace Facepunch.SteamApi
{
public class Beta
{
- public ulong BuildId { get; set; }
- public string Description { get; set; }
- public bool ReqPassword { get; set; }
- public bool ReqLocalCS { get; set; }
+ public ulong BuildId;
+ public string Description;
+ public bool ReqPassword;
+ public bool ReqLocalCS;
}
public Dictionary betas;
@@ -30,17 +31,17 @@ namespace Facepunch.SteamApi
{
public class Build
{
- public ulong BuildId { get; set; }
- public string Description { get; set; }
- public uint CreationTime { get; set; }
- public ulong AccountIDCreator { get; set; }
+ public ulong BuildId;
+ public string Description;
+ public uint CreationTime;
+ public ulong AccountIDCreator;
public class Depot
{
- public ulong DepotId { get; set; }
- public ulong DepotVersionGID { get; set; }
- public ulong TotalOriginalBytes { get; set; }
- public ulong TotalCompressedBytes { get; set; }
+ public ulong DepotId;
+ public ulong DepotVersionGID;
+ public ulong TotalOriginalBytes;
+ public ulong TotalCompressedBytes;
}
public Dictionary depots;
@@ -50,5 +51,35 @@ namespace Facepunch.SteamApi
}
}
+ public partial class ISteamEconomy
+ {
+ public class GetMarketPricesResponse
+ {
+ public int total_count;
+ public int start;
+ public int count;
+
+ public class Group
+ {
+ public string name;
+ public string icon_url;
+ public ulong sell_listings;
+ public ulong buy_listings;
+ public ulong listed_property_def_index;
+
+ public class Currency
+ {
+ public int ECurrencyCode;
+ public string currency;
+ public double sell_price;
+ }
+
+ public Currency[] currencies;
+ }
+
+ public Group[] groups;
+ }
+ }
+
}
diff --git a/Facepunch.Steamworks/SteamNative/SteamApi.Utility.cs b/Facepunch.Steamworks/SteamNative/SteamApi.Utility.cs
index 87c31be..25f764b 100644
--- a/Facepunch.Steamworks/SteamNative/SteamApi.Utility.cs
+++ b/Facepunch.Steamworks/SteamNative/SteamApi.Utility.cs
@@ -12,13 +12,17 @@ namespace Facepunch.SteamApi
{
var www = new System.Net.WebClient();
var data = www.DownloadString( url );
+ www.Dispose();
if ( typeof( T ) == typeof( string ) )
return (T)(object)data;
var response = DeserializeJson>( data );
- www.Dispose();
+
+
+ if ( response.Response == null )
+ return response.Result;
return response.Response;
}
diff --git a/Facepunch.Steamworks/SteamNative/SteamApi.cs b/Facepunch.Steamworks/SteamNative/SteamApi.cs
index f5fee24..50269b1 100644
--- a/Facepunch.Steamworks/SteamNative/SteamApi.cs
+++ b/Facepunch.Steamworks/SteamNative/SteamApi.cs
@@ -282,10 +282,10 @@ namespace Facepunch.SteamApi
}
/// Must be a steam economy app.
- public static string GetMarketPrices(uint appid)
+ public static GetMarketPricesResponse GetMarketPrices(uint appid)
{
string url = $"{Url}GetMarketPrices/v0001/?key={Facepunch.SteamApi.Config.Key}&format=json&appid={appid}";
- return Utility.WebGet( url );
+ return Utility.WebGet( url );
}
/// The app ID the user is buying assets for
diff --git a/Generator/CodeWriter/WebApi.cs b/Generator/CodeWriter/WebApi.cs
index 853aeef..6f5ca77 100644
--- a/Generator/CodeWriter/WebApi.cs
+++ b/Generator/CodeWriter/WebApi.cs
@@ -12,6 +12,8 @@ namespace Generator
{
"ISteamApps.GetAppBetas",
"ISteamApps.GetAppBuilds",
+
+ "ISteamEconomy.GetMarketPrices"
};
private void WebApi()