diff --git a/src/pubg-dotnet/Models/Common/PubgPlatform.cs b/src/pubg-dotnet/Models/Common/PubgPlatform.cs new file mode 100644 index 0000000..82a385e --- /dev/null +++ b/src/pubg-dotnet/Models/Common/PubgPlatform.cs @@ -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 + } +} diff --git a/src/pubg-dotnet/Models/Common/Region.cs b/src/pubg-dotnet/Models/Common/PubgRegion.cs similarity index 100% rename from src/pubg-dotnet/Models/Common/Region.cs rename to src/pubg-dotnet/Models/Common/PubgRegion.cs diff --git a/src/pubg-dotnet/Models/Match/PubgMap.cs b/src/pubg-dotnet/Models/Match/PubgMap.cs index b3adf1d..c767c20 100644 --- a/src/pubg-dotnet/Models/Match/PubgMap.cs +++ b/src/pubg-dotnet/Models/Match/PubgMap.cs @@ -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 @@ -16,6 +16,8 @@ public enum PubgMap [EnumMember( Value = "Desert_Main" )] Miramar, [EnumMember(Value = "Savage_Main")] - Sanhok + Sanhok, + [EnumMember(Value = "Range_Main")] + TrainingRange } } diff --git a/src/pubg-dotnet/Models/Players/PubgPlayerSeason.cs b/src/pubg-dotnet/Models/Players/PubgPlayerSeason.cs index 4d5ca96..3703d25 100644 --- a/src/pubg-dotnet/Models/Players/PubgPlayerSeason.cs +++ b/src/pubg-dotnet/Models/Players/PubgPlayerSeason.cs @@ -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; } diff --git a/src/pubg-dotnet/Models/Stats/PubgGameModeStats.cs b/src/pubg-dotnet/Models/Stats/PubgGameModeStats.cs index 0622de6..e3013b8 100644 --- a/src/pubg-dotnet/Models/Stats/PubgGameModeStats.cs +++ b/src/pubg-dotnet/Models/Stats/PubgGameModeStats.cs @@ -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; } @@ -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; } @@ -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; } @@ -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; } @@ -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; } diff --git a/src/pubg-dotnet/Models/Stats/PubgParticipantStats.cs b/src/pubg-dotnet/Models/Stats/PubgParticipantStats.cs index bb0d7c9..d02342f 100644 --- a/src/pubg-dotnet/Models/Stats/PubgParticipantStats.cs +++ b/src/pubg-dotnet/Models/Stats/PubgParticipantStats.cs @@ -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; } diff --git a/src/pubg-dotnet/Services/Matches/PubgMatchService.cs b/src/pubg-dotnet/Services/Matches/PubgMatchService.cs index 9afcd6c..915f750 100644 --- a/src/pubg-dotnet/Services/Matches/PubgMatchService.cs +++ b/src/pubg-dotnet/Services/Matches/PubgMatchService.cs @@ -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; @@ -16,9 +15,74 @@ public class PubgMatchService : PubgService public PubgMatchService() : base() { } public PubgMatchService(string apiKey) : base(apiKey) { } - public virtual PubgMatch GetMatch(PubgRegion region, string matchId, string apiKey = null) + /// + /// Get a specified match which was played on the PC from the Api from the default platform (steam) + /// + /// The ID for the specified match + /// Your Api Key (optional, not needed if specified elsewhere) + /// PubgMatch object for the specified ID + /// Exception thrown on the API side, details included on object + /// The api is unable to find the specified match + /// You have exceeded your rate limit + /// Invalid API Key + public virtual PubgMatch GetMatchPC(string matchId, string apiKey = null) => GetMatchPC(PubgPlatform.Steam, matchId, apiKey); + + /// + /// Get a specified match which was played on the PC from the Api from the specified platform + /// + /// The platform the match is on + /// The ID for the specified match + /// Your Api Key (optional, not needed if specified elsewhere) + /// PubgMatch object for the specified ID + /// Exception thrown on the API side, details included on object + /// The api is unable to find the specified match + /// You have exceeded your rate limit + /// Invalid API Key + 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>(matchJson, new JsonApiSerializerSettings()).FirstOrDefault(); + } + + /// + /// Get a specified match which was played on the PC from the Api from the specified platform asychronously + /// + /// The platform the match is on + /// The ID for the specified match + /// Your Api Key (optional, not needed if specified elsewhere) + /// PubgMatch object for the specified ID + /// Exception thrown on the API side, details included on object + /// The api is unable to find the specified match + /// You have exceeded your rate limit + /// Invalid API Key + public async virtual Task 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>(matchJson, new JsonApiSerializerSettings()).FirstOrDefault(); + } + + /// + /// Get a specified match which was played on the Xbox from the Api from the specified platform + /// + /// The region the match is held in + /// The ID for the specified match + /// Your Api Key (optional, not needed if specified elsewhere) + /// PubgMatch object for the specified ID + /// Exception thrown on the API side, details included on object + /// The api is unable to find the specified match + /// You have exceeded your rate limit + /// Invalid API Key + 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); @@ -26,9 +90,20 @@ public virtual PubgMatch GetMatch(PubgRegion region, string matchId, string apiK return JsonConvert.DeserializeObject>(matchJson, new JsonApiSerializerSettings()).FirstOrDefault(); } - public async virtual Task GetMatchAsync(PubgRegion region, string matchId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) + /// + /// Get a specified match which was played on the Xbox from the Api from the specified platform asychronously + /// + /// The region the match is held in + /// The ID for the specified match + /// Your Api Key (optional, not needed if specified elsewhere) + /// PubgMatch object for the specified ID + /// Exception thrown on the API side, details included on object + /// The api is unable to find the specified match + /// You have exceeded your rate limit + /// Invalid API Key + public async virtual Task 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); diff --git a/src/pubg-dotnet/Services/Players/PubgPlayerService.cs b/src/pubg-dotnet/Services/Players/PubgPlayerService.cs index 1c4d2cb..bccc255 100644 --- a/src/pubg-dotnet/Services/Players/PubgPlayerService.cs +++ b/src/pubg-dotnet/Services/Players/PubgPlayerService.cs @@ -54,9 +54,34 @@ public virtual IEnumerable GetPlayers(PubgRegion region, GetPubgPlay return JsonConvert.DeserializeObject>(collectionJson, new JsonApiSerializerSettings()); } - public virtual PubgPlayerSeason GetPlayerSeason(PubgRegion region, string playerId, string seasonId, string apiKey = null) + /// + /// Gets the players season stats and matches for the default platform (steam) + /// + /// The ID of the player you wish to retrieve the season stats for + /// The ID of the season you wish to recieve stats and matches for + /// Your API key (optional) + /// Stats and matches for a given player during a given season + /// Exception thrown on the API side, details included on object + /// The api is unable to find the specified player + /// You have exceeded your rate limit + /// Invalid API Key + public virtual PubgPlayerSeason GetPlayerSeasonPC(string playerId, string seasonId, string apiKey = null) => GetPlayerSeasonPC(PubgPlatform.Steam, playerId, seasonId, apiKey); + + /// + /// Gets the players season stats and matches for the specified platform + /// + /// The platform on which the season took place + /// The ID of the player you wish to retrieve the season stats for + /// The ID of the season you wish to recieve stats and matches for + /// Your API key (optional) + /// Stats and matches for a given player during a given season + /// Exception thrown on the API side, details included on object + /// The api is unable to find the specified player + /// You have exceeded your rate limit + /// Invalid API Key + 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); @@ -64,9 +89,65 @@ public virtual PubgPlayerSeason GetPlayerSeason(PubgRegion region, string player return JsonConvert.DeserializeObject(seasonJson, new JsonApiSerializerSettings()); } - public async virtual Task GetPlayerSeasonAsync(PubgRegion region, string playerId, string seasonId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) + /// + /// Gets the players season stats and matches for the specified platform asynchronusly + /// + /// The platform on which the season took place + /// The ID of the player you wish to retrieve the season stats for + /// The ID of the season you wish to recieve stats and matches for + /// Your API key (optional) + /// Stats and matches for a given player during a given season + /// Exception thrown on the API side, details included on object + /// The api is unable to find the specified player + /// You have exceeded your rate limit + /// Invalid API Key + public async virtual Task 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(seasonJson, new JsonApiSerializerSettings()); + } + + /// + /// Gets the players season stats and matches played on the xbox in the specified region + /// + /// The region which the player is located in + /// The ID of the player you wish to retrieve the season stats for + /// The ID of the season you wish to recieve stats and matches for + /// Your API key (optional) + /// Stats and matches for a given player during a given season + /// Exception thrown on the API side, details included on object + /// The api is unable to find the specified player + /// You have exceeded your rate limit + /// Invalid API Key + 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(seasonJson, new JsonApiSerializerSettings()); + } + + /// + /// Gets the players season stats and matches played on the xbox in the specified region asychronusly + /// + /// The region which the player is located in + /// The ID of the player you wish to retrieve the season stats for + /// The ID of the season you wish to recieve stats and matches for + /// Your API key (optional) + /// Stats and matches for a given player during a given season + /// Exception thrown on the API side, details included on object + /// The api is unable to find the specified player + /// You have exceeded your rate limit + /// Invalid API Key + public async virtual Task 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); diff --git a/src/pubg-dotnet/Services/Seasons/PubgSeasonService.cs b/src/pubg-dotnet/Services/Seasons/PubgSeasonService.cs index 06513b0..6371960 100644 --- a/src/pubg-dotnet/Services/Seasons/PubgSeasonService.cs +++ b/src/pubg-dotnet/Services/Seasons/PubgSeasonService.cs @@ -14,9 +14,18 @@ public class PubgSeasonService : PubgService public PubgSeasonService() : base() { } public PubgSeasonService(string apiKey) : base(apiKey) { } - public virtual IEnumerable GetSeasons(PubgRegion region, string apiKey = null) + /// + /// Get a list of seasons for the specified platform on the PC (default: Steam) + /// + /// The platform you wish to get the seasons for + /// Your api key (optional) + /// A list of seasons and their information + /// Exception thrown on the API side, details included on object + /// You have exceeded your rate limit + /// Invalid API Key + public virtual IEnumerable GetSeasonsPC(PubgPlatform platform = PubgPlatform.Steam, string apiKey = null) { - var url = Api.Seasons.SeasonsEndpoint(region); + var url = Api.Seasons.SeasonsPCEndpoint(platform); apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; var seasonJson = HttpRequestor.GetString(url, apiKey); @@ -24,9 +33,56 @@ public virtual IEnumerable GetSeasons(PubgRegion region, string apiK return JsonConvert.DeserializeObject>(seasonJson, new JsonApiSerializerSettings()); } - public async virtual Task> GetSeasonsAsync(PubgRegion region, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) + /// + /// Get a list of seasons for the specified platform on the PC (default: Steam) + /// + /// The platform you wish to get the seasons for + /// Your api key (optional) + /// A list of seasons and their information + /// Exception thrown on the API side, details included on object + /// You have exceeded your rate limit + /// Invalid API Key + public async virtual Task> GetSeasonsPCAsync(PubgPlatform platform = PubgPlatform.Steam, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) { - var url = Api.Seasons.SeasonsEndpoint(region); + var url = Api.Seasons.SeasonsPCEndpoint(platform); + apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; + + var seasonJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); + + return JsonConvert.DeserializeObject>(seasonJson, new JsonApiSerializerSettings()); + } + + /// + /// Get a list of seasons for the specified region on Xbox + /// + /// The platform you wish to get the seasons for + /// Your api key (optional) + /// A list of seasons and their information + /// Exception thrown on the API side, details included on object + /// You have exceeded your rate limit + /// Invalid API Key + public virtual IEnumerable GetSeasonsXbox(PubgRegion region, string apiKey = null) + { + var url = Api.Seasons.SeasonsXboxEndpoint(region); + apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; + + var seasonJson = HttpRequestor.GetString(url, apiKey); + + return JsonConvert.DeserializeObject>(seasonJson, new JsonApiSerializerSettings()); + } + + /// + /// Get a list of seasons for the specified region on Xbox + /// + /// The platform you wish to get the seasons for + /// Your api key (optional) + /// A list of seasons and their information + /// Exception thrown on the API side, details included on object + /// You have exceeded your rate limit + /// Invalid API Key + public async virtual Task> GetSeasonsXboxAsync(PubgRegion region, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) + { + var url = Api.Seasons.SeasonsXboxEndpoint(region); apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; var seasonJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); diff --git a/src/pubg-dotnet/Values/Api.cs b/src/pubg-dotnet/Values/Api.cs index f03a1e7..b8a2290 100644 --- a/src/pubg-dotnet/Values/Api.cs +++ b/src/pubg-dotnet/Values/Api.cs @@ -4,13 +4,15 @@ namespace Pubg.Net.Values { internal static class Api { - internal const string DefaultBaseUrl = "https://api.playbattlegrounds.com"; + internal const string DefaultBaseUrl = "https://api.pubg.com"; internal static string ShardedBaseUrl = PubgApiConfiguration.GetApiBase() + "/shards/{0}"; internal static class Matches { - internal static string MatchesEndpoint(PubgRegion region) => string.Format(ShardedBaseUrl + "/matches", region.Serialize()); - internal static string MatchesEndpoint(PubgRegion region, string matchId) => MatchesEndpoint(region) + $"/{matchId}"; + internal static string MatchesPCEndpoint(PubgPlatform platform) => string.Format(ShardedBaseUrl + "/matches", platform.Serialize()); + internal static string MatchesPCEndpoint(PubgPlatform platform, string matchId) => MatchesPCEndpoint(platform) + $"/{matchId}"; + internal static string MatchesXboxEndpoint(PubgRegion region) => string.Format(ShardedBaseUrl + "/matches", region.Serialize()); + internal static string MatchesXboxEndpoint(PubgRegion region, string matchId) => MatchesXboxEndpoint(region) + $"/{matchId}"; } internal static class Status @@ -22,7 +24,8 @@ internal static class Players { internal static string PlayersEndpoint(PubgRegion region) => string.Format(ShardedBaseUrl + "/players", region.Serialize()); internal static string PlayersEndpoint(PubgRegion region, string playerId) => PlayersEndpoint(region) + $"/{playerId}"; - internal static string PlayerSeasonsEndpoint(PubgRegion region, string playerId, string seasonId) => PlayersEndpoint(region) + $"/{playerId}/seasons/{seasonId}"; + internal static string PlayerSeasonsPCEndpoint(PubgPlatform platform, string playerId, string seasonId) => string.Format(ShardedBaseUrl + "/players/{1}/seasons/{2}", platform.Serialize(), playerId, seasonId); + internal static string PlayerSeasonsXboxEndpoint(PubgRegion region, string playerId, string seasonId) => PlayersEndpoint(region) + $"/{playerId}/seasons/{seasonId}"; } internal static class Samples @@ -32,7 +35,8 @@ internal static class Samples internal static class Seasons { - internal static string SeasonsEndpoint(PubgRegion region) => string.Format(ShardedBaseUrl + "/seasons", region.Serialize()); + internal static string SeasonsPCEndpoint(PubgPlatform platform) => string.Format(ShardedBaseUrl + "/seasons", platform.Serialize()); + internal static string SeasonsXboxEndpoint(PubgRegion region) => string.Format(ShardedBaseUrl + "/seasons", region.Serialize()); } internal static class Tournaments diff --git a/test/pubg-dotnet.Tests/Extensions/PubgRegionExtensions.cs b/test/pubg-dotnet.Tests/Extensions/PubgRegionExtensions.cs new file mode 100644 index 0000000..76be4b0 --- /dev/null +++ b/test/pubg-dotnet.Tests/Extensions/PubgRegionExtensions.cs @@ -0,0 +1,11 @@ +using Pubg.Net; +using Pubg.Net.Extensions; + +namespace pubg.net.Tests.Extensions +{ + public static class PubgRegionExtensions + { + public static bool IsPC(this PubgRegion region) => region.Serialize().ToLowerInvariant().Contains("pc"); + public static bool IsXbox(this PubgRegion region) => region.Serialize().ToLowerInvariant().Contains("xbox"); + } +} diff --git a/test/pubg-dotnet.Tests/Matches/MatchTests.cs b/test/pubg-dotnet.Tests/Matches/MatchTests.cs index 042379c..73d7991 100644 --- a/test/pubg-dotnet.Tests/Matches/MatchTests.cs +++ b/test/pubg-dotnet.Tests/Matches/MatchTests.cs @@ -14,13 +14,11 @@ public class MatchTests [Fact] public void Can_Retrieve_Match_ForPC() { - var region = PubgRegion.PCEurope; - var samples = Storage.GetSamples(region); + var samples = Storage.GetSamples(PubgRegion.PCEurope); var matchService = new PubgMatchService(Storage.ApiKey); - var match = matchService.GetMatch(region, samples.MatchIds.FirstOrDefault()); + var match = matchService.GetMatchPC(samples.MatchIds.FirstOrDefault()); - match.ShardId.Should().Equals(region.Serialize()); match.Rosters.Should().NotBeNull(); match.GameMode.Should().NotBeNullOrWhiteSpace(); @@ -34,7 +32,6 @@ public void Can_Retrieve_Match_ForPC() Assert.All(participants, p => p.Stats.Should().NotBeNull()); Assert.All(participants, p => p.Stats.KillPlace.Should().BeGreaterThan(0)); Assert.All(participants, p => p.Stats.WinPlace.Should().BeGreaterThan(0)); - Assert.All(participants, p => p.ShardId.Should().Equals(region.Serialize())); Assert.All(participants, p => p.Id.Should().NotBeNullOrWhiteSpace()); } @@ -45,7 +42,7 @@ public void Can_Retrieve_Match_ForXbox() var samples = Storage.GetSamples(region); var matchService = new PubgMatchService(Storage.ApiKey); - var match = matchService.GetMatch(region, samples.MatchIds.FirstOrDefault()); + var match = matchService.GetMatchXbox(region, samples.MatchIds.FirstOrDefault()); match.ShardId.Should().Equals(region.Serialize()); match.Rosters.Should().NotBeNull(); @@ -65,9 +62,15 @@ public void Can_Retrieve_Match_ForXbox() } [Fact] - public void Throws_Exception_When_NotFound() + public void Throws_Exception_When_NotFound_OnPC() + { + Assert.Throws(() => new PubgMatchService(Storage.ApiKey).GetMatchPC(Guid.Empty.ToString())); + } + + [Fact] + public void Throws_Exception_When_NotFound_OnXbox() { - Assert.Throws(() => new PubgMatchService(Storage.ApiKey).GetMatch(PubgRegion.PCEurope, Guid.Empty.ToString())); + Assert.Throws(() => new PubgMatchService(Storage.ApiKey).GetMatchXbox(PubgRegion.XboxEurope, Guid.Empty.ToString())); } } } diff --git a/test/pubg-dotnet.Tests/Players/PlayerTests.cs b/test/pubg-dotnet.Tests/Players/PlayerTests.cs index ae84df2..2014c4c 100644 --- a/test/pubg-dotnet.Tests/Players/PlayerTests.cs +++ b/test/pubg-dotnet.Tests/Players/PlayerTests.cs @@ -60,7 +60,7 @@ public void Can_Get_Player() } [Fact] - public void Can_Get_Season_For_Player() + public void Can_Get_Season_For_Player_OnPC() { var playerService = new PubgPlayerService(Storage.ApiKey); @@ -68,7 +68,31 @@ public void Can_Get_Season_For_Player() var playerId = Storage.GetMatch(region).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.PlayerId).FirstOrDefault(); var seasonId = Storage.GetSeason(region).Id; - var playerSeason = playerService.GetPlayerSeason(region, playerId, seasonId); + var playerSeason = playerService.GetPlayerSeasonPC(playerId, seasonId); + + playerSeason.Should().NotBeNull(); + playerSeason.GameModeStats.Should().NotBeNull(); + playerSeason.SeasonId.Should().NotBeNullOrWhiteSpace(); + playerSeason.PlayerId.Should().NotBeNullOrWhiteSpace(); + playerSeason.GameModeStats.Should().NotBeNull(); + playerSeason.GameModeStats.Solo.Should().NotBeNull(); + playerSeason.GameModeStats.SoloFPP.Should().NotBeNull(); + playerSeason.GameModeStats.Duo.Should().NotBeNull(); + playerSeason.GameModeStats.DuoFPP.Should().NotBeNull(); + playerSeason.GameModeStats.Squad.Should().NotBeNull(); + playerSeason.GameModeStats.SquadFPP.Should().NotBeNull(); + } + + [Fact] + public void Can_Get_Season_For_Player_OnXbox() + { + var playerService = new PubgPlayerService(Storage.ApiKey); + + var region = PubgRegion.PCEurope; + var playerId = Storage.GetMatch(region).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.PlayerId).FirstOrDefault(); + var seasonId = Storage.GetSeason(region).Id; + + var playerSeason = playerService.GetPlayerSeasonXbox(region, playerId, seasonId); playerSeason.Should().NotBeNull(); playerSeason.GameModeStats.Should().NotBeNull(); diff --git a/test/pubg-dotnet.Tests/Seasons/SeasonsTests.cs b/test/pubg-dotnet.Tests/Seasons/SeasonsTests.cs index 9a9e35b..432ae5b 100644 --- a/test/pubg-dotnet.Tests/Seasons/SeasonsTests.cs +++ b/test/pubg-dotnet.Tests/Seasons/SeasonsTests.cs @@ -8,11 +8,22 @@ namespace pubg.net.Tests.Seasons public class SeasonsTests { [Fact] - public void Can_Get_Seasons() + public void Can_Get_Seasons_OnPC() { var seasonsService = new PubgSeasonService(Storage.ApiKey); - var seasons = seasonsService.GetSeasons(PubgRegion.PCEurope); + var seasons = seasonsService.GetSeasonsPC(); + + Assert.All(seasons, s => s.Id.Should().NotBeNull()); + seasons.Should().ContainSingle(s => s.IsCurrentSeason == true); + } + + [Fact] + public void Can_Get_Seasons_OnXbox() + { + var seasonsService = new PubgSeasonService(Storage.ApiKey); + + var seasons = seasonsService.GetSeasonsXbox(PubgRegion.PCEurope); Assert.All(seasons, s => s.Id.Should().NotBeNull()); seasons.Should().ContainSingle(s => s.IsCurrentSeason == true); diff --git a/test/pubg-dotnet.Tests/Util/Storage.cs b/test/pubg-dotnet.Tests/Util/Storage.cs index 933d22e..20f3c9a 100644 --- a/test/pubg-dotnet.Tests/Util/Storage.cs +++ b/test/pubg-dotnet.Tests/Util/Storage.cs @@ -1,4 +1,5 @@ -using Pubg.Net; +using pubg.net.Tests.Extensions; +using Pubg.Net; using Pubg.Net.Extensions; using Pubg.Net.Models.Base; using Pubg.Net.Models.Samples; @@ -59,7 +60,12 @@ public static PubgMatch GetMatch(PubgRegion region) return match; var samples = GetSamples(region); - match = new PubgMatchService(ApiKey).GetMatch(region, samples.MatchIds.First()); + var matchService = new PubgMatchService(ApiKey); + + if (region.IsPC()) + match = matchService.GetMatchPC(samples.MatchIds.First()); + else if(region.IsXbox()) + match = matchService.GetMatchXbox(region, samples.MatchIds.First()); StoredItems.Add(match); @@ -73,7 +79,13 @@ public static PubgSeason GetSeason(PubgRegion region) if (season != null) return season; - var seasons = new PubgSeasonService(ApiKey).GetSeasons(region).ToList(); + var seasonService = new PubgSeasonService(ApiKey); + List seasons = new List(); + + if (region.IsPC()) + seasons = seasonService.GetSeasonsPC().ToList(); + else if (region.IsXbox()) + seasons = seasonService.GetSeasonsXbox(region).ToList(); seasons.ForEach(s => StoredItems.Add(s));