Skip to content

Commit a60e0aa

Browse files
author
Justin Skiles
authored
Merged enums (#97)
* Starting to fix and update the EconService methods around trades * Added finishing touches to EconService endpoints. * Fixed wrong parameter name * Merged all AppId enums into one
1 parent c5d3edb commit a60e0aa

File tree

9 files changed

+53
-83
lines changed

9 files changed

+53
-83
lines changed

src/Steam.UnitTests/EconItemsTeamFortress2Tests.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
using Microsoft.Extensions.Configuration;
2-
using SteamWebAPI2.Interfaces;
3-
using SteamWebAPI2.Utilities;
4-
using System;
5-
using System.Collections.Generic;
1+
using SteamWebAPI2.Interfaces;
62
using System.Net.Http;
7-
using System.Text;
83
using System.Threading.Tasks;
94
using Xunit;
105

@@ -17,7 +12,7 @@ public class EconItemsTeamFortress2Tests : BaseTest
1712
public EconItemsTeamFortress2Tests()
1813
{
1914
steamInterface = factory.CreateSteamWebInterface<EconItems>(
20-
EconItemsAppId.TeamFortress2,
15+
AppId.TeamFortress2,
2116
new HttpClient()
2217
);
2318
}

src/Steam.UnitTests/GCVersionTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ public GCVersionTests()
2323
HttpClient httpClient = new HttpClient();
2424

2525
steamInterfaceTeamFortress2 = factory.CreateSteamWebInterface<GCVersion>(
26-
GCVersionAppId.TeamFortress2,
26+
AppId.TeamFortress2,
2727
httpClient
2828
);
2929

3030
steamInterfaceCounterStrikeGO= factory.CreateSteamWebInterface<GCVersion>(
31-
GCVersionAppId.CounterStrikeGO,
31+
AppId.CounterStrikeGO,
3232
httpClient
3333
);
3434

3535
steamInterfaceDota2 = factory.CreateSteamWebInterface<GCVersion>(
36-
GCVersionAppId.Dota2,
36+
AppId.Dota2,
3737
httpClient
3838
);
3939

4040
steamInterfaceArtifact = factory.CreateSteamWebInterface<GCVersion>(
41-
GCVersionAppId.Artifact,
41+
AppId.Artifact,
4242
httpClient
4343
);
4444

4545
steamInterfaceDotaUnderlords = factory.CreateSteamWebInterface<GCVersion>(
46-
GCVersionAppId.DotaUnderlords,
46+
AppId.DotaUnderlords,
4747
httpClient
4848
);
4949
}

src/Steam.UnitTests/SteamWebInterfaceFactoryTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void Create_DOTA2Ticket_Interface_Should_Succeed()
6767
[Fact]
6868
public void Create_EconItems_Interface_Should_Succeed()
6969
{
70-
var steamInterface = factory.CreateSteamWebInterface<EconItems>(EconItemsAppId.TeamFortress2);
70+
var steamInterface = factory.CreateSteamWebInterface<EconItems>(AppId.TeamFortress2);
7171
Assert.NotNull(steamInterface);
7272
}
7373

@@ -88,7 +88,7 @@ public void Create_GameServersService_Interface_Should_Succeed()
8888
[Fact]
8989
public void Create_GCVersion_Interface_Should_Succeed()
9090
{
91-
var steamInterface = factory.CreateSteamWebInterface<GCVersion>(GCVersionAppId.TeamFortress2);
91+
var steamInterface = factory.CreateSteamWebInterface<GCVersion>(AppId.TeamFortress2);
9292
Assert.NotNull(steamInterface);
9393
}
9494

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace SteamWebAPI2.Interfaces
2+
{
3+
public enum AppId
4+
{
5+
TeamFortress2 = 440,
6+
Dota2 = 570,
7+
Payday2 = 218620,
8+
DefenseGrid2 = 221540,
9+
BattleBlockTheater = 238460,
10+
Portal2 = 620,
11+
CounterStrikeGO = 730,
12+
Portal2_Beta = 841,
13+
Artifact = 583950,
14+
DotaUnderlords = 1046930
15+
}
16+
}

src/SteamWebAPI2/Interfaces/EconItems.cs

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77

