Skip to content

Commit

Permalink
Merge pull request #81 from GavinPower747/URL.Platform.Changes
Browse files Browse the repository at this point in the history
Updates for API Version 6.0.0
  • Loading branch information
GavinPower747 authored Oct 3, 2018
2 parents 7357eec + 1911b57 commit 72a71b0
Show file tree
Hide file tree
Showing 15 changed files with 350 additions and 35 deletions.
15 changes: 15 additions & 0 deletions src/pubg-dotnet/Models/Common/PubgPlatform.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Runtime.Serialization;

namespace Pubg.Net
{
[JsonConverter(typeof(StringEnumConverter))]
public enum PubgPlatform
{
[EnumMember(Value = "steam")]
Steam,
[EnumMember(Value = "kakao")]
Kakao
}
}
File renamed without changes.
6 changes: 4 additions & 2 deletions src/pubg-dotnet/Models/Match/PubgMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Pubg.Net
{
[JsonConverter( typeof( DefaultValueStringEnumConverter ) )]
[JsonConverter(typeof(DefaultValueStringEnumConverter))]
public enum PubgMap
{
//In some of the Telemetry they return an empty string
Expand All @@ -16,6 +16,8 @@ public enum PubgMap
[EnumMember( Value = "Desert_Main" )]
Miramar,
[EnumMember(Value = "Savage_Main")]
Sanhok
Sanhok,
[EnumMember(Value = "Range_Main")]
TrainingRange
}
}
3 changes: 3 additions & 0 deletions src/pubg-dotnet/Models/Players/PubgPlayerSeason.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public class PubgPlayerSeason : PubgEntity
[JsonProperty]
public PubgSeasonStats GameModeStats { get; set; }

[JsonProperty]
public PubgSeasonStats LifetimeStats { get; set; }

[JsonProperty("player")]
[JsonConverter(typeof(RelationshipIdConverter))]
public string PlayerId { get; set; }
Expand Down
15 changes: 15 additions & 0 deletions src/pubg-dotnet/Models/Stats/PubgGameModeStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public class PubgGameModeStats
[JsonProperty]
public int Assists { get; set; }

[JsonProperty]
public float BestRankPoints { get; set; }

[JsonProperty]
public int Boosts { get; set; }

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

[JsonProperty]
public int DailyWins { get; set; }

[JsonProperty]
public float DamageDealt { get; set; }

Expand Down Expand Up @@ -49,6 +55,9 @@ public class PubgGameModeStats
[JsonProperty]
public float MostSurvivalTime { get; set; }

[JsonProperty]
public float RankPoints { get; set; }

[JsonProperty]
public int Revives { get; set; }

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

[JsonProperty]
public float SwimDistance { get; set; }

[JsonProperty]
public int TeamKills { get; set; }

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

[JsonProperty]
public int WeeklyWins { get; set; }

[JsonProperty]
public float WinPoints { get; set; }

Expand Down
3 changes: 3 additions & 0 deletions src/pubg-dotnet/Models/Stats/PubgParticipantStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public class PubgParticipantStats
[JsonProperty]
public int MostDamage { get; set; }

[JsonProperty]
public float RankPoints { get; set; }

[JsonProperty]
public int Revives { get; set; }

Expand Down
85 changes: 80 additions & 5 deletions src/pubg-dotnet/Services/Matches/PubgMatchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Pubg.Net.Extensions;
using Newtonsoft.Json;
using JsonApiSerializer;
using System.Linq;
Expand All @@ -16,19 +15,95 @@ public class PubgMatchService : PubgService
public PubgMatchService() : base() { }
public PubgMatchService(string apiKey) : base(apiKey) { }

public virtual PubgMatch GetMatch(PubgRegion region, string matchId, string apiKey = null)
/// <summary>
/// Get a specified match which was played on the PC from the Api from the default platform (steam)
/// </summary>
/// <param name="matchId">The ID for the specified match</param>
/// <param name="apiKey">Your Api Key (optional, not needed if specified elsewhere)</param>
/// <returns>PubgMatch object for the specified ID</returns>
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified match</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
public virtual PubgMatch GetMatchPC(string matchId, string apiKey = null) => GetMatchPC(PubgPlatform.Steam, matchId, apiKey);

