Skip to content

Commit bc3c9fb

Browse files
author
babelshift
committed
Added base string to identify the interface name of each interface class.
Added interface/method for DOTA2 fantasy stuff.
1 parent 26f5411 commit bc3c9fb

11 files changed

Lines changed: 83 additions & 15 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace SteamWebAPI2.Models
8+
{
9+
public class DOTA2PlayerOfficialInfoResult
10+
{
11+
public string Name { get; set; }
12+
public string TeamName { get; set; }
13+
public string TeamTag { get; set; }
14+
public string Sponsor { get; set; }
15+
public int FantasyRole { get; set; }
16+
}
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace SteamWebAPI2.Models
8+
{
9+
public class DOTA2PlayerOfficialInfoResultContainer
10+
{
11+
public DOTA2PlayerOfficialInfoResult Result { get; set; }
12+
}
13+
}

SteamWebAPI2.Models/SteamWebAPI2.Models.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
<Compile Include="CSGOServerStatusResult.cs" />
5757
<Compile Include="CSGOServerStatusResultContainer.cs" />
5858
<Compile Include="CSGOServices.cs" />
59+
<Compile Include="DOTA2PlayerOfficialInfoResult.cs" />
60+
<Compile Include="DOTA2PlayerOfficialInfoResultContainer.cs" />
5961
<Compile Include="FeedData.cs" />
6062
<Compile Include="Friend.cs" />
6163
<Compile Include="GameSchema.cs" />

SteamWebAPI2/CSGOServers.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ namespace SteamWebAPI2
99
{
1010
internal class CSGOServers : SteamWebRequest
1111
{
12-
public CSGOServers(SteamWebRequestParameter developerKey) : base(developerKey) { }
12+
public CSGOServers(SteamWebRequestParameter developerKey)
13+
: base(developerKey, "ICSGOServers_730") { }
1314

1415
public async Task<CSGOServerStatusResult> GetGameServerStatusAsync()
1516
{
16-
var gameServerStatus = await GetJsonAsync<CSGOServerStatusResultContainer>("ICSGOServers_730", "GetGameServersStatus", 1);
17+
var gameServerStatus = await GetJsonAsync<CSGOServerStatusResultContainer>(interfaceName, "GetGameServersStatus", 1);
1718
return gameServerStatus.Result;
1819
}
1920
}

SteamWebAPI2/DOTA2Fantasy.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using SteamWebAPI2.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace SteamWebAPI2
9+
{
10+
internal class DOTA2Fantasy : SteamWebRequest
11+
{
12+
13+
public DOTA2Fantasy(SteamWebRequestParameter developerKey)
14+
: base(developerKey, "IDOTA2Fantasy_570") { }
15+
16+
public async Task<DOTA2PlayerOfficialInfoResult> GetPlayerOfficialInfo(long steamId)
17+
{
18+
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
19+
parameters.Add(new SteamWebRequestParameter("accountid", steamId.ToString()));
20+
21+
var gameServerStatus = await GetJsonAsync<DOTA2PlayerOfficialInfoResultContainer>(interfaceName, "GetPlayerOfficialInfo", 1, parameters);
22+
return gameServerStatus.Result;
23+
}
24+
}
25+
}

SteamWebAPI2/SteamUser.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ namespace SteamWebAPI2
99
{
1010
internal class SteamUser : SteamWebRequest
1111
{
12-
public SteamUser(SteamWebRequestParameter developerKey) : base(developerKey) { }
12+
public SteamUser(SteamWebRequestParameter developerKey)
13+
: base(developerKey, "ISteamUser") { }
1314

1415
public async Task<PlayerSummary> GetPlayerSummaryAsync(string steamId)
1516
{
1617
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
1718
parameters.Add(new SteamWebRequestParameter("steamids", steamId));
18-
var playerSummary = await GetJsonAsync<PlayerSummaryResponseContainer>("ISteamUser", "GetPlayerSummaries", 2, parameters);
19+
var playerSummary = await GetJsonAsync<PlayerSummaryResponseContainer>(interfaceName, "GetPlayerSummaries", 2, parameters);
1920

2021
if (playerSummary.Response.Players.Count > 0)
2122
{

SteamWebAPI2/SteamWebAPI2.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
</ItemGroup>
4747
<ItemGroup>
4848
<Compile Include="CSGOServers.cs" />
49+
<Compile Include="DOTA2Fantasy.cs" />
4950
<Compile Include="ErrorMessages.Designer.cs">
5051
<AutoGen>True</AutoGen>
5152
<DesignTime>True</DesignTime>

SteamWebAPI2/SteamWebAPIUtil.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ namespace SteamWebAPI2
1010
{
1111
internal class SteamWebAPIUtil : SteamWebRequest
1212
{
13-
public SteamWebAPIUtil(SteamWebRequestParameter developerKey) : base(developerKey) { }
13+
public SteamWebAPIUtil(SteamWebRequestParameter developerKey)
14+
: base(developerKey, "ISteamWebAPIUtil") { }
1415

1516
public async Task<SteamServerInfo> GetServerInfoAsync()
1617
{
17-
var steamServerInfo = await GetJsonAsync<SteamServerInfo>("ISteamWebAPIUtil", "GetServerInfo", 1);
18+
var steamServerInfo = await GetJsonAsync<SteamServerInfo>(interfaceName, "GetServerInfo", 1);
1819
return steamServerInfo;
1920
}
2021

2122
public async Task<IReadOnlyCollection<SteamInterface>> GetSupportedAPIListAsync()
2223
{
23-
var steamApiListContainer = await GetJsonAsync<SteamApiListContainer>("ISteamWebAPIUtil", "GetSupportedAPIList", 1);
24+
var steamApiListContainer = await GetJsonAsync<SteamApiListContainer>(interfaceName, "GetSupportedAPIList", 1);
2425
return new ReadOnlyCollection<SteamInterface>(steamApiListContainer.ApiList.Interfaces);
2526
}
2627
}

SteamWebAPI2/SteamWebRequest.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ namespace SteamWebAPI2
1313
{
1414
internal abstract class SteamWebRequest
1515
{
16+
protected readonly string interfaceName;
1617
private SteamWebRequestParameter developerKey;
1718

18-
public SteamWebRequest(SteamWebRequestParameter developerKey)
19+
public SteamWebRequest(SteamWebRequestParameter developerKey, string interfaceName)
1920
{
2021
// we assert here because SteamWebRequest is never constructed by the application, instead it is constructed by SteamWebSession (controlled by this library)
2122
Debug.Assert(developerKey != null);
@@ -29,6 +30,10 @@ public SteamWebRequest(SteamWebRequestParameter developerKey)
2930
}
3031

3132
this.developerKey = developerKey;
33+
34+
Debug.Assert(!String.IsNullOrEmpty(interfaceName));
35+
36+
this.interfaceName = interfaceName;
3237
}
3338

3439
protected async Task<T> GetJsonAsync<T>(string interfaceName, string methodName, int methodVersion)
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
62

73
namespace SteamWebAPI2
84
{
9-
public class SteamWebRequestParameter
5+
internal class SteamWebRequestParameter
106
{
117
public string Name { get; private set; }
128
public string Value { get; private set; }
139

1410
public SteamWebRequestParameter(string name, string value)
1511
{
16-
if(String.IsNullOrEmpty(name))
12+
if (String.IsNullOrEmpty(name))
1713
{
1814
throw new ArgumentNullException("name");
1915
}
@@ -22,4 +18,4 @@ public SteamWebRequestParameter(string name, string value)
2218
this.Value = value;
2319
}
2420
}
25-
}
21+
}

0 commit comments

Comments
 (0)