88
namespace SteamWebAPI2.Interfaces
99
{
10-
public enum EconItemsAppId
11-
{
12-
TeamFortress2 = 440,
13-
Dota2 = 570,
14-
Payday2 = 218620,
15-
DefenseGrid2 = 221540,
16-
BattleBlockTheater = 238460,
17-
Portal2 = 620,
18-
CounterStrikeGO = 730,
19-
Portal2_Beta = 841
20-
}
21-
2210
public class EconItems : IEconItems
2311
{
2412
private uint appId;
@@ -36,7 +24,7 @@ public class EconItems : IEconItems
3624
/// Default constructor established the Steam Web API key and initializes for subsequent method calls
3725
/// </summary>
3826
/// <param name="steamWebRequest"></param>
39-
public EconItems(ISteamWebRequest steamWebRequest, EconItemsAppId appId, ISteamWebInterface steamWebInterface = null)
27+
public EconItems(ISteamWebRequest steamWebRequest, AppId appId, ISteamWebInterface steamWebInterface = null)
4028
{
4129
if (appId <= 0)
4230
{
@@ -49,21 +37,21 @@ public EconItems(ISteamWebRequest steamWebRequest, EconItemsAppId appId, ISteamW
4937

5038
this.appId = (uint)appId;
5139

52-
validSchemaAppIds.Add((uint)EconItemsAppId.TeamFortress2);
53-
validSchemaAppIds.Add((uint)EconItemsAppId.Dota2);
54-
validSchemaAppIds.Add((uint)EconItemsAppId.Portal2);
55-
validSchemaAppIds.Add((uint)EconItemsAppId.Portal2_Beta);
56-
validSchemaAppIds.Add((uint)EconItemsAppId.CounterStrikeGO);
40+
validSchemaAppIds.Add((uint)AppId.TeamFortress2);
41+
validSchemaAppIds.Add((uint)AppId.Dota2);
42+
validSchemaAppIds.Add((uint)AppId.Portal2);
43+
validSchemaAppIds.Add((uint)AppId.Portal2_Beta);
44+
validSchemaAppIds.Add((uint)AppId.CounterStrikeGO);
5745

58-
validSchemaUrlAppIds.Add((uint)EconItemsAppId.TeamFortress2);
59-
validSchemaUrlAppIds.Add((uint)EconItemsAppId.Dota2);
60-
validSchemaUrlAppIds.Add((uint)EconItemsAppId.CounterStrikeGO);
46+
validSchemaUrlAppIds.Add((uint)AppId.TeamFortress2);
47+
validSchemaUrlAppIds.Add((uint)AppId.Dota2);
48+
validSchemaUrlAppIds.Add((uint)AppId.CounterStrikeGO);
6149

62-
validStoreMetaDataAppIds.Add((uint)EconItemsAppId.TeamFortress2);
63-
validStoreMetaDataAppIds.Add((uint)EconItemsAppId.Dota2);
64-
validStoreMetaDataAppIds.Add((uint)EconItemsAppId.CounterStrikeGO);
50+
validStoreMetaDataAppIds.Add((uint)AppId.TeamFortress2);
51+
validStoreMetaDataAppIds.Add((uint)AppId.Dota2);
52+
validStoreMetaDataAppIds.Add((uint)AppId.CounterStrikeGO);
6553

66-
validStoreStatusAppIds.Add((uint)EconItemsAppId.TeamFortress2);
54+
validStoreStatusAppIds.Add((uint)AppId.TeamFortress2);
6755
}
6856

6957
/// <summary>
@@ -91,7 +79,7 @@ public async Task<ISteamWebResponse<EconItemResultModel>> GetPlayerItemsAsync(ul
9179
/// <returns></returns>
9280
public async Task<ISteamWebResponse<SchemaItemsResultContainer>> GetSchemaItemsForTF2Async(string language = "en_us")
9381
{
94-
if (appId != (int)EconItemsAppId.TeamFortress2)
82+
if (appId != (int)AppId.TeamFortress2)
9583
{
9684
throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetSchemaTF2 method.", appId));
9785
}
@@ -112,7 +100,7 @@ public async Task<ISteamWebResponse<SchemaItemsResultContainer>> GetSchemaItemsF
112100
/// <returns></returns>
113101
public async Task<ISteamWebResponse<SchemaOverviewResultContainer>> GetSchemaOverviewForTF2Async(string language = "en_us")
114102
{
115-
if (appId != (int)EconItemsAppId.TeamFortress2)
103+
if (appId != (int)AppId.TeamFortress2)
116104
{
117105
throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetSchemaTF2 method.", appId));
118106
}

src/SteamWebAPI2/Interfaces/GCVersion.cs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@
77

88
namespace SteamWebAPI2.Interfaces
99
{
10-
public enum GCVersionAppId
11-
{
12-
TeamFortress2 = 440,
13-
Dota2 = 570,
14-
CounterStrikeGO = 730,
15-
Artifact = 583950,
16-
DotaUnderlords = 1046930
17-
}
18-
1910
public class GCVersion : IGCVersion
2011
{
2112
private uint appId;
@@ -32,7 +23,7 @@ public class GCVersion : IGCVersion
3223
/// Default constructor established the Steam Web API key and initializes for subsequent method calls
3324
/// </summary>
3425
/// <param name="steamWebRequest"></param>
35-
public GCVersion(ISteamWebRequest steamWebRequest, GCVersionAppId appId, ISteamWebInterface steamWebInterface = null)
26+
public GCVersion(ISteamWebRequest steamWebRequest, AppId appId, ISteamWebInterface steamWebInterface = null)
3627
{
3728
this.steamWebInterface = steamWebInterface == null
3829
? new SteamWebInterface("IGCVersion_" + (uint)appId, steamWebRequest)
@@ -45,16 +36,16 @@ public GCVersion(ISteamWebRequest steamWebRequest, GCVersionAppId appId, ISteamW
4536

4637
this.appId = (uint)appId;
4738

48-
validClientVersionAppIds.Add((int)GCVersionAppId.TeamFortress2);
49-
validClientVersionAppIds.Add((int)GCVersionAppId.Dota2);
50-
validClientVersionAppIds.Add((int)GCVersionAppId.Artifact);
51-
validClientVersionAppIds.Add((int)GCVersionAppId.DotaUnderlords);
39+
validClientVersionAppIds.Add((int)AppId.TeamFortress2);
40+
validClientVersionAppIds.Add((int)AppId.Dota2);
41+
validClientVersionAppIds.Add((int)AppId.Artifact);
42+
validClientVersionAppIds.Add((int)AppId.DotaUnderlords);
5243

53-
validServerVersionAppIds.Add((int)GCVersionAppId.TeamFortress2);
54-
validServerVersionAppIds.Add((int)GCVersionAppId.Dota2);
55-
validServerVersionAppIds.Add((int)GCVersionAppId.CounterStrikeGO);
56-
validServerVersionAppIds.Add((int)GCVersionAppId.Artifact);
57-
validServerVersionAppIds.Add((int)GCVersionAppId.DotaUnderlords);
44+
validServerVersionAppIds.Add((int)AppId.TeamFortress2);
45+
validServerVersionAppIds.Add((int)AppId.Dota2);
46+
validServerVersionAppIds.Add((int)AppId.CounterStrikeGO);
47+
validServerVersionAppIds.Add((int)AppId.Artifact);
48+
validServerVersionAppIds.Add((int)AppId.DotaUnderlords);
5849
}
5950

6051
/// <summary>

src/SteamWebAPI2/Interfaces/GameServersService.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66

77
namespace SteamWebAPI2.Interfaces
88
{
9-
public enum GameServersAppId
10-
{
11-
TeamFortress2 = 440,
12-
CounterStrikeGo = 730
13-
}
14-
159
public class GameServersService : IGameServersService
1610
{
1711
private ISteamWebInterface steamWebInterface;
@@ -44,7 +38,7 @@ public async Task<ISteamWebResponse<AccountListModel>> GetAccountListAsync()
4438
/// <param name="appId">Only supports TF2 and CSGO.</param>
4539
/// <param name="memo">Free text to attach to server. Does nothing but act as an identifier.</param>
4640
/// <returns>Steam ID and LoginToken for the new server.</returns>
47-
public async Task<ISteamWebResponse<CreateAccountModel>> CreateAccountAsync(GameServersAppId appId, string memo)
41+
public async Task<ISteamWebResponse<CreateAccountModel>> CreateAccountAsync(AppId appId, string memo)
4842
{
4943
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
5044
parameters.AddIfHasValue((int)appId, "appid");

src/SteamWebAPI2/Interfaces/IGameServersService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public interface IGameServersService
99
{
1010
Task<ISteamWebResponse<AccountListModel>> GetAccountListAsync();
1111

12-
Task<ISteamWebResponse<CreateAccountModel>> CreateAccountAsync(GameServersAppId appId, string memo);
12+
Task<ISteamWebResponse<CreateAccountModel>> CreateAccountAsync(AppId appId, string memo);
1313

1414
Task SetMemoAsync(ulong steamId, string memo);
1515

src/SteamWebAPI2/Utilities/SteamWebInterfaceFactory.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,7 @@ public T CreateSteamWebInterface<T>(HttpClient httpClient = null)
5050
/// If null, new instance is created with all defaults.</param>
5151
/// <typeparam name="T">Type of the web interface to create</typeparam>
5252
/// <returns>Instance of the web interface</returns>
53-
public T CreateSteamWebInterface<T>(EconItemsAppId appId, HttpClient httpClient = null)
54-
{
55-
var steamWebRequest = CreateSteamWebRequest(httpClient);
56-
return (T)Activator.CreateInstance(typeof(T), steamWebRequest, appId, null);
57-
}
58-
59-
/// <summary>
60-
/// Creates a web interface object connected to a specific Steam Web API interface endpoint
61-
/// </summary>
62-
/// <param name="appId">Indicates which app to use</param>
63-
/// <param name="httpClient">Custom http client injected with your customization (if necessary).
64-
/// If null, new instance is created with all defaults.</param>
65-
/// <typeparam name="T">Type of the web interface to create</typeparam>
66-
/// <returns>Instance of the web interface</returns>
67-
public T CreateSteamWebInterface<T>(GCVersionAppId appId, HttpClient httpClient = null)
53+
public T CreateSteamWebInterface<T>(AppId appId, HttpClient httpClient = null)
6854
{
6955
var steamWebRequest = CreateSteamWebRequest(httpClient);
7056
return (T)Activator.CreateInstance(typeof(T), steamWebRequest, appId, null);

0 commit comments

Comments
 (0)