mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 14:15:47 +03:00
GetMarketPrices
This commit is contained in:
parent
270595a540
commit
54fe75b2bc
@ -100,7 +100,8 @@
|
|||||||
<Compile Include="Server\Inventory.cs" />
|
<Compile Include="Server\Inventory.cs" />
|
||||||
<Compile Include="Server\Server.cs" />
|
<Compile Include="Server\Server.cs" />
|
||||||
<Compile Include="Server\Stats.cs" />
|
<Compile Include="Server\Stats.cs" />
|
||||||
<Compile Include="Web\WebSteamApps.cs" />
|
<Compile Include="Web\ISteamEconomy.cs" />
|
||||||
|
<Compile Include="Web\ISteamApps.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Facepunch.Steamworks\Facepunch.Steamworks.csproj">
|
<ProjectReference Include="..\Facepunch.Steamworks\Facepunch.Steamworks.csproj">
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
namespace Facepunch.Steamworks.Test
|
namespace Facepunch.Steamworks.Test
|
||||||
{
|
{
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public partial class WebSteamApps
|
public partial class ISteamApps
|
||||||
{
|
{
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void Init()
|
public void Init()
|
44
Facepunch.Steamworks.Test/Web/ISteamEconomy.cs
Normal file
44
Facepunch.Steamworks.Test/Web/ISteamEconomy.cs
Normal file
@ -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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,8 @@ namespace Facepunch.SteamApi
|
|||||||
{
|
{
|
||||||
internal class ApiResponse<T>
|
internal class ApiResponse<T>
|
||||||
{
|
{
|
||||||
public T Response { get; set; }
|
public T Response;
|
||||||
|
public T Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class ISteamApps
|
public partial class ISteamApps
|
||||||
@ -17,10 +18,10 @@ public class GetAppBetasResponse
|
|||||||
{
|
{
|
||||||
public class Beta
|
public class Beta
|
||||||
{
|
{
|
||||||
public ulong BuildId { get; set; }
|
public ulong BuildId;
|
||||||
public string Description { get; set; }
|
public string Description;
|
||||||
public bool ReqPassword { get; set; }
|
public bool ReqPassword;
|
||||||
public bool ReqLocalCS { get; set; }
|
public bool ReqLocalCS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, Beta> betas;
|
public Dictionary<string, Beta> betas;
|
||||||
@ -30,17 +31,17 @@ public class GetAppBuildsResponse
|
|||||||
{
|
{
|
||||||
public class Build
|
public class Build
|
||||||
{
|
{
|
||||||
public ulong BuildId { get; set; }
|
public ulong BuildId;
|
||||||
public string Description { get; set; }
|
public string Description;
|
||||||
public uint CreationTime { get; set; }
|
public uint CreationTime;
|
||||||
public ulong AccountIDCreator { get; set; }
|
public ulong AccountIDCreator;
|
||||||
|
|
||||||
public class Depot
|
public class Depot
|
||||||
{
|
{
|
||||||
public ulong DepotId { get; set; }
|
public ulong DepotId;
|
||||||
public ulong DepotVersionGID { get; set; }
|
public ulong DepotVersionGID;
|
||||||
public ulong TotalOriginalBytes { get; set; }
|
public ulong TotalOriginalBytes;
|
||||||
public ulong TotalCompressedBytes { get; set; }
|
public ulong TotalCompressedBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, Depot> depots;
|
public Dictionary<string, Depot> depots;
|
||||||
@ -50,5 +51,35 @@ public class Depot
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,17 @@ public static T WebGet<T>( string url )
|
|||||||
{
|
{
|
||||||
var www = new System.Net.WebClient();
|
var www = new System.Net.WebClient();
|
||||||
var data = www.DownloadString( url );
|
var data = www.DownloadString( url );
|
||||||
|
www.Dispose();
|
||||||
|
|
||||||
if ( typeof( T ) == typeof( string ) )
|
if ( typeof( T ) == typeof( string ) )
|
||||||
return (T)(object)data;
|
return (T)(object)data;
|
||||||
|
|
||||||
var response = DeserializeJson<ApiResponse<T>>( data );
|
var response = DeserializeJson<ApiResponse<T>>( data );
|
||||||
|
|
||||||
www.Dispose();
|
|
||||||
|
|
||||||
|
if ( response.Response == null )
|
||||||
|
return response.Result;
|
||||||
|
|
||||||
return response.Response;
|
return response.Response;
|
||||||
}
|
}
|
||||||
|
@ -282,10 +282,10 @@ public static string GetExportedAssetsForUser(ulong steamid, uint appid, ulong c
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <param name="appid">Must be a steam economy app.</param>
|
/// <param name="appid">Must be a steam economy app.</param>
|
||||||
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}";
|
string url = $"{Url}GetMarketPrices/v0001/?key={Facepunch.SteamApi.Config.Key}&format=json&appid={appid}";
|
||||||
return Utility.WebGet<string>( url );
|
return Utility.WebGet<GetMarketPricesResponse>( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <param name="appid">The app ID the user is buying assets for</param>
|
/// <param name="appid">The app ID the user is buying assets for</param>
|
||||||
|
@ -12,6 +12,8 @@ public partial class CodeWriter
|
|||||||
{
|
{
|
||||||
"ISteamApps.GetAppBetas",
|
"ISteamApps.GetAppBetas",
|
||||||
"ISteamApps.GetAppBuilds",
|
"ISteamApps.GetAppBuilds",
|
||||||
|
|
||||||
|
"ISteamEconomy.GetMarketPrices"
|
||||||
};
|
};
|
||||||
|
|
||||||
private void WebApi()
|
private void WebApi()
|
||||||
|
Loading…
Reference in New Issue
Block a user