Skip to content

Commit 41f67f1

Browse files
author
babelshift
committed
Added wrappers for GetRecentlyPlayedGames method.
1 parent a37fe90 commit 41f67f1

4 files changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 RecentlyPlayedGame
10+
{
11+
[JsonProperty("appid")]
12+
public int AppId { get; set; }
13+
14+
[JsonProperty("name")]
15+
public string Name { get; set; }
16+
17+
[JsonProperty("playtime_2weeks")]
18+
public int Playtime2Weeks { get; set; }
19+
20+
[JsonProperty("playtime_forever")]
21+
public int PlaytimeForever { get; set; }
22+
23+
[JsonProperty("img_icon_url")]
24+
public string ImgIconUrl { get; set; }
25+
26+
[JsonProperty("img_logo_url")]
27+
public string ImgLogoUrl { get; set; }
28+
}
29+
30+
public class RecentlyPlayedGameResult
31+
{
32+
[JsonProperty("total_count")]
33+
public int TotalCount { get; set; }
34+
35+
[JsonProperty("games")]
36+
public IList<RecentlyPlayedGame> RecentlyPlayedGames { get; set; }
37+
}
38+
39+
public class RecentlyPlayedGameResultContainer
40+
{
41+
[JsonProperty("response")]
42+
public RecentlyPlayedGameResult Result { get; set; }
43+
}
44+
}

SteamWebAPI2.Models/SteamWebAPI2.Models.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<Compile Include="CurrentPlayersResultContainer.cs" />
5252
<Compile Include="PlayerAchievementResultContainer.cs" />
5353
<Compile Include="PlayerBansContainer.cs" />
54+
<Compile Include="RecentlyPlayedGameResultContainer.cs" />
5455
<Compile Include="ResolveVanityUrlResultContainer.cs" />
5556
<Compile Include="SchemaForGameResultContainer.cs" />
5657
<Compile Include="SteamAppUpToDateCheckResultContainer.cs" />

SteamWebAPI2/PlayerService.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+
public class PlayerService : SteamWebInterface
11+
{
12+
public PlayerService(string steamWebApiKey)
13+
: base(steamWebApiKey, "IPlayerService")
14+
{
15+
}
16+
17+
public async Task<RecentlyPlayedGameResult> GetRecentlyPlayedGamesAsync(long steamId)
18+
{
19+
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
20+
AddToParametersIfHasValue("steamid", steamId, parameters);
21+
var recentlyPlayedGameResult = await CallMethodAsync<RecentlyPlayedGameResultContainer>("GetRecentlyPlayedGames", 1, parameters);
22+
return recentlyPlayedGameResult.Result;
23+
}
24+
}
25+
}

SteamWebAPI2/SteamWebAPI2.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<Compile Include="DOTA2Ticket.cs" />
5353
<Compile Include="GCVersion.cs" />
5454
<Compile Include="EconItems.cs" />
55+
<Compile Include="PlayerService.cs" />
5556
<Compile Include="SteamEconomy.cs" />
5657
<Compile Include="SteamApps.cs" />
5758
<Compile Include="SteamNews.cs" />

0 commit comments

Comments
 (0)