Skip to content

Commit 0b9e812

Browse files
author
babelshift
committed
Added wrapper for GetStoreStatus method.
1 parent 21c8727 commit 0b9e812

3 files changed

Lines changed: 55 additions & 3 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Generated by Xamasoft JSON Class Generator
2+
// http://www.xamasoft.com/json-class-generator
3+
4+
using Newtonsoft.Json;
5+
6+
namespace SteamWebAPI2.Models.Economy
7+
{
8+
public class StoreStatusResult
9+
{
10+
[JsonProperty("status")]
11+
public int Status { get; set; }
12+
13+
[JsonProperty("store_status")]
14+
public int StoreStatus { get; set; }
15+
}
16+
17+
public class StoreStatusResultContainer
18+
{
19+
[JsonProperty("result")]
20+
public StoreStatusResult Result { get; set; }
21+
}
22+
}

SteamWebAPI2.Models/SteamWebAPI2.Models.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
<Compile Include="Economy\SchemaResultContainer.cs" />
110110
<Compile Include="Economy\SchemaURLResultContainer.cs" />
111111
<Compile Include="Economy\StoreMetaDataResultContainer.cs" />
112+
<Compile Include="Economy\StoreStatusResultContainer.cs" />
112113
<Compile Include="FeedData.cs" />
113114
<Compile Include="Friend.cs" />
114115
<Compile Include="GameSchema.cs" />

SteamWebAPI2/EconItems.cs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public class EconItems : SteamWebInterface
1111
{
1212
private int appId;
1313

14+
// The API only exposes certain methods for certain App Ids in the EconItems interface
15+
// I'm hard coding the values for now until I come up with a better, more dynamic solution
1416
private List<int> validSchemaAppIds = new List<int>();
1517
private List<int> validSchemaUrlAppIds = new List<int>();
1618
private List<int> validStoreMetaDataAppIds = new List<int>();
@@ -38,6 +40,7 @@ public EconItems(string steamWebApiKey, int appId)
3840

3941
validStoreMetaDataAppIds.Add(440);
4042
validStoreMetaDataAppIds.Add(570);
43+
validSchemaUrlAppIds.Add(730);
4144

4245
validStoreStatusAppIds.Add(440);
4346
}
@@ -67,15 +70,41 @@ public async Task<SchemaResult> GetSchemaAsync(string language = "")
6770
return schemaResult.Result;
6871
}
6972

70-
public async Task<SchemaUrlResult> GetSchemaUrlAsync(string language = "")
73+
public async Task<SchemaUrlResult> GetSchemaUrlAsync()
7174
{
7275
if (!validSchemaUrlAppIds.Contains(appId))
7376
{
7477
throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetSchemaUrl method.", appId));
7578
}
7679

77-
var schemaResult = await CallMethodAsync<SchemaUrlResultContainer>("GetSchemaURL", 1);
78-
return schemaResult.Result;
80+
var schemaUrlResult = await CallMethodAsync<SchemaUrlResultContainer>("GetSchemaURL", 1);
81+
return schemaUrlResult.Result;
82+
}
83+
84+
public async Task<StoreMetaDataResult> GetStoreMetaDataAsync(string language = "")
85+
{
86+
if (!validStoreMetaDataAppIds.Contains(appId))
87+
{
88+
throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetStoreMetaData method.", appId));
89+
}
90+
91+
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
92+
93+
AddToParametersIfHasValue("language", language, parameters);
94+
95+
var storeMetaDataResult = await CallMethodAsync<StoreMetaDataResultContainer>("GetStoreMetaData", 1);
96+
return storeMetaDataResult.Result;
97+
}
98+
99+
public async Task<StoreStatusResult> GetStoreStatusAsync()
100+
{
101+
if (!validStoreStatusAppIds.Contains(appId))
102+
{
103+
throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetStoreStatus method.", appId));
104+
}
105+
106+
var storeStatusResult = await CallMethodAsync<StoreStatusResultContainer>("GetStoreStatus", 1);
107+
return storeStatusResult.Result;
79108
}
80109
}
81110
}

0 commit comments

Comments
 (0)