Skip to content

Commit 50750e2

Browse files
author
babelshift
committed
Added wrappers for GetUserStatsForGame method.
1 parent 00dfca0 commit 50750e2

3 files changed

Lines changed: 62 additions & 5 deletions

File tree

SteamWebAPI2.Models/SteamWebAPI2.Models.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
<Compile Include="UserBanStatus.cs" />
9898
<Compile Include="UserGroupListResultContainer.cs" />
9999
<Compile Include="UserStats.cs" />
100+
<Compile Include="UserStatsForGameResultContainer.cs" />
100101
<Compile Include="Utilities\AssetClassInfoJsonConverter.cs" />
101102
<Compile Include="Utilities\CSGODataCenterJsonConverter.cs" />
102103
<Compile Include="Utilities\DateTimeExtensions.cs" />
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Generated by Xamasoft JSON Class Generator
2+
// http://www.xamasoft.com/json-class-generator
3+
4+
using Newtonsoft.Json;
5+
using System.Collections.Generic;
6+
7+
namespace SteamWebAPI2.Models
8+
{
9+
public class UserStat
10+
{
11+
[JsonProperty("name")]
12+
public string Name { get; set; }
13+
14+
[JsonProperty("value")]
15+
public int Value { get; set; }
16+
}
17+
18+
public class UserStatAchievement
19+
{
20+
[JsonProperty("name")]
21+
public string Name { get; set; }
22+
23+
[JsonProperty("achieved")]
24+
public int Achieved { get; set; }
25+
}
26+
27+
public class UserStatsForGameResult
28+
{
29+
[JsonProperty("steamID")]
30+
public string SteamId { get; set; }
31+
32+
[JsonProperty("gameName")]
33+
public string GameName { get; set; }
34+
35+
[JsonProperty("stats")]
36+
public IList<UserStat> Stats { get; set; }
37+
38+
[JsonProperty("achievements")]
39+
public IList<UserStatAchievement> Achievements { get; set; }
40+
}
41+
42+
public class UserStatsForGameResultContainer
43+
{
44+
[JsonProperty("playerstats")]
45+
public UserStatsForGameResult Result { get; set; }
46+
}
47+
}

SteamWebAPI2/SteamUserStats.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ public SteamUserStats(string steamWebApiKey)
1515
: base(steamWebApiKey, "ISteamUserStats")
1616
{ }
1717

18-
public async Task<IReadOnlyCollection<GlobalAchievementPercentage>> GetGlobalAchievementPercentagesForAppAsync(long appId)
18+
public async Task<IReadOnlyCollection<GlobalAchievementPercentage>> GetGlobalAchievementPercentagesForAppAsync(int appId)
1919
{
2020
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
2121
AddToParametersIfHasValue("gameid", appId, parameters);
2222
var achievementPercentagesResult = await CallMethodAsync<GlobalAchievementPercentagesResultContainer>("GetGlobalAchievementPercentagesForApp", 2, parameters);
2323
return new ReadOnlyCollection<GlobalAchievementPercentage>(achievementPercentagesResult.Result.AchievementPercentages);
2424
}
2525

26-
public async Task<GlobalStatsForGameResult> GetGlobalStatsForGameAsync(long appId, IReadOnlyList<string> statNames, DateTime? startDate = null, DateTime? endDate = null)
26+
public async Task<GlobalStatsForGameResult> GetGlobalStatsForGameAsync(int appId, IReadOnlyList<string> statNames, DateTime? startDate = null, DateTime? endDate = null)
2727
{
2828
long? startDateUnixTimeStamp = null;
2929
long? endDateUnixTimeStamp = null;
@@ -53,15 +53,15 @@ public async Task<GlobalStatsForGameResult> GetGlobalStatsForGameAsync(long appI
5353
return globalStatsResult.Result;
5454
}
5555

56-
public async Task<int> GetNumberOfCurrentPlayersForGameAsync(long appId)
56+
public async Task<int> GetNumberOfCurrentPlayersForGameAsync(int appId)
5757
{
5858
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
5959
AddToParametersIfHasValue("appid", appId, parameters);
6060
var globalStatsResult = await CallMethodAsync<CurrentPlayersResultContainer>("GetNumberOfCurrentPlayers", 1, parameters);
6161
return globalStatsResult.Result.PlayerCount;
6262
}
6363

64-
public async Task<PlayerStats> GetPlayerAchievementsAsync(long appId, long steamId, string language = "")
64+
public async Task<PlayerStats> GetPlayerAchievementsAsync(int appId, long steamId, string language = "")
6565
{
6666
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
6767
AddToParametersIfHasValue("appid", appId, parameters);
@@ -71,13 +71,22 @@ public async Task<PlayerStats> GetPlayerAchievementsAsync(long appId, long steam
7171
return playerStatsResult.PlayerStats;
7272
}
7373

74-
public async Task<SchemaForGameResult> GetSchemaForGamesAsync(long appId, string language = "")
74+
public async Task<SchemaForGameResult> GetSchemaForGameAsync(int appId, string language = "")
7575
{
7676
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
7777
AddToParametersIfHasValue("appid", appId, parameters);
7878
AddToParametersIfHasValue("l", language, parameters);
7979
var schemaForGameResult = await CallMethodAsync<SchemaForGameResultContainer>("GetSchemaForGame", 2, parameters);
8080
return schemaForGameResult.Result;
8181
}
82+
83+
public async Task<UserStatsForGameResult> GetUserStatsForGameAsync(long steamId, int appId)
84+
{
85+
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
86+
AddToParametersIfHasValue("steamid", steamId, parameters);
87+
AddToParametersIfHasValue("appid", appId, parameters);
88+
var userStatsForGameResult = await CallMethodAsync<UserStatsForGameResultContainer>("GetUserStatsForGame", 2, parameters);
89+
return userStatsForGameResult.Result;
90+
}
8291
}
8392
}

0 commit comments

Comments
 (0)