/// <summary>
/// Get a specified match which was played on the PC from the Api from the specified platform
/// </summary>
/// <param name="region">The platform the match is on</param>
/// <param name="matchId">The ID for the specified match</param>
/// <param name="apiKey">Your Api Key (optional, not needed if specified elsewhere)</param>
/// <returns>PubgMatch object for the specified ID</returns>
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified match</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
public virtual PubgMatch GetMatchPC(PubgPlatform platform, string matchId, string apiKey = null)
{
var url = Api.Matches.MatchesPCEndpoint(platform, matchId);
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

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

/// <summary>
/// Get a specified match which was played on the PC from the Api from the specified platform asychronously
/// </summary>
/// <param name="region">The platform the match is on</param>
/// <param name="matchId">The ID for the specified match</param>
/// <param name="apiKey">Your Api Key (optional, not needed if specified elsewhere)</param>
/// <returns>PubgMatch object for the specified ID</returns>
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified match</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
public async virtual Task<PubgMatch> GetMatchPCAsync(PubgPlatform region, string matchId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
{
var url = Api.Matches.MatchesPCEndpoint(region, matchId);
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

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

/// <summary>
/// Get a specified match which was played on the Xbox from the Api from the specified platform
/// </summary>
/// <param name="region">The region the match is held in</param>
/// <param name="matchId">The ID for the specified match</param>
/// <param name="apiKey">Your Api Key (optional, not needed if specified elsewhere)</param>
/// <returns>PubgMatch object for the specified ID</returns>
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified match</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
public virtual PubgMatch GetMatchXbox(PubgRegion region, string matchId, string apiKey = null)
{
var url = Api.Matches.MatchesEndpoint(region, matchId);
var url = Api.Matches.MatchesXboxEndpoint(region, matchId);
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

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

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

var matchJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false);
Expand Down
89 changes: 85 additions & 4 deletions src/pubg-dotnet/Services/Players/PubgPlayerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,100 @@ public virtual IEnumerable<PubgPlayer> GetPlayers(PubgRegion region, GetPubgPlay
return JsonConvert.DeserializeObject<IEnumerable<PubgPlayer>>(collectionJson, new JsonApiSerializerSettings());
}

public virtual PubgPlayerSeason GetPlayerSeason(PubgRegion region, string playerId, string seasonId, string apiKey = null)
/// <summary>
/// Gets the players season stats and matches for the default platform (steam)
/// </summary>
/// <param name="playerId">The ID of the player you wish to retrieve the season stats for</param>
/// <param name="seasonId">The ID of the season you wish to recieve stats and matches for</param>
/// <param name="apiKey">Your API key (optional)</param>
/// <returns>Stats and matches for a given player during a given season</returns>
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified player</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
public virtual PubgPlayerSeason GetPlayerSeasonPC(string playerId, string seasonId, string apiKey = null) => GetPlayerSeasonPC(PubgPlatform.Steam, playerId, seasonId, apiKey);

/// <summary>
/// Gets the players season stats and matches for the specified platform
/// </summary>
/// <param name="platform">The platform on which the season took place</param>
/// <param name="playerId">The ID of the player you wish to retrieve the season stats for</param>
/// <param name="seasonId">The ID of the season you wish to recieve stats and matches for</param>
/// <param name="apiKey">Your API key (optional)</param>
/// <returns>Stats and matches for a given player during a given season</returns>
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified player</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
public virtual PubgPlayerSeason GetPlayerSeasonPC(PubgPlatform platform, string playerId, string seasonId, string apiKey = null)
{
var url = Api.Players.PlayerSeasonsEndpoint(region, playerId, seasonId);
var url = Api.Players.PlayerSeasonsPCEndpoint(platform, playerId, seasonId);
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

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

public async virtual Task<PubgPlayerSeason> GetPlayerSeasonAsync(PubgRegion region, string playerId, string seasonId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
/// <summary>
/// Gets the players season stats and matches for the specified platform asynchronusly
/// </summary>
/// <param name="platform">The platform on which the season took place</param>
/// <param name="playerId">The ID of the player you wish to retrieve the season stats for</param>
/// <param name="seasonId">The ID of the season you wish to recieve stats and matches for</param>
/// <param name="apiKey">Your API key (optional)</param>
/// <returns>Stats and matches for a given player during a given season</returns>
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified player</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
public async virtual Task<PubgPlayerSeason> GetPlayerSeasonPCAsync(PubgPlatform platform, string playerId, string seasonId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
{
var url = Api.Players.PlayerSeasonsEndpoint(region, playerId, seasonId);
var url = Api.Players.PlayerSeasonsPCEndpoint(platform, playerId, seasonId);
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

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

/// <summary>
/// Gets the players season stats and matches played on the xbox in the specified region
/// </summary>
/// <param name="region">The region which the player is located in</param>
/// <param name="playerId">The ID of the player you wish to retrieve the season stats for</param>
/// <param name="seasonId">The ID of the season you wish to recieve stats and matches for</param>
/// <param name="apiKey">Your API key (optional)</param>
/// <returns>Stats and matches for a given player during a given season</returns>
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified player</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
public virtual PubgPlayerSeason GetPlayerSeasonXbox(PubgRegion region, string playerId, string seasonId, string apiKey = null)
{
var url = Api.Players.PlayerSeasonsXboxEndpoint(region, playerId, seasonId);
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

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

/// <summary>
/// Gets the players season stats and matches played on the xbox in the specified region asychronusly
/// </summary>
/// <param name="region">The region which the player is located in</param>
/// <param name="playerId">The ID of the player you wish to retrieve the season stats for</param>
/// <param name="seasonId">The ID of the season you wish to recieve stats and matches for</param>
/// <param name="apiKey">Your API key (optional)</param>
/// <returns>Stats and matches for a given player during a given season</returns>
/// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgNotFoundException">The api is unable to find the specified player</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
/// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
public async virtual Task<PubgPlayerSeason> GetPlayerSeasonXboxAsync(PubgRegion region, string playerId, string seasonId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
{
var url = Api.Players.PlayerSeasonsXboxEndpoint(region, playerId, seasonId);
apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

0 comments on commit 72a71b0

Please sign in to comment.