Skip to content

Commit 1d3f8d1

Browse files
Merge pull request #82 from GavinPower747/development
Release 2.0.0
2 parents 56ee19e + 79440cb commit 1d3f8d1

File tree

18 files changed

+353
-38
lines changed

18 files changed

+353
-38
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 1.8.1.{build}
1+
version: 2.0.0.{build}
22
image: Visual Studio 2017
33
skip_tags: true
44

src/pubg-dotnet/Exceptions/PubgNotFoundException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Pubg.Net.Exceptions
44
{
55
public class PubgNotFoundException : PubgException
66
{
7-
private const string DefaultErrorMessage = "Unable to find specified resource";
7+
private const string DefaultErrorMessage = "API returned 404. An entity with the specified ID was not found";
88

99
public PubgNotFoundException() : base(DefaultErrorMessage, HttpStatusCode.NotFound) { }
1010
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Converters;
3+
using System.Runtime.Serialization;
4+
5+
namespace Pubg.Net
6+
{
7+
[JsonConverter(typeof(StringEnumConverter))]
8+
public enum PubgPlatform
9+
{
10+
[EnumMember(Value = "steam")]
11+
Steam,
12+
[EnumMember(Value = "kakao")]
13+
Kakao
14+
}
15+
}
File renamed without changes.

src/pubg-dotnet/Models/Match/PubgMap.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Pubg.Net
77
{
8-
[JsonConverter( typeof( DefaultValueStringEnumConverter ) )]
8+
[JsonConverter(typeof(DefaultValueStringEnumConverter))]
99
public enum PubgMap
1010
{
1111
//In some of the Telemetry they return an empty string
@@ -16,6 +16,8 @@ public enum PubgMap
1616
[EnumMember( Value = "Desert_Main" )]
1717
Miramar,
1818
[EnumMember(Value = "Savage_Main")]
19-
Sanhok
19+
Sanhok,
20+
[EnumMember(Value = "Range_Main")]
21+
TrainingRange
2022
}
2123
}

src/pubg-dotnet/Models/Players/PubgPlayerSeason.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ public class PubgPlayerSeason : PubgEntity
1111
[JsonProperty]
1212
public PubgSeasonStats GameModeStats { get; set; }
1313

14+
[JsonProperty]
15+
public PubgSeasonStats LifetimeStats { get; set; }
16+
1417
[JsonProperty("player")]
1518
[JsonConverter(typeof(RelationshipIdConverter))]
1619
public string PlayerId { get; set; }

src/pubg-dotnet/Models/Stats/PubgGameModeStats.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ public class PubgGameModeStats
77
[JsonProperty]
88
public int Assists { get; set; }
99

10+
[JsonProperty]
11+
public float BestRankPoints { get; set; }
12+
1013
[JsonProperty]
1114
public int Boosts { get; set; }
1215

@@ -16,6 +19,9 @@ public class PubgGameModeStats
1619
[JsonProperty]
1720
public int DailyKills { get; set; }
1821

22+
[JsonProperty]
23+
public int DailyWins { get; set; }
24+
1925
[JsonProperty]
2026
public float DamageDealt { get; set; }
2127

@@ -49,6 +55,9 @@ public class PubgGameModeStats
4955
[JsonProperty]
5056
public float MostSurvivalTime { get; set; }
5157

58+
[JsonProperty]
59+
public float RankPoints { get; set; }
60+
5261
[JsonProperty]
5362
public int Revives { get; set; }
5463

@@ -67,6 +76,9 @@ public class PubgGameModeStats
6776
[JsonProperty]
6877
public int Suicides { get; set; }
6978

79+
[JsonProperty]
80+
public float SwimDistance { get; set; }
81+
7082
[JsonProperty]
7183
public int TeamKills { get; set; }
7284

@@ -88,6 +100,9 @@ public class PubgGameModeStats
88100
[JsonProperty]
89101
public int WeeklyKills { get; set; }
90102

103+
[JsonProperty]
104+
public int WeeklyWins { get; set; }
105+
91106
[JsonProperty]
92107
public float WinPoints { get; set; }
93108

src/pubg-dotnet/Models/Stats/PubgParticipantStats.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public class PubgParticipantStats
5656
[JsonProperty]
5757
public int MostDamage { get; set; }
5858

59+
[JsonProperty]
60+
public float RankPoints { get; set; }
61+
5962
[JsonProperty]
6063
public int Revives { get; set; }
6164

src/pubg-dotnet/Services/Matches/PubgMatchService.cs

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Collections.Generic;
55
using System.Threading;
66
using System.Threading.Tasks;
7-
using Pubg.Net.Extensions;
87
using Newtonsoft.Json;
98
using JsonApiSerializer;
109
using System.Linq;
@@ -16,19 +15,95 @@ public class PubgMatchService : PubgService
1615
public PubgMatchService() : base() { }
1716
public PubgMatchService(string apiKey) : base(apiKey) { }
1817

19-
public virtual PubgMatch GetMatch(PubgRegion region, string matchId, string apiKey = null)
18+
/// <summary>
19+
/// Get a specified match which was played on the PC from the Api from the default platform (steam)
20+
/// </summary>
21+
/// <param name="matchId">The ID for the specified match</param>
22+
/// <param name="apiKey">Your Api Key (optional, not needed if specified elsewhere)</param>
23+
/// <returns>PubgMatch object for the specified ID</returns>
24+
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
25+
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified match</exception>
26+
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
27+
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
28+
public virtual PubgMatch GetMatchPC(string matchId, string apiKey = null) => GetMatchPC(PubgPlatform.Steam, matchId, apiKey);
29+
30+
/// <summary>
31+
/// Get a specified match which was played on the PC from the Api from the specified platform
32+
/// </summary>
33+
/// <param name="region">The platform the match is on</param>
34+
/// <param name="matchId">The ID for the specified match</param>
35+
/// <param name="apiKey">Your Api Key (optional, not needed if specified elsewhere)</param>
36+
/// <returns>PubgMatch object for the specified ID</returns>
37+
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
38+
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified match</exception>
39+
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
40+
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
41+
public virtual PubgMatch GetMatchPC(PubgPlatform platform, string matchId, string apiKey = null)
42+
{
43+
var url = Api.Matches.MatchesPCEndpoint(platform, matchId);
44+
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;
45+
46+
var matchJson = HttpRequestor.GetString(url, apiKey);
47+
48+
return JsonConvert.DeserializeObject<IEnumerable<PubgMatch>>(matchJson, new JsonApiSerializerSettings()).FirstOrDefault();
49+
}
50+
51+
/// <summary>
52+
/// Get a specified match which was played on the PC from the Api from the specified platform asychronously
53+
/// </summary>
54+
/// <param name="region">The platform the match is on</param>
55+
/// <param name="matchId">The ID for the specified match</param>
56+
/// <param name="apiKey">Your Api Key (optional, not needed if specified elsewhere)</param>
57+
/// <returns>PubgMatch object for the specified ID</returns>
58+
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
59+
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified match</exception>
60+
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
61+
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
62+
public async virtual Task<PubgMatch> GetMatchPCAsync(PubgPlatform region, string matchId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
63+
{
64+
var url = Api.Matches.MatchesPCEndpoint(region, matchId);
65+
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;
66+
67+
var matchJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false);
68+
69+
return JsonConvert.DeserializeObject<IEnumerable<PubgMatch>>(matchJson, new JsonApiSerializerSettings()).FirstOrDefault();
70+
}
71+
72+
/// <summary>
73+
/// Get a specified match which was played on the Xbox from the Api from the specified platform
74+
/// </summary>
75+
/// <param name="region">The region the match is held in</param>
76+
/// <param name="matchId">The ID for the specified match</param>
77+
/// <param name="apiKey">Your Api Key (optional, not needed if specified elsewhere)</param>
78+
/// <returns>PubgMatch object for the specified ID</returns>
79+
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
80+
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified match</exception>
81+
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
82+
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
83+
public virtual PubgMatch GetMatchXbox(PubgRegion region, string matchId, string apiKey = null)
2084
{
21-
var url = Api.Matches.MatchesEndpoint(region, matchId);
85+
var url = Api.Matches.MatchesXboxEndpoint(region, matchId);
2286
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;
2387

2488
var matchJson = HttpRequestor.GetString(url, apiKey);
2589

2690
return JsonConvert.DeserializeObject<IEnumerable<PubgMatch>>(matchJson, new JsonApiSerializerSettings()).FirstOrDefault();
2791
}
2892

29-
public async virtual Task<PubgMatch> GetMatchAsync(PubgRegion region, string matchId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
93+
/// <summary>
94+
/// Get a specified match which was played on the Xbox from the Api from the specified platform asychronously
95+
/// </summary>
96+
/// <param name="region">The region the match is held in</param>
97+
/// <param name="matchId">The ID for the specified match</param>
98+
/// <param name="apiKey">Your Api Key (optional, not needed if specified elsewhere)</param>
99+
/// <returns>PubgMatch object for the specified ID</returns>
100+
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
101+
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified match</exception>
102+
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
103+
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
104+
public async virtual Task<PubgMatch> GetMatchXboxAsync(PubgRegion region, string matchId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
30105
{
31-
var url = Api.Matches.MatchesEndpoint(region, matchId);
106+
var url = Api.Matches.MatchesXboxEndpoint(region, matchId);
32107
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;
33108

34109
var matchJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false);

src/pubg-dotnet/Services/Players/PubgPlayerService.cs

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,100 @@ public virtual IEnumerable<PubgPlayer> GetPlayers(PubgRegion region, GetPubgPlay
5454
return JsonConvert.DeserializeObject<IEnumerable<PubgPlayer>>(collectionJson, new JsonApiSerializerSettings());
5555
}
5656

57-
public virtual PubgPlayerSeason GetPlayerSeason(PubgRegion region, string playerId, string seasonId, string apiKey = null)
57+
/// <summary>
58+
/// Gets the players season stats and matches for the default platform (steam)
59+
/// </summary>
60+
/// <param name="playerId">The ID of the player you wish to retrieve the season stats for</param>
61+
/// <param name="seasonId">The ID of the season you wish to recieve stats and matches for</param>
62+
/// <param name="apiKey">Your API key (optional)</param>
63+
/// <returns>Stats and matches for a given player during a given season</returns>
64+
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
65+
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified player</exception>
66+
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
67+
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
68+
public virtual PubgPlayerSeason GetPlayerSeasonPC(string playerId, string seasonId, string apiKey = null) => GetPlayerSeasonPC(PubgPlatform.Steam, playerId, seasonId, apiKey);
69+
70+
/// <summary>
71+
/// Gets the players season stats and matches for the specified platform
72+
/// </summary>
73+
/// <param name="platform">The platform on which the season took place</param>
74+
/// <param name="playerId">The ID of the player you wish to retrieve the season stats for</param>
75+
/// <param name="seasonId">The ID of the season you wish to recieve stats and matches for</param>
76+
/// <param name="apiKey">Your API key (optional)</param>
77+
/// <returns>Stats and matches for a given player during a given season</returns>
78+
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
79+
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified player</exception>
80+
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
81+
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
82+
public virtual PubgPlayerSeason GetPlayerSeasonPC(PubgPlatform platform, string playerId, string seasonId, string apiKey = null)
5883
{
59-
var url = Api.Players.PlayerSeasonsEndpoint(region, playerId, seasonId);
84+
var url = Api.Players.PlayerSeasonsPCEndpoint(platform, playerId, seasonId);
6085
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;
6186

6287
var seasonJson = HttpRequestor.GetString(url, apiKey);
6388

6489
return JsonConvert.DeserializeObject<PubgPlayerSeason>(seasonJson, new JsonApiSerializerSettings());
6590
}
6691

67-
public async virtual Task<PubgPlayerSeason> GetPlayerSeasonAsync(PubgRegion region, string playerId, string seasonId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
92+
/// <summary>
93+
/// Gets the players season stats and matches for the specified platform asynchronusly
94+
/// </summary>
95+
/// <param name="platform">The platform on which the season took place</param>
96+
/// <param name="playerId">The ID of the player you wish to retrieve the season stats for</param>
97+
/// <param name="seasonId">The ID of the season you wish to recieve stats and matches for</param>
98+
/// <param name="apiKey">Your API key (optional)</param>
99+
/// <returns>Stats and matches for a given player during a given season</returns>
100+
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
101+
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified player</exception>
102+
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
103+
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
104+
public async virtual Task<PubgPlayerSeason> GetPlayerSeasonPCAsync(PubgPlatform platform, string playerId, string seasonId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
68105
{
69-
var url = Api.Players.PlayerSeasonsEndpoint(region, playerId, seasonId);
106+
var url = Api.Players.PlayerSeasonsPCEndpoint(platform, playerId, seasonId);
107+
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;
108+
109+
var seasonJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false);
110+
111+
return JsonConvert.DeserializeObject<PubgPlayerSeason>(seasonJson, new JsonApiSerializerSettings());
112+
}
113+
114+
/// <summary>
115+
/// Gets the players season stats and matches played on the xbox in the specified region
116+
/// </summary>
117+
/// <param name="region">The region which the player is located in</param>
118+
/// <param name="playerId">The ID of the player you wish to retrieve the season stats for</param>
119+
/// <param name="seasonId">The ID of the season you wish to recieve stats and matches for</param>
120+
/// <param name="apiKey">Your API key (optional)</param>
121+
/// <returns>Stats and matches for a given player during a given season</returns>
122+
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
123+
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified player</exception>
124+
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
125+
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
126+
public virtual PubgPlayerSeason GetPlayerSeasonXbox(PubgRegion region, string playerId, string seasonId, string apiKey = null)
127+
{
128+
var url = Api.Players.PlayerSeasonsXboxEndpoint(region, playerId, seasonId);
129+
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;
130+
131+
var seasonJson = HttpRequestor.GetString(url, apiKey);
132+
133+
return JsonConvert.DeserializeObject<PubgPlayerSeason>(seasonJson, new JsonApiSerializerSettings());
134+
}
135+
136+
/// <summary>
137+
/// Gets the players season stats and matches played on the xbox in the specified region asychronusly
138+
/// </summary>
139+
/// <param name="region">The region which the player is located in</param>
140+
/// <param name="playerId">The ID of the player you wish to retrieve the season stats for</param>
141+
/// <param name="seasonId">The ID of the season you wish to recieve stats and matches for</param>
142+
/// <param name="apiKey">Your API key (optional)</param>
143+
/// <returns>Stats and matches for a given player during a given season</returns>
144+
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
145+
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified player</exception>
146+
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
147+
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
148+
public async virtual Task<PubgPlayerSeason> GetPlayerSeasonXboxAsync(PubgRegion region, string playerId, string seasonId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
149+
{
150+
var url = Api.Players.PlayerSeasonsXboxEndpoint(region, playerId, seasonId);
70151
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;
71152

72153
var seasonJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false);

0 commit comments

Comments
 (0)