├── src └── pubg-dotnet │ ├── Models │ ├── Match │ │ ├── PubgRound.cs │ │ ├── PubgSpectator.cs │ │ ├── PubgTeam.cs │ │ ├── PubgMatchStats.cs │ │ ├── PubgMap.cs │ │ ├── PubgMatch.cs │ │ └── PubgGameMode.cs │ ├── Base │ │ ├── PubgEntity.cs │ │ └── PubgShardedEntity.cs │ ├── Telemetry │ │ ├── Location.cs │ │ ├── Events │ │ │ ├── LogPlayerLogout.cs │ │ │ ├── LogPlayerCreate.cs │ │ │ ├── LogCarePackageLand.cs │ │ │ ├── LogGameStatePeriodic.cs │ │ │ ├── LogCarePackageSpawn.cs │ │ │ ├── LogSwimStart.cs │ │ │ ├── LogVaultStart.cs │ │ │ ├── LogRedZoneEnded.cs │ │ │ ├── LogMatchEnd.cs │ │ │ ├── LogPhaseChange.cs │ │ │ ├── LogItemDrop.cs │ │ │ ├── LogItemUse.cs │ │ │ ├── LogCharacterCarry.cs │ │ │ ├── LogItemEquip.cs │ │ │ ├── LogItemPickup.cs │ │ │ ├── LogItemUnequip.cs │ │ │ ├── LogMatchDefinition.cs │ │ │ ├── LogParachuteLanding.cs │ │ │ ├── LogItemPickUpFromCarePackage.cs │ │ │ ├── LogObjectInteraction.cs │ │ │ ├── LogPlayerLogin.cs │ │ │ ├── LogVehicleRide.cs │ │ │ ├── LogHeal.cs │ │ │ ├── LogItemAttach.cs │ │ │ ├── LogItemDetach.cs │ │ │ ├── LogPlayerRevive.cs │ │ │ ├── LogSwimEnd.cs │ │ │ ├── LogWeaponFireCount.cs │ │ │ ├── LogObjectDestroy.cs │ │ │ ├── LogItemPickupFromLootBox.cs │ │ │ ├── LogPlayerPosition.cs │ │ │ ├── LogPlayerUseThrowable.cs │ │ │ ├── LogVehicleLeave.cs │ │ │ ├── LogWheelDestroy.cs │ │ │ ├── PubgTelemetryEvent.cs │ │ │ ├── LogVehicleDestroy.cs │ │ │ ├── LogPlayerAttack.cs │ │ │ ├── LogVehicleDamage.cs │ │ │ ├── UnknownTelemetryEvent.cs │ │ │ ├── LogPlayerTakeDamage.cs │ │ │ ├── LogArmorDestroy.cs │ │ │ ├── LogPlayerMakeGroggy.cs │ │ │ ├── LogMatchStart.cs │ │ │ ├── LogPlayerKill.cs │ │ │ └── LogPlayerKillV2.cs │ │ ├── PubgCommonTelemetry.cs │ │ ├── PubgItemPackage.cs │ │ ├── Enums │ │ │ ├── PubgAttackType.cs │ │ │ ├── PubgVehicleType.cs │ │ │ ├── PubgItemCategory.cs │ │ │ ├── PubgDamageReason.cs │ │ │ └── PubgItemSubCategory.cs │ │ ├── PubgAsset.cs │ │ ├── PubgVehicle.cs │ │ ├── PubgGameResult.cs │ │ ├── PubgItem.cs │ │ ├── PubgTelemetryStats.cs │ │ ├── DamageInfo.cs │ │ ├── PubgCharacter.cs │ │ ├── PubgBlueZoneConfig.cs │ │ └── PubgGameState.cs │ ├── Masteries │ │ ├── WeaponMastery.cs │ │ ├── SurvivalMastery.cs │ │ └── WeaponSummary.cs │ ├── LifetimeStats │ │ ├── LifetimeStats.cs │ │ └── GameModeStat.cs │ ├── Status │ │ ├── PubgStatus.cs │ │ └── PubgStatusAttributes.cs │ ├── Rosters │ │ ├── PubgRosterStats.cs │ │ └── PubgRoster.cs │ ├── Errors │ │ ├── PubgErrorSource.cs │ │ └── PubgError.cs │ ├── Participants │ │ ├── PubgParticipant.cs │ │ └── PubgParticipantDeathType.cs │ ├── Leaderboard │ │ ├── PubgLeaderboard.cs │ │ ├── PubgLeaderboardPlayer.cs │ │ └── PubgLeaderboardStats.cs │ ├── Seasons │ │ ├── PubgSeason.cs │ │ └── PubgSeasonState.cs │ ├── Tournaments │ │ └── PubgTournament.cs │ ├── Common │ │ ├── PubgPlatform.cs │ │ └── PubgRegion.cs │ ├── Samples │ │ └── PubgMatchSample.cs │ ├── Stats │ │ ├── PubgStatEntity.cs │ │ ├── PubgSeasonStats.cs │ │ ├── PubgRankPointsTitle.cs │ │ ├── PubgParticipantStats.cs │ │ └── PubgGameModeStats.cs │ └── Players │ │ ├── PubgPlayer.cs │ │ └── PubgPlayerSeason.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Infrastructure │ ├── Parsers │ │ ├── IParser.cs │ │ ├── ArrayParser.cs │ │ ├── EnumParser.cs │ │ └── DateTimeParser.cs │ ├── Attributes │ │ └── DefaultEnumMemberAttribute.cs │ ├── ErrorMapper.cs │ ├── JsonConverters │ │ ├── StringifiedArrayConverter.cs │ │ ├── PropertyBasedConverter.cs │ │ ├── DefaultValueStringEnumConverter.cs │ │ ├── PubgTelemetryConverter.cs │ │ └── RelationshipIdConverter.cs │ ├── RequestBuilder.cs │ └── HttpRequestor.cs │ ├── Configuration │ ├── PubgApiSettings.cs │ └── PubgApiConfiguration.cs │ ├── Services │ ├── PubgRequest.cs │ ├── Samples │ │ ├── GetSamplesRequest.cs │ │ └── PubgSamplesService.cs │ ├── Players │ │ ├── GetPubgPlayersRequest.cs │ │ └── PubgPlayerService.cs │ ├── PubgService.cs │ ├── Status │ │ └── PubgStatusService.cs │ ├── Masteries │ │ └── PubgMasteriesService.cs │ ├── Telemetry │ │ └── PubgTelemetryService.cs │ ├── LifetimeStats │ │ └── PubgLifetimeStatsService.cs │ ├── Leaderboard │ │ └── PubgLeaderboardService.cs │ ├── Tournaments │ │ └── PubgTournamentService.cs │ ├── Matches │ │ └── PubgMatchService.cs │ └── Seasons │ │ └── PubgSeasonService.cs │ ├── Extensions │ └── EnumExtensions.cs │ ├── Exceptions │ ├── PubgNotFoundException.cs │ ├── PubgUnauthorizedException.cs │ ├── PubgContentTypeException.cs │ ├── PubgTooManyRequestsException.cs │ └── PubgException.cs │ ├── pubg-dotnet.csproj │ └── Values │ └── Api.cs ├── test ├── pubg-dotnet.Tests │ ├── TestBase.cs │ ├── Extensions │ │ └── PubgRegionExtensions.cs │ ├── Status │ │ └── StatusTests.cs │ ├── LifetimeStats │ │ └── LifetimeStatsTest.cs │ ├── pubg-dotnet.Tests.csproj │ ├── Seasons │ │ └── SeasonsTests.cs │ ├── Masteries │ │ └── MasteriesTest.cs │ ├── Leaderboard │ │ └── LeaderboardServiceTests.cs │ ├── Tournaments │ │ └── TournamentsTests.cs │ ├── Samples │ │ └── MatchSamplesTests.cs │ ├── Telemetry │ │ └── TelemetryTests.cs │ ├── Matches │ │ └── MatchTests.cs │ ├── Util │ │ └── Storage.cs │ └── Players │ │ └── PlayerTests.cs └── pubg-dotnet.UnitTests │ ├── pubg-dotnet.UnitTests.csproj │ ├── ErrorMapping │ └── ErrorMappingTests.cs │ ├── JsonConverters │ ├── DefaultEnumConverterTests.cs │ ├── TelemetryConverterTests.cs │ └── RelationshipIdConverterTests.cs │ └── HttpRequestors │ └── HttpRequestorTests.cs ├── LICENSE ├── appveyor.yml ├── pubg-dotnet.sln ├── README.md └── .gitignore /src/pubg-dotnet/Models/Match/PubgRound.cs: -------------------------------------------------------------------------------- 1 | namespace Pubg.Net 2 | { 3 | public class PubgRound 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Match/PubgSpectator.cs: -------------------------------------------------------------------------------- 1 | namespace Pubg.Net 2 | { 3 | public class PubgSpectator 4 | { 5 | //Incomplete Docs 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Match/PubgTeam.cs: -------------------------------------------------------------------------------- 1 | namespace Pubg.Net 2 | { 3 | public class PubgTeam 4 | { 5 | //TODO: Revisit when docs are more complete 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Match/PubgMatchStats.cs: -------------------------------------------------------------------------------- 1 | namespace Pubg.Net 2 | { 3 | public class PubgMatchStats 4 | { 5 | //Review when documentation improves 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("pubg-dotnet.Tests")] 4 | [assembly: InternalsVisibleTo("pubg-dotnet.UnitTests")] 5 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Base/PubgEntity.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Base 4 | { 5 | public abstract class PubgEntity 6 | { 7 | [JsonProperty] 8 | public string Id { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Location.cs: -------------------------------------------------------------------------------- 1 | namespace Pubg.Net 2 | { 3 | public class Location 4 | { 5 | public float X { get; set; } 6 | public float Y { get; set; } 7 | public float Z { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogPlayerLogout.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogPlayerLogout : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public string AccountId { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Base/PubgShardedEntity.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Base 4 | { 5 | public abstract class PubgShardedEntity : PubgEntity 6 | { 7 | [JsonProperty] 8 | public string ShardId { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogPlayerCreate.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogPlayerCreate : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Masteries/WeaponMastery.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Pubg.Net.Models.Base; 3 | 4 | namespace Pubg.Net.Models.Masteries; 5 | 6 | public class WeaponMastery : PubgShardedEntity 7 | { 8 | public Dictionary WeaponSummaries { get; set; } 9 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogCarePackageLand.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogCarePackageLand : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgItemPackage ItemPackage { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogGameStatePeriodic.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogGameStatePeriodic : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgGameState GameState { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/LifetimeStats/LifetimeStats.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Pubg.Net.Models.Base; 3 | 4 | namespace Pubg.Net.Models.LifetimeStats; 5 | 6 | public class LifetimeStats : PubgEntity 7 | { 8 | public Dictionary GameModeStats { get; set; } 9 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Status/PubgStatus.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Base; 3 | 4 | namespace Pubg.Net 5 | { 6 | public class PubgStatus : PubgEntity 7 | { 8 | [JsonProperty] 9 | public PubgStatusAttributes Attributes { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogCarePackageSpawn.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogCarePackageSpawn : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgItemPackage ItemPackage { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogSwimStart.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogSwimStart : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogVaultStart.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogVaultStart : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogRedZoneEnded.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogRedZoneEnded : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter[] Drivers { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/Parsers/IParser.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Pubg.Net.Infrastructure.Parsers 4 | { 5 | public interface IParser 6 | { 7 | bool CanParse(PropertyInfo prop, object propValue); 8 | string Parse(PropertyInfo prop, object propValue); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Rosters/PubgRosterStats.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class PubgRosterStats 6 | { 7 | [JsonProperty] 8 | public int Rank { get; set; } 9 | 10 | [JsonProperty] 11 | public int TeamId { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Configuration/PubgApiSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Pubg.Net.Configuration 4 | { 5 | public class PubgApiSettings 6 | { 7 | public string ApiKey { get; set; } 8 | public string ApiBaseUrl { get; set; } 9 | public TimeSpan? HttpTimeout { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/Attributes/DefaultEnumMemberAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Pubg.Net.Infrastructure.Attributes 4 | { 5 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)] 6 | public sealed class DefaultEnumMemberAttribute : Attribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogMatchEnd.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System.Collections.Generic; 3 | 4 | namespace Pubg.Net 5 | { 6 | public class LogMatchEnd : PubgTelemetryEvent 7 | { 8 | [JsonProperty] 9 | public IEnumerable Characters { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Errors/PubgErrorSource.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Errors 4 | { 5 | public class PubgErrorSource 6 | { 7 | [JsonProperty] 8 | public string Pointer { get; set; } 9 | 10 | [JsonProperty] 11 | public string Parameter { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Status/PubgStatusAttributes.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class PubgStatusAttributes 6 | { 7 | [JsonProperty] 8 | public string ReleasedAt { get; set; } 9 | 10 | [JsonProperty] 11 | public string Version { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogPhaseChange.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events; 4 | 5 | public class LogPhaseChange : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public int Phase { get; set; } 9 | 10 | [JsonProperty] 11 | public double ElapsedTime { get; set; } 12 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/PubgRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Pubg.Net.Services 2 | { 3 | public abstract class PubgRequest 4 | { 5 | /// 6 | /// Use for setting the ApiKey per request, not needed if you've set it elsewhere 7 | /// 8 | public string ApiKey { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Extensions/EnumExtensions.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | 4 | namespace Pubg.Net.Extensions 5 | { 6 | public static class EnumExtensions 7 | { 8 | public static string Serialize(this Enum e) 9 | { 10 | return JsonConvert.SerializeObject(e).Trim('"'); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/Samples/GetSamplesRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Services; 3 | using System; 4 | 5 | namespace Pubg.Net 6 | { 7 | public class GetSamplesRequest : PubgRequest 8 | { 9 | [JsonProperty("filter[createdAt-start]")] 10 | public DateTime? CreatedAtStart { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogItemDrop.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogItemDrop : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgItem Item { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogItemUse.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogItemUse : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgItem Item { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogCharacterCarry.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events; 4 | 5 | public class LogCharacterCarry : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public string CarryState { get; set; } 12 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogItemEquip.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogItemEquip : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgItem Item { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogItemPickup.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogItemPickup : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgItem Item { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogItemUnequip.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogItemUnequip : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgItem Item { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogMatchDefinition.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogMatchDefinition : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public string MatchId { get; set; } 9 | 10 | [JsonProperty] 11 | public string PingQuality { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/TestBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace pubg.net.Tests 5 | { 6 | public class TestBase : IDisposable 7 | { 8 | public void Dispose() 9 | { 10 | //Dirty hack to get around the rate limit, remove ASAP 11 | Task.Delay(30000).GetAwaiter().GetResult(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Participants/PubgParticipant.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Base; 3 | 4 | namespace Pubg.Net 5 | { 6 | public class PubgParticipant : PubgShardedEntity 7 | { 8 | [JsonProperty] 9 | public PubgParticipantStats Stats { get; set; } 10 | 11 | [JsonProperty] 12 | public string Actor { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogParachuteLanding.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogParachuteLanding : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public float Distance { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogItemPickUpFromCarePackage.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogItemPickupFromCarePackage : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgItem Item { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Exceptions/PubgNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | 3 | namespace Pubg.Net.Exceptions 4 | { 5 | public class PubgNotFoundException : PubgException 6 | { 7 | private const string DefaultErrorMessage = "API returned 404. An entity with the specified ID was not found"; 8 | 9 | public PubgNotFoundException() : base(DefaultErrorMessage, HttpStatusCode.NotFound) { } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogObjectInteraction.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events; 4 | 5 | public class LogObjectInteraction : PubgTelemetryEvent 6 | { 7 | [JsonProperty] public PubgCharacter Character { get; set; } 8 | 9 | [JsonProperty] public string ObjectType { get; set; } 10 | 11 | [JsonProperty] public string ObjectTypeStatus { get; set; } 12 | 13 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/PubgCommonTelemetry.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry 4 | { 5 | public class PubgCommonTelemetry 6 | { 7 | [JsonProperty] 8 | public string MatchId { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgMap MapName { get; set; } 12 | 13 | [JsonProperty] 14 | public float IsGame { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogPlayerLogin.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogPlayerLogin : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public bool Result { get; set; } 9 | 10 | [JsonProperty] 11 | public string ErrorMessge { get; set; } 12 | 13 | [JsonProperty] 14 | public string AccountId { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/Players/GetPubgPlayersRequest.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Services; 3 | 4 | namespace Pubg.Net 5 | { 6 | public class GetPubgPlayersRequest : PubgRequest 7 | { 8 | [JsonProperty("filter[playerIds]")] 9 | public string[] PlayerIds { get; set; } 10 | 11 | [JsonProperty("filter[playerNames]")] 12 | public string[] PlayerNames { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogVehicleRide.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogVehicleRide : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgVehicle Vehicle { get; set; } 12 | 13 | [JsonProperty] 14 | public int SeatIndex { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Leaderboard/PubgLeaderboard.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Base; 3 | using System.Collections.Generic; 4 | 5 | namespace Pubg.Net 6 | { 7 | public class PubgLeaderboard : PubgShardedEntity 8 | { 9 | [JsonProperty] 10 | public PubgGameMode GameMode { get; set; } 11 | 12 | [JsonProperty] 13 | public IEnumerable Players { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogHeal.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogHeal: PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgItem Item { get; set; } 12 | 13 | [JsonProperty] 14 | public float HealAmount { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogItemAttach.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogItemAttach : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgItem ParentItem { get; set; } 12 | 13 | [JsonProperty] 14 | public PubgItem ChildItem { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogItemDetach.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogItemDetach : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgItem ParentItem { get; set; } 12 | 13 | [JsonProperty] 14 | public PubgItem ChildItem { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogPlayerRevive.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogPlayerRevive : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Reviver { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgCharacter Victim { get; set; } 12 | 13 | [JsonProperty] 14 | public int DBNOId { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/PubgItemPackage.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System.Collections.Generic; 3 | 4 | namespace Pubg.Net 5 | { 6 | public class PubgItemPackage 7 | { 8 | [JsonProperty] 9 | public string ItemPackageId { get; set; } 10 | 11 | [JsonProperty] 12 | public Location Location { get; set; } 13 | 14 | [JsonProperty] 15 | public IEnumerable Items { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/Extensions/PubgRegionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Pubg.Net; 2 | using Pubg.Net.Extensions; 3 | 4 | namespace pubg.net.Tests.Extensions 5 | { 6 | public static class PubgRegionExtensions 7 | { 8 | public static bool IsPC(this PubgRegion region) => region.Serialize().ToLowerInvariant().Contains("pc"); 9 | public static bool IsXbox(this PubgRegion region) => region.Serialize().ToLowerInvariant().Contains("xbox"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogSwimEnd.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogSwimEnd : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public float SwimDistance { get; set; } 12 | 13 | [JsonProperty] 14 | public float MaxSwimDeptOfWater { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Leaderboard/PubgLeaderboardPlayer.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Base; 3 | 4 | namespace Pubg.Net 5 | { 6 | public class PubgLeaderboardPlayer : PubgShardedEntity 7 | { 8 | [JsonProperty] 9 | public string Name { get; set; } 10 | 11 | [JsonProperty] 12 | public int Rank { get; set; } 13 | 14 | [JsonProperty] 15 | public PubgLeaderboardStats Stats { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogWeaponFireCount.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogWeaponFireCount : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public string WeaponId { get; set; } 12 | 13 | [JsonProperty] 14 | public int FireCount { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Enums/PubgAttackType.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.JsonConverters; 3 | using System.Runtime.Serialization; 4 | 5 | namespace Pubg.Net.Models.Telemetry.Enums 6 | { 7 | [JsonConverter(typeof(DefaultValueStringEnumConverter))] 8 | public enum PubgAttackType 9 | { 10 | [EnumMember(Value = "RedZone")] 11 | RedZone, 12 | [EnumMember(Value = "Weapon")] 13 | Weapon 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogObjectDestroy.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogObjectDestroy : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public string ObjectType { get; set; } 12 | 13 | [JsonProperty] 14 | public Location ObjectLocation { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogItemPickupFromLootBox.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogItemPickupFromLootBox : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgItem Item { get; set; } 12 | 13 | [JsonProperty] 14 | public int OwnerTeamId { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/PubgService.cs: -------------------------------------------------------------------------------- 1 | namespace Pubg.Net.Services 2 | { 3 | public abstract class PubgService 4 | { 5 | public string ApiKey { get; set; } 6 | 7 | protected const string ResponseRootNode = "data"; 8 | 9 | protected PubgService(string apiKey = null) 10 | { 11 | if (string.IsNullOrEmpty(apiKey)) 12 | apiKey = PubgApiConfiguration.GetApiKey(); 13 | 14 | ApiKey = apiKey; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Seasons/PubgSeason.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Base; 3 | using System.Collections.Generic; 4 | 5 | namespace Pubg.Net 6 | { 7 | public class PubgSeason : PubgEntity 8 | { 9 | [JsonProperty] 10 | public bool IsCurrentSeason { get; set; } 11 | 12 | [JsonProperty] 13 | public bool IsOffseason { get; set; } 14 | 15 | [JsonProperty] 16 | public Dictionary Links { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Rosters/PubgRoster.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Base; 3 | using System.Collections.Generic; 4 | 5 | namespace Pubg.Net 6 | { 7 | public class PubgRoster : PubgShardedEntity 8 | { 9 | [JsonProperty] 10 | public PubgRosterStats Stats { get; set; } 11 | 12 | [JsonProperty] 13 | public bool Won { get; set; } 14 | 15 | [JsonProperty] 16 | public IEnumerable Participants { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/Status/StatusTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using Pubg.Net.Tests.Util; 3 | using Pubg.Net; 4 | using Xunit; 5 | using pubg.net.Tests; 6 | 7 | namespace Pubg.Net.Tests.Status 8 | { 9 | public class StatusTests : TestBase 10 | { 11 | [Fact] 12 | public void Can_Retrieve_Status() 13 | { 14 | var status = new PubgStatusService(Storage.ApiKey).GetStatus(); 15 | status.Id.Should().NotBeNullOrWhiteSpace(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/Parsers/ArrayParser.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Linq; 3 | using System.Reflection; 4 | 5 | namespace Pubg.Net.Infrastructure.Parsers 6 | { 7 | internal class ArrayParser : IParser 8 | { 9 | public bool CanParse(PropertyInfo prop, object propValue) => prop.PropertyType.IsArray; 10 | 11 | public string Parse(PropertyInfo prop, object propValue) => ((IEnumerable)propValue).Cast().Select(x => x.ToString()).Aggregate((x,y) => x + "," + y); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogPlayerPosition.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogPlayerPosition : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public float ElapsedTime { get; set; } 12 | 13 | [JsonProperty] 14 | public int NumAlivePlayers { get; set; } 15 | 16 | [JsonProperty] 17 | public PubgVehicle Vehicle { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/PubgAsset.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Base; 3 | using System; 4 | 5 | namespace Pubg.Net 6 | { 7 | public class PubgAsset : PubgEntity 8 | { 9 | [JsonProperty] 10 | public DateTime CreatedAt { get; set; } 11 | 12 | [JsonProperty] 13 | public string Url { get; set; } 14 | 15 | [JsonProperty] 16 | public string Description { get; set; } 17 | 18 | [JsonProperty] 19 | public string Name { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Tournaments/PubgTournament.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.JsonConverters; 3 | using Pubg.Net.Models.Base; 4 | using System.Collections.Generic; 5 | 6 | namespace Pubg.Net 7 | { 8 | public class PubgTournament : PubgEntity 9 | { 10 | [JsonProperty] 11 | public string Type { get; set; } 12 | 13 | [JsonProperty("matches")] 14 | [JsonConverter(typeof(RelationshipIdConverter))] 15 | public IEnumerable MatchIds { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/PubgVehicle.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Telemetry.Enums; 3 | 4 | namespace Pubg.Net 5 | { 6 | public class PubgVehicle 7 | { 8 | [JsonProperty] 9 | public PubgVehicleType VehicleType { get; set; } 10 | 11 | [JsonProperty] 12 | public string VehicleId { get; set; } 13 | 14 | [JsonProperty] 15 | public float HealthPercent { get; set; } 16 | 17 | [JsonProperty] 18 | public float FeulPercent { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Common/PubgPlatform.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | using System.Runtime.Serialization; 5 | 6 | namespace Pubg.Net 7 | { 8 | [JsonConverter(typeof(StringEnumConverter))] 9 | public enum PubgPlatform 10 | { 11 | [EnumMember(Value = "steam")] 12 | Steam, 13 | [EnumMember(Value = "kakao")] 14 | Kakao, 15 | [EnumMember(Value = "tournament")] 16 | Tournament, 17 | [EnumMember(Value = "console")] 18 | Console 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/PubgGameResult.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry 4 | { 5 | public class PubgGameResult 6 | { 7 | [JsonProperty] 8 | public int Rank { get; set; } 9 | 10 | [JsonProperty] 11 | public string GameResult { get; set; } 12 | 13 | [JsonProperty] 14 | public int TeamId { get; set; } 15 | 16 | [JsonProperty] 17 | public PubgTelemetryStats Stats { get; set; } 18 | 19 | [JsonProperty] 20 | public string AccountId { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Exceptions/PubgUnauthorizedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Pubg.Net.Exceptions 4 | { 5 | public class PubgUnauthorizedException : PubgException 6 | { 7 | private const string DefaultErrorMessage = "Api Key is invalid or missing!"; 8 | 9 | public PubgUnauthorizedException() : base(DefaultErrorMessage) { } 10 | public PubgUnauthorizedException(string errorMessage) : base(errorMessage) { } 11 | public PubgUnauthorizedException(string errorMessage, Exception innerException) : base(errorMessage, innerException) { } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Exceptions/PubgContentTypeException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Pubg.Net.Exceptions 4 | { 5 | public class PubgContentTypeException : PubgException 6 | { 7 | private const string DefaultErrorMessage = "Content type is unsupported or not specified"; 8 | 9 | public PubgContentTypeException() : base(DefaultErrorMessage) { } 10 | public PubgContentTypeException(string errorMessage) : base(errorMessage) { } 11 | public PubgContentTypeException(string errorMessage, Exception innerException) : base(errorMessage, innerException) { } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogPlayerUseThrowable.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events; 4 | 5 | public class LogPlayerUseThrowable : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public int AttackId { get; set; } 9 | 10 | [JsonProperty] 11 | public int FireWeaponStackCount { get; set; } 12 | 13 | [JsonProperty] 14 | public PubgCharacter Attacker { get; set; } 15 | 16 | [JsonProperty] 17 | public string AttackType { get; set; } 18 | 19 | [JsonProperty] 20 | public PubgItem Weapon { get; set; } 21 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogVehicleLeave.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogVehicleLeave : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public PubgCharacter Character { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgVehicle Vehicle { get; set; } 12 | 13 | [JsonProperty] 14 | public float RideDistance { get; set; } 15 | 16 | [JsonProperty] 17 | public int SeatIndex { get; set; } 18 | 19 | [JsonProperty] 20 | public float MaxSpeed { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Errors/PubgError.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Base; 3 | 4 | namespace Pubg.Net.Models.Errors 5 | { 6 | public class PubgError : PubgEntity 7 | { 8 | [JsonProperty] 9 | public string Status { get; set; } 10 | 11 | [JsonProperty] 12 | public string Code { get; set; } 13 | 14 | [JsonProperty] 15 | public string Title { get; set; } 16 | 17 | [JsonProperty] 18 | public string Detail { get; set; } 19 | 20 | [JsonProperty] 21 | public PubgErrorSource Source { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Seasons/PubgSeasonState.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.Attributes; 3 | using Pubg.Net.Infrastructure.JsonConverters; 4 | using System.Runtime.Serialization; 5 | 6 | namespace Pubg.Net.Models.Seasons 7 | { 8 | [JsonConverter(typeof(DefaultValueStringEnumConverter))] 9 | public enum PubgSeasonState 10 | { 11 | [DefaultEnumMember] 12 | Unknown, 13 | [EnumMember(Value = "closed")] 14 | Closed, 15 | [EnumMember(Value = "prepare")] 16 | Prepare, 17 | [EnumMember(Value = "progress")] 18 | Progress 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/PubgItem.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Telemetry.Enums; 3 | 4 | namespace Pubg.Net 5 | { 6 | public class PubgItem 7 | { 8 | [JsonProperty] 9 | public string ItemId { get; set; } 10 | 11 | [JsonProperty] 12 | public int StackCount { get; set; } 13 | 14 | [JsonProperty] 15 | public PubgItemCategory Category { get; set; } 16 | 17 | [JsonProperty] 18 | public PubgItemSubCategory SubCategory { get; set; } 19 | 20 | [JsonProperty] 21 | public string[] AttachedItems { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogWheelDestroy.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogWheelDestroy : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public int AttackId { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgCharacter Attacker { get; set; } 12 | 13 | [JsonProperty] 14 | public PubgVehicle Vehicle { get; set; } 15 | 16 | [JsonProperty] 17 | public string DamageTypeCategory { get; set; } 18 | 19 | [JsonProperty] 20 | public string DamageCauserName { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Participants/PubgParticipantDeathType.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | using System.Runtime.Serialization; 4 | 5 | namespace Pubg.Net.Models.Participants 6 | { 7 | [JsonConverter(typeof(StringEnumConverter))] 8 | public enum PubgParticipantDeathType 9 | { 10 | [EnumMember(Value = "alive")] 11 | Alive, 12 | [EnumMember(Value = "byplayer")] 13 | ByPlayer, 14 | [EnumMember(Value = "byzone")] 15 | ByZone, 16 | [EnumMember(Value = "suicide")] 17 | Suicide, 18 | [EnumMember(Value = "logout")] 19 | Logout 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Samples/PubgMatchSample.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.JsonConverters; 3 | using Pubg.Net.Models.Base; 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Pubg.Net.Models.Samples 8 | { 9 | public class PubgMatchSample : PubgShardedEntity 10 | { 11 | [JsonProperty] 12 | public DateTime CreatedAt { get; set; } 13 | 14 | [JsonProperty] 15 | public string TitleId { get; set; } 16 | 17 | [JsonProperty("matches")] 18 | [JsonConverter(typeof(RelationshipIdConverter))] 19 | public IEnumerable MatchIds { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Stats/PubgStatEntity.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.JsonConverters; 3 | using Pubg.Net.Models.Base; 4 | using Pubg.Net.Models.Stats; 5 | 6 | namespace Pubg.Net 7 | { 8 | public class PubgStatEntity : PubgEntity 9 | { 10 | [JsonProperty] 11 | public PubgSeasonStats GameModeStats { get; set; } 12 | 13 | [JsonProperty("player")] 14 | [JsonConverter(typeof(RelationshipIdConverter))] 15 | public string PlayerId { get; set; } 16 | 17 | [JsonProperty("season")] 18 | [JsonConverter(typeof(RelationshipIdConverter))] 19 | public string SeasonId { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/PubgTelemetryEvent.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.JsonConverters; 3 | using Pubg.Net.Models.Telemetry; 4 | using System; 5 | 6 | namespace Pubg.Net 7 | { 8 | [JsonConverter(typeof(PubgTelemetryConverter))] 9 | public class PubgTelemetryEvent 10 | { 11 | [JsonProperty("_V")] 12 | public string Version { get; set; } 13 | 14 | [JsonProperty("_D")] 15 | public DateTime Timestamp { get; set; } 16 | 17 | [JsonProperty("_T")] 18 | public string Type { get; set; } 19 | 20 | [JsonProperty] 21 | public PubgCommonTelemetry Common { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/LifetimeStats/LifetimeStatsTest.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Pubg.Net; 3 | using Pubg.Net.Services.LifetimeStats; 4 | using Pubg.Net.Tests.Util; 5 | using Xunit; 6 | 7 | namespace pubg.net.Tests.LifetimeStats; 8 | 9 | public class LifetimeStatsTest : TestBase 10 | { 11 | [Fact] 12 | public void Can_RetrieveLifetimeStats() 13 | { 14 | var samples = Storage.GetPlayer(PubgPlatform.Steam); 15 | var lifetimeStatsService = new PubgLifetimeStatsService(Storage.ApiKey); 16 | 17 | var stats = lifetimeStatsService.GetLifetimeStats(PubgPlatform.Steam, samples.Id); 18 | 19 | Assert.True(stats.GameModeStats.Values.All(s => s != null)); 20 | } 21 | } -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/pubg-dotnet.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | pubg.net.Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogVehicleDestroy.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class LogVehicleDestroy : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public int AttackId { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgCharacter Attacker { get; set; } 12 | 13 | [JsonProperty] 14 | public PubgVehicle Vehicle { get; set; } 15 | 16 | [JsonProperty] 17 | public string DamageTypeCategory { get; set; } 18 | 19 | [JsonProperty] 20 | public string DamageCauserName { get; set; } 21 | 22 | [JsonProperty] 23 | public float Distance { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/PubgTelemetryStats.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry 4 | { 5 | public class PubgTelemetryStats 6 | { 7 | [JsonProperty] 8 | public int KillCount { get; set; } 9 | 10 | [JsonProperty] 11 | public float DistanceOnFoot { get; set; } 12 | 13 | [JsonProperty] 14 | public float DistanceOnSwim { get; set; } 15 | 16 | [JsonProperty] 17 | public float DistanceOnVehicle { get; set; } 18 | 19 | [JsonProperty] 20 | public float DistanceOnParachute { get; set; } 21 | 22 | [JsonProperty] 23 | public float DistanceOnFreefall { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/DamageInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Pubg.Net.Models.Base; 4 | 5 | namespace Pubg.Net.Models.Telemetry; 6 | 7 | public class DamageInfo : PubgEntity 8 | { 9 | [JsonProperty] 10 | public string DamageReason { get; set; } 11 | 12 | [JsonProperty] 13 | public string DamageTypeCategory { get; set; } 14 | 15 | [JsonProperty] 16 | public string DamageCauserName { get; set; } 17 | 18 | [JsonProperty] 19 | public List AdditionalInfo { get; set; } 20 | 21 | [JsonProperty] 22 | public double Distance { get; set; } 23 | 24 | [JsonProperty] 25 | public bool IsThroughPenetrableWall { get; set; } 26 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Masteries/SurvivalMastery.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Pubg.Net.Models.Base; 3 | 4 | namespace Pubg.Net.Models.Masteries; 5 | 6 | public class SurvivalMastery : PubgEntity 7 | { 8 | public int Xp { get; set; } 9 | public int Tier { get; set; } 10 | public int Level { get; set; } 11 | public int TotalMatchesPlayed { get; set; } 12 | public string LatestMatchId { get; set; } 13 | public Dictionary Stats { get; set; } 14 | } 15 | 16 | public class Stat 17 | { 18 | public string Statid { get; set; } 19 | public int Total { get; set; } 20 | public int Average { get; set; } 21 | public int CareerBest { get; set; } 22 | public int LastMatchValue { get; set; } 23 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Stats/PubgSeasonStats.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Stats 4 | { 5 | public class PubgSeasonStats 6 | { 7 | [JsonProperty] 8 | public PubgGameModeStats Duo { get; set; } 9 | 10 | [JsonProperty("duo-fpp")] 11 | public PubgGameModeStats DuoFPP { get; set; } 12 | 13 | [JsonProperty] 14 | public PubgGameModeStats Solo { get; set; } 15 | 16 | [JsonProperty("solo-fpp")] 17 | public PubgGameModeStats SoloFPP { get; set; } 18 | 19 | [JsonProperty] 20 | public PubgGameModeStats Squad { get; set; } 21 | 22 | [JsonProperty("squad-fpp")] 23 | public PubgGameModeStats SquadFPP { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Exceptions/PubgTooManyRequestsException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | 4 | namespace Pubg.Net.Exceptions 5 | { 6 | public class PubgTooManyRequestsException : PubgException 7 | { 8 | public const string DefaultErrorMessage = "You have surpassed your Rate Limit"; 9 | public string TimeUntilReset { get; set; } 10 | 11 | public PubgTooManyRequestsException(string timeUntilReset) : base (DefaultErrorMessage, (HttpStatusCode) 429) 12 | { 13 | TimeUntilReset = timeUntilReset; 14 | } 15 | 16 | public PubgTooManyRequestsException(string errorMessage, Exception innerException) : base(errorMessage, innerException) 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogPlayerAttack.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Telemetry.Enums; 3 | 4 | namespace Pubg.Net 5 | { 6 | public class LogPlayerAttack : PubgTelemetryEvent 7 | { 8 | [JsonProperty] 9 | public int AttackId { get; set; } 10 | 11 | [JsonProperty] 12 | public PubgCharacter Attacker { get; set; } 13 | 14 | [JsonProperty] 15 | public PubgAttackType AttackType { get; set; } 16 | 17 | [JsonProperty] 18 | public int FireWeaponStackCount { get; set; } 19 | 20 | [JsonProperty] 21 | public PubgItem Weapon { get; set; } 22 | 23 | [JsonProperty] 24 | public PubgVehicle Vehicle { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogVehicleDamage.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events; 4 | 5 | public class LogVehicleDamage : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public int AttackId { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgCharacter Attacker { get; set; } 12 | 13 | [JsonProperty] 14 | public PubgVehicle Vehicle { get; set; } 15 | 16 | [JsonProperty] 17 | public string DamageTypeCategory { get; set; } 18 | 19 | [JsonProperty] 20 | public string DamageCauserName { get; set; } 21 | 22 | [JsonProperty] 23 | public double Damage { get; set; } 24 | 25 | [JsonProperty] 26 | public double Distance { get; set; } 27 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Enums/PubgVehicleType.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.Attributes; 3 | using Pubg.Net.Infrastructure.JsonConverters; 4 | using System.Runtime.Serialization; 5 | 6 | namespace Pubg.Net.Models.Telemetry.Enums 7 | { 8 | [JsonConverter(typeof(DefaultValueStringEnumConverter))] 9 | public enum PubgVehicleType 10 | { 11 | [DefaultEnumMember] 12 | None, 13 | [EnumMember( Value ="FloatingVehicle")] 14 | FloatingVehicle, 15 | [EnumMember( Value ="Parachute")] 16 | Parachute, 17 | [EnumMember( Value ="TransportAircraft")] 18 | TransportAircraft, 19 | [EnumMember( Value ="WheeledVehicle")] 20 | WheeledVehicle 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/Parsers/EnumParser.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Reflection; 4 | 5 | namespace Pubg.Net.Infrastructure.Parsers 6 | { 7 | public class EnumParser : IParser 8 | { 9 | public bool CanParse(PropertyInfo prop, object propValue) 10 | { 11 | var type = prop.PropertyType; 12 | 13 | if (type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) 14 | { 15 | type = Nullable.GetUnderlyingType(type); 16 | } 17 | 18 | return type.GetTypeInfo().IsEnum; 19 | } 20 | 21 | public string Parse(PropertyInfo prop, object propValue) => JsonConvert.SerializeObject(propValue).Trim('"'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Enums/PubgItemCategory.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.Attributes; 3 | using Pubg.Net.Infrastructure.JsonConverters; 4 | using System.Runtime.Serialization; 5 | 6 | namespace Pubg.Net.Models.Telemetry.Enums 7 | { 8 | [JsonConverter(typeof(DefaultValueStringEnumConverter))] 9 | public enum PubgItemCategory 10 | { 11 | [DefaultEnumMember] 12 | NotSpecified, 13 | [EnumMember(Value ="Ammunition")] 14 | Ammunition, 15 | [EnumMember(Value ="Attachment")] 16 | Attachment, 17 | [EnumMember(Value ="Equipment")] 18 | Equipment, 19 | [EnumMember(Value ="Use")] 20 | Use, 21 | [EnumMember(Value ="Weapon")] 22 | Weapon 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/UnknownTelemetryEvent.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | /// 6 | /// Generic object for when the library can't identify an event 7 | /// RawContent contains the serialized json, used for graceful failure. 8 | /// 9 | public class UnknownTelemetryEvent : PubgTelemetryEvent 10 | { 11 | public string ErrorMessage => "Unable to identify telemetry event, please create an issue at https://www.github.com/GavinPower747/Pubg-Dotnet/issues"; 12 | public string RawContent { get; set; } 13 | 14 | public UnknownTelemetryEvent(JObject json) 15 | { 16 | RawContent = json.ToString(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/Parsers/DateTimeParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Pubg.Net.Infrastructure.Parsers 5 | { 6 | internal class DateTimeParser : IParser 7 | { 8 | public bool CanParse(PropertyInfo prop, object propValue) 9 | { 10 | var type = prop.PropertyType; 11 | 12 | if (type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) 13 | { 14 | type = Nullable.GetUnderlyingType(type); 15 | } 16 | 17 | return type == typeof(DateTime); 18 | } 19 | 20 | //ISO8601 as specified in docs 21 | public string Parse(PropertyInfo prop, object propValue) => ((DateTime)propValue).ToString("o"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Leaderboard/PubgLeaderboardStats.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class PubgLeaderboardStats 6 | { 7 | [JsonProperty] 8 | public int AverageDamage { get; set; } 9 | 10 | [JsonProperty] 11 | public float AverageRank { get; set; } 12 | 13 | [JsonProperty] 14 | public int Games { get; set; } 15 | 16 | [JsonProperty] 17 | public int Kills { get; set; } 18 | 19 | [JsonProperty] 20 | public float KillDeathRatio { get; set; } 21 | 22 | [JsonProperty] 23 | public float RankPoints { get; set; } 24 | 25 | [JsonProperty] 26 | public float WinRatio { get; set; } 27 | 28 | [JsonProperty] 29 | public int Wins { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogPlayerTakeDamage.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Telemetry.Enums; 3 | 4 | namespace Pubg.Net 5 | { 6 | public class LogPlayerTakeDamage : PubgTelemetryEvent 7 | { 8 | [JsonProperty] 9 | public int AttackId { get; set; } 10 | 11 | [JsonProperty] 12 | public PubgCharacter Attacker { get; set; } 13 | 14 | [JsonProperty] 15 | public PubgCharacter Victim { get; set; } 16 | 17 | [JsonProperty] 18 | public string DamageTypeCategory { get; set; } 19 | 20 | [JsonProperty] 21 | public PubgDamageReason DamageReason { get; set; } 22 | 23 | [JsonProperty] 24 | public float Damage { get; set; } 25 | 26 | [JsonProperty] 27 | public string DamageCauserName { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/PubgCharacter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class PubgCharacter 6 | { 7 | [JsonProperty] 8 | public string Name { get; set; } 9 | 10 | [JsonProperty] 11 | public int TeamId { get; set; } 12 | 13 | [JsonProperty] 14 | public float Health { get; set; } 15 | 16 | [JsonProperty] 17 | public Location Location { get; set; } 18 | 19 | [JsonProperty] 20 | public int Ranking { get; set; } 21 | 22 | [JsonProperty] 23 | public string AccountId { get; set; } 24 | 25 | [JsonProperty] 26 | public bool IsInRedZone { get; set; } 27 | 28 | [JsonProperty] 29 | public bool IsInBlueZone { get; set; } 30 | 31 | [JsonProperty] 32 | public string[] Zone { get; set; } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Enums/PubgDamageReason.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.Attributes; 3 | using Pubg.Net.Infrastructure.JsonConverters; 4 | using System.Runtime.Serialization; 5 | 6 | namespace Pubg.Net.Models.Telemetry.Enums 7 | { 8 | [JsonConverter(typeof(DefaultValueStringEnumConverter))] 9 | public enum PubgDamageReason 10 | { 11 | [EnumMember(Value ="None")] 12 | [DefaultEnumMember] 13 | None, 14 | [EnumMember(Value ="NonSpecific")] 15 | NonSpecific, 16 | [EnumMember(Value = "ArmShot")] 17 | ArmShot, 18 | [EnumMember(Value ="HeadShot")] 19 | HeadShot, 20 | [EnumMember(Value ="LegShot")] 21 | LegShot, 22 | [EnumMember(Value ="PelvisShot")] 23 | PelvisShot, 24 | [EnumMember(Value ="TorsoShot")] 25 | TorsoShot 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/ErrorMapper.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using Pubg.Net.Models.Errors; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace Pubg.Net.Infrastructure 8 | { 9 | internal static class ErrorMapper 10 | { 11 | public static List MapErrors(string json) 12 | { 13 | var jObject = JObject.Parse(json); 14 | var collection = jObject.SelectToken("errors"); 15 | 16 | return collection.Select(objJson => MapError(objJson.ToString())).ToList(); 17 | } 18 | 19 | private static PubgError MapError(string json) 20 | { 21 | var objectJson = JObject.Parse(json).ToString(); 22 | 23 | var serializedObject = JsonConvert.DeserializeObject(objectJson); 24 | 25 | return serializedObject; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/pubg-dotnet.UnitTests/pubg-dotnet.UnitTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | Pubg.Net.UnitTests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/PubgBlueZoneConfig.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry 4 | { 5 | public class PubgBlueZoneConfig 6 | { 7 | [JsonProperty] 8 | public int PhaseNum { get; set; } 9 | 10 | [JsonProperty] 11 | public int StartDelay { get; set; } 12 | 13 | [JsonProperty] 14 | public int WarningDuration { get; set; } 15 | 16 | [JsonProperty] 17 | public int ReleaseDuration { get; set; } 18 | 19 | [JsonProperty] 20 | public float PoisonGasDamagePerSecond { get; set; } 21 | 22 | [JsonProperty] 23 | public float RadiusRate { get; set; } 24 | 25 | [JsonProperty] 26 | public float SpreadRatio { get; set; } 27 | 28 | [JsonProperty] 29 | public float LandRatio { get; set; } 30 | 31 | [JsonProperty] 32 | public int CircleAlgorithm { get; set; } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/JsonConverters/StringifiedArrayConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | 6 | namespace Pubg.Net.Infrastructure.JsonConverters 7 | { 8 | //Don't ask because I don't know - Gav 9 | public class StringifiedArrayConverter : JsonConverter 10 | { 11 | public override bool CanConvert(Type objectType) => false; 12 | public override bool CanWrite => false; 13 | 14 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 15 | { 16 | JToken token = JToken.Load(reader); 17 | return JsonConvert.DeserializeObject>(token.ToString()); 18 | } 19 | 20 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogArmorDestroy.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Telemetry.Enums; 3 | 4 | namespace Pubg.Net.Models.Telemetry.Events 5 | { 6 | public class LogArmorDestroy : PubgTelemetryEvent 7 | { 8 | [JsonProperty] 9 | public int AttackId { get; set; } 10 | 11 | [JsonProperty] 12 | public PubgCharacter Attacker { get; set; } 13 | 14 | [JsonProperty] 15 | public PubgCharacter Victim { get; set; } 16 | 17 | [JsonProperty] 18 | public string DamageTypeCategory { get; set; } 19 | 20 | [JsonProperty] 21 | public PubgDamageReason DamageReason { get; set; } 22 | 23 | [JsonProperty] 24 | public string DamageCauserName { get; set; } 25 | 26 | [JsonProperty] 27 | public PubgItem Item { get; set; } 28 | 29 | [JsonProperty] 30 | public float Distance { get; set; } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Exceptions/PubgException.cs: -------------------------------------------------------------------------------- 1 | using Pubg.Net.Models.Errors; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Net; 6 | 7 | namespace Pubg.Net.Exceptions 8 | { 9 | public class PubgException : Exception 10 | { 11 | public HttpStatusCode HttpStatusCode { get; set; } 12 | public IEnumerable Errors { get; set; } 13 | 14 | public PubgException(string errorMessage) : base(errorMessage) { } 15 | public PubgException(string errorMessage, Exception innerException) : base(errorMessage, innerException) { } 16 | public PubgException(string errorMessage, HttpStatusCode statusCode) : base(errorMessage) { } 17 | public PubgException(string errorMessage, HttpStatusCode statusCode, IEnumerable apiErrors) : base(errorMessage) 18 | { 19 | HttpStatusCode = statusCode; 20 | Errors = apiErrors; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Stats/PubgRankPointsTitle.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.Attributes; 3 | using Pubg.Net.Infrastructure.JsonConverters; 4 | using System.Runtime.Serialization; 5 | 6 | namespace Pubg.Net.Models.Stats 7 | { 8 | [JsonConverter(typeof(DefaultValueStringEnumConverter))] 9 | public enum PubgRankPointsTitle 10 | { 11 | [DefaultEnumMember] 12 | Unknown, 13 | [EnumMember(Value = "BEGINNER")] 14 | Beginner, 15 | [EnumMember(Value = "NOVICE")] 16 | Novice, 17 | [EnumMember(Value = "EXPERIENCED")] 18 | Experienced, 19 | [EnumMember(Value = "SKILLED")] 20 | Skilled, 21 | [EnumMember(Value = "SPECIALIST")] 22 | Specialist, 23 | [EnumMember(Value = "EXPERT")] 24 | Expert, 25 | [EnumMember(Value = "SURVIVOR")] 26 | Survivor, 27 | [EnumMember(Value = "LONE SURVIVOR")] 28 | LoneSurvivor 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Players/PubgPlayer.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.JsonConverters; 3 | using Pubg.Net.Models.Base; 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Pubg.Net 8 | { 9 | public class PubgPlayer : PubgShardedEntity 10 | { 11 | [JsonProperty("Name")] 12 | public string Name { get; set; } 13 | 14 | [JsonProperty] 15 | public DateTime CreatedAt { get; set; } 16 | 17 | [JsonProperty] 18 | public DateTime UpdatedAt { get; set; } 19 | 20 | [JsonProperty] 21 | public string PatchVersion { get; set; } 22 | 23 | [JsonProperty] 24 | public string TitleId { get; set; } 25 | 26 | [JsonProperty("matches")] 27 | [JsonConverter(typeof(RelationshipIdConverter))] 28 | public IEnumerable MatchIds { get; set; } 29 | 30 | [JsonProperty] 31 | public string BanType { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/Seasons/SeasonsTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using Pubg.Net; 3 | using Pubg.Net.Tests.Util; 4 | using Xunit; 5 | 6 | namespace pubg.net.Tests.Seasons 7 | { 8 | public class SeasonsTests 9 | { 10 | [Fact] 11 | public void Can_Get_Seasons_OnPC() 12 | { 13 | var seasonsService = new PubgSeasonService(Storage.ApiKey); 14 | 15 | var seasons = seasonsService.GetSeasonsPC(); 16 | 17 | Assert.All(seasons, s => s.Id.Should().NotBeNull()); 18 | seasons.Should().ContainSingle(s => s.IsCurrentSeason == true); 19 | } 20 | 21 | [Fact] 22 | public void Can_Get_Seasons_OnXbox() 23 | { 24 | var seasonsService = new PubgSeasonService(Storage.ApiKey); 25 | 26 | var seasons = seasonsService.GetSeasonsXbox(PubgRegion.XboxEurope); 27 | 28 | Assert.All(seasons, s => s.Id.Should().NotBeNull()); 29 | seasons.Should().ContainSingle(s => s.IsCurrentSeason == true); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogPlayerMakeGroggy.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Telemetry.Events 4 | { 5 | public class LogPlayerMakeGroggy : PubgTelemetryEvent 6 | { 7 | [JsonProperty] 8 | public int AttackerId { get; set; } 9 | 10 | [JsonProperty] 11 | public PubgCharacter Attacker { get; set; } 12 | 13 | [JsonProperty] 14 | public PubgCharacter Victim { get; set; } 15 | 16 | [JsonProperty] 17 | public string DamageTypeCategory { get; set; } 18 | 19 | [JsonProperty] 20 | public string DamageCauserName { get; set; } 21 | 22 | [JsonProperty] 23 | public float Distance { get; set; } 24 | 25 | [JsonProperty] 26 | public bool IsAttackerInVehicle { get; set; } 27 | 28 | [JsonProperty] 29 | public int DBNOId { get; set; } 30 | 31 | [JsonProperty] 32 | public string[] DamageCauserAdditionalInfo { get; set; } 33 | 34 | [JsonProperty] 35 | public string DamageReason { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogMatchStart.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.JsonConverters; 3 | using Pubg.Net.Models.Telemetry; 4 | using System.Collections.Generic; 5 | 6 | namespace Pubg.Net 7 | { 8 | public class LogMatchStart : PubgTelemetryEvent 9 | { 10 | [JsonProperty] 11 | public IEnumerable Characters { get; set; } 12 | 13 | [JsonProperty] 14 | public bool IsCustomGame { get; set; } 15 | 16 | [JsonProperty] 17 | public bool IsEventMode { get; set; } 18 | 19 | [JsonProperty] 20 | public string CameraViewBehaviour { get; set; } 21 | 22 | [JsonProperty] 23 | public int TeamSize { get; set; } 24 | 25 | [JsonProperty] 26 | [JsonConverter(typeof(StringifiedArrayConverter))] 27 | public IEnumerable BlueZoneCustomOptions { get; set; } 28 | 29 | [JsonProperty] 30 | public PubgMap MapName { get; set; } 31 | 32 | [JsonProperty] 33 | public string WeatherId { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/Masteries/MasteriesTest.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Pubg.Net; 3 | using Pubg.Net.Services.LifetimeStats; 4 | using Pubg.Net.Services.Masteries; 5 | using Pubg.Net.Tests.Util; 6 | using Xunit; 7 | 8 | namespace pubg.net.Tests.Masteries; 9 | 10 | public class MasteriesTest : TestBase 11 | { 12 | [Fact] 13 | public void Can_RetrieveWeaponMastery() 14 | { 15 | var samples = Storage.GetPlayer(PubgPlatform.Steam); 16 | var masteriesService = new PubgMasteriesService(Storage.ApiKey); 17 | 18 | var stats = masteriesService.GetWeaponMastery(PubgPlatform.Steam, samples.Id); 19 | 20 | Assert.True(stats.WeaponSummaries.Values.All(s => s != null)); 21 | } 22 | 23 | [Fact] 24 | public void Can_RetrieveSurvivalMastery() 25 | { 26 | var samples = Storage.GetPlayer(PubgPlatform.Steam); 27 | var masteriesService = new PubgMasteriesService(Storage.ApiKey); 28 | 29 | var stats = masteriesService.GetSurvivalMastery(PubgPlatform.Steam, samples.Id); 30 | 31 | Assert.True(stats.Stats.All(s => s.Value != null)); 32 | } 33 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/pubg-dotnet.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sync and Async client library for communicating with the Pubg Developer API supporting .net standard 2.0 5 | Pubg.Net 6 | 2.3.1 7 | Gavin Power 8 | net8.0 9 | Pubg.Net 10 | Pubg-DotNet 11 | pubg;playerunknown;battlegrounds;developer;api 12 | https://github.com/GavinPower747/pubg-dotnet 13 | True 14 | 15 | 16 | 17 | Pubg.Net 18 | false 19 | Pubg.Net 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/PubgGameState.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net 4 | { 5 | public class PubgGameState 6 | { 7 | [JsonProperty] 8 | public int ElapsedTime { get; set; } 9 | 10 | [JsonProperty] 11 | public int NumAliveTeams { get; set; } 12 | 13 | [JsonProperty] 14 | public int NumJoinPlayers { get; set; } 15 | 16 | [JsonProperty] 17 | public int NumStartPlayers { get; set; } 18 | 19 | [JsonProperty] 20 | public int NumAlivePlayers { get; set; } 21 | 22 | [JsonProperty] 23 | public Location SafetyZonePosition { get; set; } 24 | 25 | [JsonProperty] 26 | public float SafetyZoneRadius { get; set; } 27 | 28 | [JsonProperty] 29 | public Location PoisonGasWarningPosition { get; set; } 30 | 31 | [JsonProperty] 32 | public float PoisonGasWarningRadius { get; set; } 33 | 34 | [JsonProperty] 35 | public Location RedZonePosition { get; set; } 36 | 37 | [JsonProperty] 38 | public float RedZoneRadius { get; set; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Gavin Power 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/JsonConverters/PropertyBasedConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Linq; 4 | 5 | namespace Pubg.Net.Infrastructure.JsonConverters 6 | { 7 | public abstract class PropertyBasedConverter : JsonConverter 8 | { 9 | protected abstract T Create(Type objectType, JObject jObject); 10 | 11 | public override bool CanConvert(Type objectType) 12 | { 13 | return typeof(T).IsAssignableFrom(objectType); 14 | } 15 | 16 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 17 | { 18 | JObject jObject = JObject.Load(reader); 19 | T target = Create(objectType, jObject); 20 | 21 | if(target != null) 22 | serializer.Populate(jObject.CreateReader(), target); 23 | 24 | return target; 25 | } 26 | 27 | public override bool CanWrite => false; 28 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotImplementedException(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/JsonConverters/DefaultValueStringEnumConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Converters; 5 | using Pubg.Net.Infrastructure.Attributes; 6 | 7 | namespace Pubg.Net.Infrastructure.JsonConverters 8 | { 9 | public class DefaultValueStringEnumConverter : StringEnumConverter 10 | { 11 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 12 | { 13 | Enum convertedObject; 14 | 15 | try 16 | { 17 | var obj = base.ReadJson(reader, objectType, existingValue, serializer); 18 | convertedObject = (Enum) Enum.Parse(objectType, obj.ToString()); 19 | } 20 | catch 21 | { 22 | var defaultMember = objectType.GetMembers().FirstOrDefault(f => f.GetCustomAttributes(typeof(DefaultEnumMemberAttribute), false).Count() > 0); 23 | convertedObject = (Enum) Enum.Parse(objectType, defaultMember.Name); 24 | } 25 | 26 | return convertedObject; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Enums/PubgItemSubCategory.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.Attributes; 3 | using Pubg.Net.Infrastructure.JsonConverters; 4 | using System.Runtime.Serialization; 5 | 6 | namespace Pubg.Net.Models.Telemetry.Enums 7 | { 8 | [JsonConverter(typeof(DefaultValueStringEnumConverter))] 9 | public enum PubgItemSubCategory 10 | { 11 | [EnumMember( Value ="None")] 12 | [DefaultEnumMember] 13 | None, 14 | [EnumMember( Value ="Backpack")] 15 | Backpack, 16 | [EnumMember( Value ="Boost")] 17 | Boost, 18 | [EnumMember( Value ="Fuel")] 19 | Fuel, 20 | [EnumMember( Value ="Handgun")] 21 | Handgun, 22 | [EnumMember( Value ="Headgear")] 23 | Headgear, 24 | [EnumMember( Value ="Heal")] 25 | Heal, 26 | [EnumMember( Value ="Jacket")] 27 | Jacket, 28 | [EnumMember( Value ="Main")] 29 | Main, 30 | [EnumMember( Value ="Melee")] 31 | Melee, 32 | [EnumMember( Value ="Throwable")] 33 | Throwable, 34 | [EnumMember( Value ="Vest")] 35 | Vest 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Match/PubgMap.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.Attributes; 3 | using Pubg.Net.Infrastructure.JsonConverters; 4 | using System.Runtime.Serialization; 5 | 6 | namespace Pubg.Net 7 | { 8 | [JsonConverter(typeof(DefaultValueStringEnumConverter))] 9 | public enum PubgMap 10 | { 11 | //In some of the Telemetry they return an empty string 12 | [DefaultEnumMember] 13 | Unspecified, 14 | [EnumMember( Value = "Erangel_Main" )] 15 | Erangel, 16 | [EnumMember( Value = "Desert_Main" )] 17 | Miramar, 18 | [EnumMember(Value = "Savage_Main")] 19 | Sanhok, 20 | [EnumMember(Value = "Range_Main")] 21 | TrainingRange, 22 | [EnumMember(Value = "DihorOtok_Main")] 23 | Vikendi, 24 | [EnumMember(Value = "Baltic_Main")] 25 | Baltic, 26 | [EnumMember(Value = "Heaven_Main")] 27 | Haven, 28 | [EnumMember(Value = "Kiki_Main")] 29 | Deston, 30 | [EnumMember(Value = "Summerland_Main")] 31 | Karakin, 32 | [EnumMember(Value = "Tiger_Main")] 33 | Taego, 34 | [EnumMember(Value = "Neon_Main")] 35 | Rondo, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogPlayerKill.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Telemetry; 3 | using Pubg.Net.Models.Telemetry.Enums; 4 | 5 | namespace Pubg.Net 6 | { 7 | public class LogPlayerKill : PubgTelemetryEvent 8 | { 9 | [JsonProperty] 10 | public int AttackId { get; set; } 11 | 12 | [JsonProperty] 13 | public PubgCharacter Killer { get; set; } 14 | 15 | [JsonProperty] 16 | public PubgCharacter Victim { get; set; } 17 | 18 | [JsonProperty] 19 | public string DamageTypeCategory { get; set; } 20 | 21 | [JsonProperty] 22 | public string DamageCauserName { get; set; } 23 | 24 | [JsonProperty] 25 | public float Distance { get; set; } 26 | 27 | [JsonProperty] 28 | public PubgDamageReason DamageReason { get; set; } 29 | 30 | [JsonProperty] 31 | public PubgCharacter Assistant { get; set; } 32 | 33 | [JsonProperty] 34 | public string[] DamageCauserAdditionalInfo { get; set; } 35 | 36 | [JsonProperty] 37 | public int DBNOId { get; set; } 38 | 39 | [JsonProperty] 40 | public PubgGameResult VictimGameResult { get; set; } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Players/PubgPlayerSeason.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.JsonConverters; 3 | using System.Collections.Generic; 4 | 5 | namespace Pubg.Net 6 | { 7 | public class PubgPlayerSeason : PubgStatEntity 8 | { 9 | [JsonProperty("matchesSolo")] 10 | [JsonConverter(typeof(RelationshipIdConverter))] 11 | public IEnumerable SoloMatchIds { get; set; } 12 | 13 | [JsonProperty("matchesSoloFPP")] 14 | [JsonConverter(typeof(RelationshipIdConverter))] 15 | public IEnumerable SoloFPPMatchIds { get; set; } 16 | 17 | [JsonProperty("matchesDuo")] 18 | [JsonConverter(typeof(RelationshipIdConverter))] 19 | public IEnumerable DuoMatchIds { get; set; } 20 | 21 | [JsonProperty("matchesDuoFPP")] 22 | [JsonConverter(typeof(RelationshipIdConverter))] 23 | public IEnumerable DuoFPPMatchIds { get; set; } 24 | 25 | [JsonProperty("matchesSquad")] 26 | [JsonConverter(typeof(RelationshipIdConverter))] 27 | public IEnumerable SquadMatchIds { get; set; } 28 | 29 | [JsonProperty("matchesSquadFPP")] 30 | [JsonConverter(typeof(RelationshipIdConverter))] 31 | public IEnumerable SquadFPPMatchIds { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/JsonConverters/PubgTelemetryConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | using Newtonsoft.Json; 5 | using Newtonsoft.Json.Linq; 6 | using Pubg.Net; 7 | using Pubg.Net.Models.Telemetry.Events; 8 | 9 | namespace Pubg.Net.Infrastructure.JsonConverters 10 | { 11 | public class PubgTelemetryConverter : PropertyBasedConverter 12 | { 13 | protected override PubgTelemetryEvent Create(Type objectType, JObject jObject) 14 | { 15 | var jsonProp = objectType.GetProperty(nameof(PubgTelemetryEvent.Type)).GetCustomAttribute().PropertyName; 16 | var typeName = (string)jObject.Property(jsonProp); 17 | 18 | if (typeName != null) 19 | { 20 | var baseType = typeof(PubgTelemetryEvent); 21 | var eventTypes = baseType.Assembly.GetTypes().Where(t => t.IsSubclassOf(baseType)); 22 | 23 | foreach (var eventType in eventTypes) 24 | { 25 | if (typeName.ToLowerInvariant().Equals(eventType.Name.ToLowerInvariant())) 26 | return (PubgTelemetryEvent)Activator.CreateInstance(eventType); 27 | } 28 | } 29 | 30 | return new UnknownTelemetryEvent(jObject); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/JsonConverters/RelationshipIdConverter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Linq; 5 | 6 | namespace Pubg.Net.Infrastructure.JsonConverters 7 | { 8 | public class RelationshipIdConverter : JsonConverter 9 | { 10 | public override bool CanConvert(Type objectType) => false; 11 | public override bool CanWrite => false; 12 | 13 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 14 | { 15 | //if the reader is not reading a relationship object just deserialize as normal. 16 | //This allows us to serialize and deserialize multiple times after converting from the Json-API format 17 | if (reader.TokenType != JsonToken.StartObject) 18 | return serializer.Deserialize(reader, objectType); 19 | 20 | JToken jt = JToken.Load(reader); 21 | 22 | var dataToken = jt.SelectToken("data"); 23 | 24 | if (objectType == typeof(string)) 25 | return dataToken["id"].ToString(); 26 | 27 | return dataToken.Select(x => (string)x["id"]).ToList(); 28 | } 29 | 30 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Configuration/PubgApiConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Pubg.Net.Configuration; 2 | using Pubg.Net.Values; 3 | using System; 4 | 5 | namespace Pubg.Net 6 | { 7 | public static class PubgApiConfiguration 8 | { 9 | private static string _apiKey; 10 | private static string _apiBaseUrl; 11 | private static TimeSpan? _httpTimeout; 12 | 13 | internal static string GetApiKey() => _apiKey; 14 | public static void SetApiKey(string key) =>_apiKey = key; 15 | 16 | internal static string GetApiBase() 17 | { 18 | if(string.IsNullOrEmpty(_apiBaseUrl)) 19 | { 20 | _apiBaseUrl = Api.DefaultBaseUrl; 21 | } 22 | 23 | return _apiBaseUrl; 24 | } 25 | 26 | public static void SetApiBase(string apiBase) => _apiBaseUrl = apiBase; 27 | 28 | internal static TimeSpan? GetHttpTimeout() => _httpTimeout; 29 | public static void SetHttpTimeout(TimeSpan timeout) => _httpTimeout = timeout; 30 | 31 | public static void Configure(Action configAction) 32 | { 33 | PubgApiSettings settings = new PubgApiSettings(); 34 | 35 | configAction(settings); 36 | 37 | _apiKey = settings.ApiKey; 38 | _apiBaseUrl = settings.ApiBaseUrl; 39 | _httpTimeout = settings.HttpTimeout; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/Leaderboard/LeaderboardServiceTests.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using FluentAssertions; 3 | using Pubg.Net; 4 | using Pubg.Net.Services.Leaderboard; 5 | using Pubg.Net.Tests.Util; 6 | using Xunit; 7 | 8 | namespace pubg.net.Tests.Leaderboard 9 | { 10 | public class LeaderboardServiceTests : TestBase 11 | { 12 | [Theory] 13 | [InlineData(PubgGameMode.Duo)] 14 | [InlineData(PubgGameMode.DuoFpp)] 15 | [InlineData(PubgGameMode.Solo)] 16 | [InlineData(PubgGameMode.SoloFpp)] 17 | [InlineData(PubgGameMode.Squad)] 18 | [InlineData(PubgGameMode.SquadFpp)] 19 | public void Can_Get_Leaderboard(PubgGameMode gameMode) 20 | { 21 | var service = new PubgLeaderboardService(Storage.ApiKey); 22 | var seasonService = new PubgSeasonService(Storage.ApiKey); 23 | 24 | var seasons = seasonService.GetSeasonsPC().Where(s => s.Id.Contains("pc")); 25 | var leaderboard = service.GetGameModeLeaderboard(PubgRegion.PCEurope, seasons.First().Id, gameMode); 26 | 27 | leaderboard.Id.Should().NotBeNullOrEmpty(); 28 | leaderboard.ShardId.Should().NotBeNullOrEmpty(); 29 | Assert.All(leaderboard.Players, player => player.Id.Should().NotBeNullOrEmpty()); 30 | Assert.All(leaderboard.Players, player => player.Name.Should().NotBeNullOrEmpty()); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/Tournaments/TournamentsTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using Pubg.Net; 3 | using Pubg.Net.Tests.Util; 4 | using System.Linq; 5 | using Xunit; 6 | 7 | namespace pubg.net.Tests.Tournaments 8 | { 9 | public class TournamentsTests : TestBase 10 | { 11 | [Fact] 12 | public void Can_Get_Tournaments() 13 | { 14 | var tournamentService = new PubgTournamentService(Storage.ApiKey); 15 | 16 | var tournaments = tournamentService.GetTournaments(); 17 | 18 | Assert.All(tournaments, t => t.Id.Should().NotBeNullOrWhiteSpace()); 19 | Assert.All(tournaments, t => t.Type.Should().NotBeNullOrWhiteSpace()); 20 | } 21 | 22 | [Fact] 23 | public void Can_Get_Tournament_From_List() 24 | { 25 | var tournamentService = new PubgTournamentService(Storage.ApiKey); 26 | 27 | var tournaments = tournamentService.GetTournaments(); 28 | var tournamentToGet = tournaments.FirstOrDefault(); 29 | 30 | tournamentToGet.Should().NotBeNull(); 31 | 32 | var retrievedTournament = tournamentService.GetTournament(tournamentToGet.Id); 33 | 34 | retrievedTournament.Should().NotBeNull(); 35 | retrievedTournament.Id.Should().NotBeNullOrWhiteSpace(); 36 | retrievedTournament.Type.Should().NotBeNullOrWhiteSpace(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Match/PubgMatch.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Base; 3 | using Pubg.Net.Models.Seasons; 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Pubg.Net 8 | { 9 | public class PubgMatch : PubgShardedEntity 10 | { 11 | [JsonProperty] 12 | public string CreatedAt { get; set; } 13 | 14 | [JsonProperty] 15 | public long Duration { get; set; } 16 | 17 | [JsonProperty] 18 | public IEnumerable Rosters { get; set; } 19 | 20 | [JsonProperty] 21 | public PubgRound Rounds { get; set; } 22 | 23 | [JsonProperty] 24 | public IEnumerable Assets { get; set; } 25 | 26 | [JsonProperty] 27 | public PubgMatchStats Stats { get; set; } 28 | 29 | [JsonProperty] 30 | public PubgGameMode GameMode { get; set; } 31 | 32 | [JsonProperty] 33 | public string PatchVersion { get; set; } 34 | 35 | [JsonProperty] 36 | public string TitleId { get; set; } 37 | 38 | [JsonProperty] 39 | public Dictionary Links { get; set; } 40 | 41 | [JsonProperty] 42 | public PubgMap MapName { get; set; } 43 | 44 | [JsonProperty] 45 | public bool IsCustomMatch { get; set; } 46 | 47 | [JsonProperty] 48 | public PubgSeasonState SeasonState { get; set; } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/Status/PubgStatusService.cs: -------------------------------------------------------------------------------- 1 | using JsonApiSerializer; 2 | using Newtonsoft.Json; 3 | using Pubg.Net.Infrastructure; 4 | using Pubg.Net.Services; 5 | using Pubg.Net.Values; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace Pubg.Net 10 | { 11 | public class PubgStatusService : PubgService 12 | { 13 | public PubgStatusService() : base() { } 14 | public PubgStatusService(string apiKey) : base(apiKey) { } 15 | 16 | public virtual PubgStatus GetStatus(string apiKey = null) 17 | { 18 | var url = Api.Status.StatusEndpoint(); 19 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 20 | 21 | var objectJson = HttpRequestor.GetString(url, apiKey); 22 | 23 | return JsonConvert.DeserializeObject(objectJson, new JsonApiSerializerSettings()); 24 | } 25 | 26 | public virtual async Task GetStatusAsync(string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 27 | { 28 | var url = Api.Status.StatusEndpoint(); 29 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 30 | 31 | var objectJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); 32 | 33 | return JsonConvert.DeserializeObject(objectJson, new JsonApiSerializerSettings()); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Common/PubgRegion.cs: -------------------------------------------------------------------------------- 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 PubgRegion 9 | { 10 | //Xbox Regions 11 | [EnumMember(Value = "xbox-as")] 12 | XboxAsia, 13 | 14 | [EnumMember(Value = "xbox-eu")] 15 | XboxEurope, 16 | 17 | [EnumMember(Value = "xbox-na")] 18 | XboxNorthAmerica, 19 | 20 | [EnumMember(Value = "xbox-oc")] 21 | XboxOceania, 22 | 23 | [EnumMember(Value = "xbox-sa")] 24 | XboxSouthAmerica, 25 | 26 | //PC Regions 27 | [EnumMember(Value = "pc-as")] 28 | PCAsia, 29 | 30 | [EnumMember(Value = "pc-eu")] 31 | PCEurope, 32 | 33 | [EnumMember(Value = "pc-ru")] 34 | PCRussia, 35 | 36 | [EnumMember(Value = "pc-kakao")] 37 | PCKakao, //What? 38 | 39 | [EnumMember(Value = "pc-krjp")] 40 | PCKorea, 41 | 42 | [EnumMember(Value = "pc-jp")] 43 | PCJapan, 44 | 45 | [EnumMember(Value = "pc-na")] 46 | PCNorthAmerica, 47 | 48 | [EnumMember(Value = "pc-oc")] 49 | PCOceania, 50 | 51 | [EnumMember(Value = "pc-sa")] 52 | PCSouthAndCentralAmerica, 53 | 54 | [EnumMember(Value = "pc-sea")] 55 | PCSouthEastAsia 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/Samples/MatchSamplesTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using Pubg.Net; 3 | using Pubg.Net.Extensions; 4 | using Pubg.Net.Tests.Util; 5 | using System; 6 | using Xunit; 7 | 8 | namespace pubg.net.Tests.Samples 9 | { 10 | public class MatchSamplesTests : TestBase 11 | { 12 | [Fact] 13 | public void Can_Get_MatchSamples_When_NoFilterGiven() 14 | { 15 | var region = PubgPlatform.Steam; 16 | var samplesService = new PubgSamplesService(Storage.ApiKey); 17 | 18 | var matchSamples = samplesService.GetMatchSamples(region); 19 | 20 | matchSamples.Should().NotBeNull(); 21 | matchSamples.MatchIds.Should().NotBeNullOrEmpty(); 22 | matchSamples.ShardId.Should().BeEquivalentTo(region.Serialize()); 23 | } 24 | 25 | [Fact] 26 | public void Can_Get_MatchSamples_When_FilterGiven() 27 | { 28 | var region = PubgPlatform.Steam; 29 | var samplesService = new PubgSamplesService(Storage.ApiKey); 30 | var createdDate = DateTime.UtcNow.AddDays(-2); 31 | 32 | var matchSamples = samplesService.GetMatchSamples(region, new GetSamplesRequest { CreatedAtStart = createdDate }); 33 | 34 | matchSamples.Should().NotBeNull(); 35 | matchSamples.MatchIds.Should().NotBeNullOrEmpty(); 36 | matchSamples.ShardId.Should().BeEquivalentTo(region.Serialize()); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/Masteries/PubgMasteriesService.cs: -------------------------------------------------------------------------------- 1 | using JsonApiSerializer; 2 | using Newtonsoft.Json; 3 | using Pubg.Net.Infrastructure; 4 | using Pubg.Net.Models.Masteries; 5 | using Pubg.Net.Values; 6 | 7 | namespace Pubg.Net.Services.Masteries; 8 | 9 | public class PubgMasteriesService : PubgService 10 | { 11 | public PubgMasteriesService() : base() 12 | { 13 | } 14 | 15 | public PubgMasteriesService(string apiKey) : base(apiKey) 16 | { 17 | } 18 | public virtual WeaponMastery GetWeaponMastery(PubgPlatform platform, string accountId, 19 | string apiKey = null) 20 | { 21 | var url = Api.Masteries.WeaponMasteryEndpoint(platform, accountId); 22 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 23 | 24 | var statsJson = HttpRequestor.GetString(url, apiKey); 25 | 26 | return JsonConvert.DeserializeObject(statsJson, 27 | new JsonApiSerializerSettings()); 28 | } 29 | 30 | public virtual SurvivalMastery GetSurvivalMastery(PubgPlatform platform, string accountId, 31 | string apiKey = null) 32 | { 33 | var url = Api.Masteries.SurvivalMasteryEndpoint(platform, accountId); 34 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 35 | 36 | var statsJson = HttpRequestor.GetString(url, apiKey); 37 | 38 | return JsonConvert.DeserializeObject(statsJson, 39 | new JsonApiSerializerSettings()); 40 | } 41 | } -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 2.3.0.{build} 2 | image: Visual Studio 2017 3 | skip_tags: true 4 | 5 | branches: 6 | only: 7 | - master 8 | - development 9 | 10 | deploy: 11 | - provider: NuGet 12 | api_key: 13 | secure: 7bO/kGissHvP4YkwclB3U0KN7Qdl70XYUDIr0Fk9EYd6HCKljLgC8JRFXklEPbWz 14 | on: 15 | branch: master 16 | 17 | - provider: GitHub 18 | release: Pubg.Net-v$(appveyor_build_version) 19 | description: '' 20 | auth_token: 21 | secure: 6bQdMR64k8Hsx3yyvLjkfD9K16vBFYQg85PqD5tAypkcBRe8cSsofZAgavw1QrVm 22 | artifact: /.*\.nupkg/ 23 | draft: false 24 | prerelease: false 25 | on: 26 | branch: master 27 | 28 | 29 | before_build: 30 | - dotnet --info 31 | - ps: Write-Host $("Performing Dot Net Restore") 32 | - dotnet restore 33 | 34 | build: 35 | parallel: true 36 | 37 | build_script: 38 | - ps: Write-Host $("Performing build") 39 | - dotnet build -c Release src\pubg-dotnet 40 | - dotnet build -c Debug src\pubg-dotnet 41 | - dotnet build -c Debug test\pubg-dotnet.Tests 42 | 43 | after_build: 44 | - ps: Write-Host $("Performing dotnet pack") 45 | - dotnet pack -c Release src\pubg-dotnet 46 | 47 | test_script: 48 | - ps: Write-Host $("Starting tests") 49 | - ps: Write-Host $("Running full tests") 50 | - dotnet test test\pubg-dotnet.Tests\pubg-dotnet.Tests.csproj 51 | - ps: Write-Host $("Running unit tests") 52 | - dotnet test test\pubg-dotnet.UnitTests\pubg-dotnet.UnitTests.csproj 53 | 54 | artifacts: 55 | - path: '**\*.nupkg' 56 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/Telemetry/PubgTelemetryService.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure; 3 | using Pubg.Net.Services; 4 | using System.Collections.Generic; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace Pubg.Net 9 | { 10 | public class PubgTelemetryService : PubgService 11 | { 12 | public virtual IEnumerable GetTelemetry(PubgRegion region, PubgAsset asset) => GetTelemetry(region, asset.Url); 13 | 14 | public virtual IEnumerable GetTelemetry(PubgRegion region, string url) 15 | { 16 | var collectionJson = HttpRequestor.GetString(url); 17 | 18 | return JsonConvert.DeserializeObject>(collectionJson); 19 | } 20 | 21 | public virtual async Task> GetTelemetryAsync(PubgRegion region, PubgAsset asset, CancellationToken cancellationToken = default(CancellationToken)) 22 | => await GetTelemetryAsync(region, asset.Url, cancellationToken).ConfigureAwait(false); 23 | 24 | public virtual async Task> GetTelemetryAsync(PubgRegion region, string url, CancellationToken cancellationToken = default(CancellationToken)) 25 | { 26 | var collectionJson = await HttpRequestor.GetStringAsync(url, cancellationToken).ConfigureAwait(false); 27 | 28 | return JsonConvert.DeserializeObject>(collectionJson); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Telemetry/Events/LogPlayerKillV2.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | using Pubg.Net.Models.Telemetry.Enums; 4 | 5 | namespace Pubg.Net.Models.Telemetry.Events; 6 | 7 | public class LogPlayerKillV2 : PubgTelemetryEvent 8 | { 9 | [JsonProperty] 10 | public int AttackId { get; set; } 11 | 12 | [JsonProperty] 13 | public int DBNOId { get; set; } 14 | 15 | [JsonProperty] 16 | public PubgGameResult VictimGameResult { get; set; } 17 | 18 | [JsonProperty] 19 | public PubgCharacter Victim { get; set; } 20 | 21 | [JsonProperty] 22 | public string VictimWeapon { get; set; } 23 | 24 | [JsonProperty] 25 | public List VictimWeaponAdditionalInfo { get; set; } 26 | 27 | [JsonProperty] 28 | public PubgCharacter DBNOMaker { get; set; } 29 | 30 | [JsonProperty] 31 | public DamageInfo DBNODamageInfo { get; set; } 32 | 33 | [JsonProperty] 34 | public PubgCharacter Finisher { get; set; } 35 | 36 | [JsonProperty] 37 | public DamageInfo FinishDamageInfo { get; set; } 38 | 39 | [JsonProperty] 40 | public PubgCharacter Killer { get; set; } 41 | 42 | [JsonProperty] 43 | public DamageInfo KillerDamageInfo { get; set; } 44 | 45 | [JsonProperty] 46 | public List Assists_AccountId { get; set; } 47 | 48 | [JsonProperty] 49 | public List TeamKillers_AccountId { get; set; } 50 | 51 | [JsonProperty] 52 | public bool IsSuicide { get; set; } 53 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/LifetimeStats/GameModeStat.cs: -------------------------------------------------------------------------------- 1 | namespace Pubg.Net.Models.LifetimeStats; 2 | 3 | public class GameModeStat 4 | { 5 | public int Assists { get; set; } 6 | public int Boosts { get; set; } 7 | public int DBnOs { get; set; } 8 | public int DailyKills { get; set; } 9 | public int DamageDealt { get; set; } 10 | public int Days { get; set; } 11 | public int DailyWins { get; set; } 12 | public int HeadshotKills { get; set; } 13 | public int Heals { get; set; } 14 | public int KillPoints { get; set; } 15 | public int Kills { get; set; } 16 | public int LongestKill { get; set; } 17 | public int LongestTimeSurvived { get; set; } 18 | public int Losses { get; set; } 19 | public int MaxKillStreaks { get; set; } 20 | public int MostSurvivalTime { get; set; } 21 | public int RankPoints { get; set; } 22 | public string RankPointsTitle { get; set; } 23 | public int Revives { get; set; } 24 | public int RideDistance { get; set; } 25 | public int RoadKills { get; set; } 26 | public int RoundMostKills { get; set; } 27 | public int RoundsPlayed { get; set; } 28 | public int Suicides { get; set; } 29 | public int SwimDistance { get; set; } 30 | public int TeamKills { get; set; } 31 | public int TimeSurvived { get; set; } 32 | public int Top10S { get; set; } 33 | public int VehicleDestroys { get; set; } 34 | public int WalkDistance { get; set; } 35 | public int WeaponsAcquired { get; set; } 36 | public int WeeklyKills { get; set; } 37 | public int WeeklyWins { get; set; } 38 | public int WinPoints { get; set; } 39 | public int Wins { get; set; } 40 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/LifetimeStats/PubgLifetimeStatsService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using JsonApiSerializer; 3 | using Newtonsoft.Json; 4 | using Pubg.Net.Infrastructure; 5 | using Pubg.Net.Values; 6 | 7 | namespace Pubg.Net.Services.LifetimeStats; 8 | 9 | public class PubgLifetimeStatsService : PubgService 10 | { 11 | public PubgLifetimeStatsService() : base() 12 | { 13 | } 14 | 15 | public PubgLifetimeStatsService(string apiKey) : base(apiKey) 16 | { 17 | } 18 | 19 | public virtual Models.LifetimeStats.LifetimeStats GetLifetimeStats(PubgPlatform platform, string accountId, 20 | string apiKey = null) 21 | { 22 | var url = Api.LifetimeStats.LifetimeStatsEndpoint(platform, accountId); 23 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 24 | 25 | var statsJson = HttpRequestor.GetString(url, apiKey); 26 | 27 | return JsonConvert.DeserializeObject(statsJson, 28 | new JsonApiSerializerSettings()); 29 | } 30 | 31 | public virtual IEnumerable GetLifetimeStats(PubgPlatform platform, 32 | PubgGameMode gameMode, 33 | IEnumerable playerIds, string apiKey = null) 34 | { 35 | var url = Api.LifetimeStats.LifetimeStatsEndpoint(platform, gameMode, playerIds); 36 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 37 | 38 | var statsJson = HttpRequestor.GetString(url, apiKey); 39 | 40 | return JsonConvert.DeserializeObject>(statsJson, 41 | new JsonApiSerializerSettings()); 42 | } 43 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/Leaderboard/PubgLeaderboardService.cs: -------------------------------------------------------------------------------- 1 | using JsonApiSerializer; 2 | using Newtonsoft.Json; 3 | using Pubg.Net.Infrastructure; 4 | using Pubg.Net.Values; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace Pubg.Net.Services.Leaderboard 9 | { 10 | public class PubgLeaderboardService : PubgService 11 | { 12 | public PubgLeaderboardService() : base() { } 13 | public PubgLeaderboardService(string apiKey) : base(apiKey) { } 14 | 15 | public virtual PubgLeaderboard GetGameModeLeaderboard(PubgRegion region, string seasonId,PubgGameMode gameMode, string apiKey = null) 16 | { 17 | var url = Api.Leaderboard.LeaderboardEndpoint(region, seasonId, gameMode); 18 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 19 | 20 | var leaderboardJson = HttpRequestor.GetString(url, apiKey); 21 | 22 | return JsonConvert.DeserializeObject(leaderboardJson, new JsonApiSerializerSettings()); 23 | } 24 | 25 | public virtual async Task GetGameModeLeaderboardAsync(PubgRegion region, string seasonId, PubgGameMode gameMode, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 26 | { 27 | var url = Api.Leaderboard.LeaderboardEndpoint(region,seasonId, gameMode); 28 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 29 | 30 | var leaderboardJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); 31 | 32 | return JsonConvert.DeserializeObject(leaderboardJson, new JsonApiSerializerSettings()); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/pubg-dotnet.UnitTests/ErrorMapping/ErrorMappingTests.cs: -------------------------------------------------------------------------------- 1 | using AutoFixture; 2 | using FluentAssertions; 3 | using Newtonsoft.Json; 4 | using Pubg.Net.Infrastructure; 5 | using Pubg.Net.Models.Errors; 6 | using System.Linq; 7 | using Xunit; 8 | 9 | namespace Pubg.Net.UnitTests.ErrorMapping 10 | { 11 | public class ErrorMappingTests 12 | { 13 | [Fact] 14 | public void ErrorMapper_Can_MapError() 15 | { 16 | var fixture = new Fixture(); 17 | var error = fixture.Create(); 18 | var errorJson = JsonConvert.SerializeObject(error); 19 | 20 | string json = $@"{{ 21 | ""data"": [], 22 | ""included"" : [], 23 | ""errors"": [ 24 | {errorJson} 25 | ] 26 | }}"; 27 | 28 | var mappedErrors = ErrorMapper.MapErrors(json); 29 | 30 | mappedErrors.Should().NotBeNullOrEmpty(); 31 | 32 | var mappedError = mappedErrors.First(); 33 | 34 | mappedError.Should().BeEquivalentTo(error); 35 | } 36 | 37 | [Fact] 38 | public void ErrorMapper_Can_MapManyErrors() 39 | { 40 | var fixture = new Fixture(); 41 | var errors = fixture.CreateMany(); 42 | var errorJson = JsonConvert.SerializeObject(errors); 43 | 44 | string json = $@"{{ 45 | ""data"": [], 46 | ""included"" : [], 47 | ""errors"": {errorJson} 48 | }}"; 49 | 50 | var mappedErrors = ErrorMapper.MapErrors(json); 51 | 52 | mappedErrors.Should().NotBeNullOrEmpty(); 53 | 54 | Assert.All(mappedErrors, error => errors.Contains(error)); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/Telemetry/TelemetryTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using Pubg.Net.Tests.Util; 3 | using System.Linq; 4 | using Xunit; 5 | using Pubg.Net.Models.Telemetry.Events; 6 | using pubg.net.Tests; 7 | 8 | namespace Pubg.Net.Tests.Telemetry 9 | { 10 | public class TelemetryTests : TestBase 11 | { 12 | [Fact] 13 | public void Can_Pull_Telemetry_From_Match_OnPc() 14 | { 15 | var region = PubgRegion.PCEurope; 16 | var match = Storage.GetMatch(PubgPlatform.Steam); 17 | var asset = match.Assets.FirstOrDefault(); 18 | var telemetryService = new PubgTelemetryService(); 19 | 20 | var telemetry = telemetryService.GetTelemetry(region, asset); 21 | 22 | telemetry.Should().NotBeEmpty(); 23 | Assert.All(telemetry, t => t.Should().NotBeOfType()); 24 | 25 | var matchDefinition = telemetry.OfType().FirstOrDefault(); 26 | 27 | matchDefinition.MatchId.Should().NotBeNullOrWhiteSpace(); 28 | } 29 | 30 | [Fact] 31 | public void Can_Pull_Telemetry_From_Match_OnXbox() 32 | { 33 | var region = PubgRegion.XboxEurope; 34 | var match = Storage.GetMatch(PubgPlatform.Steam); 35 | var asset = match.Assets.FirstOrDefault(); 36 | var telemetryService = new PubgTelemetryService(); 37 | 38 | var telemetry = telemetryService.GetTelemetry(region, asset); 39 | 40 | telemetry.Should().NotBeEmpty(); 41 | Assert.All(telemetry, t => t.Should().NotBeOfType()); 42 | 43 | var matchDefinition = telemetry.OfType().FirstOrDefault(); 44 | 45 | matchDefinition.MatchId.Should().NotBeNullOrWhiteSpace(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/RequestBuilder.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.Parsers; 3 | using Pubg.Net.Services; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Reflection; 7 | 8 | namespace Pubg.Net.Infrastructure 9 | { 10 | internal static class RequestBuilder 11 | { 12 | static IParser[] _availableParsers = new IParser[] 13 | { 14 | new ArrayParser(), 15 | new EnumParser(), 16 | new DateTimeParser() 17 | }; 18 | 19 | internal static string BuildRequestUrl(string baseUrl, PubgRequest request) 20 | { 21 | var excludedProperties = typeof(PubgRequest).GetRuntimeProperties(); 22 | var completedUrl = baseUrl; 23 | 24 | foreach (var property in request.GetType().GetRuntimeProperties()) 25 | { 26 | if (excludedProperties.Any(ep => ep.Name.Equals(property.Name))) continue; 27 | 28 | var value = property.GetValue(request, null); 29 | if (value == null) continue; 30 | 31 | var parser = _availableParsers.FirstOrDefault(p => p.CanParse(property, value)); 32 | 33 | var parsedValue = value; 34 | 35 | if (parser != null) 36 | parsedValue = parser.Parse(property, value); 37 | 38 | var attribute = property.GetCustomAttribute(); 39 | 40 | completedUrl = ApplyPrimativeValue(completedUrl, attribute.PropertyName, parsedValue.ToString()); 41 | } 42 | 43 | return completedUrl; 44 | } 45 | 46 | private static string ApplyPrimativeValue(string url, string propName, string value) 47 | { 48 | var separator = url.Contains("?") ? "&" : "?"; 49 | 50 | return $"{url}{separator}{propName}={WebUtility.UrlEncode(value)}"; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Masteries/WeaponSummary.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Pubg.Net.Models.Masteries; 4 | 5 | public class CompetitiveStatsTotal 6 | { 7 | public int MostDefeatsInAGame { get; set; } 8 | public int Defeats { get; set; } 9 | public int DamagePlayer { get; set; } 10 | public int HeadShots { get; set; } 11 | public int Kills { get; set; } 12 | public int MostKillsInAGame { get; set; } 13 | public int Groggies { get; set; } 14 | public int LongestKill { get; set; } 15 | } 16 | 17 | public class Medal 18 | { 19 | public string MedalId { get; set; } 20 | public int Count { get; set; } 21 | } 22 | 23 | public class OfficialStatsTotal 24 | { 25 | public int MostDefeatsInAGame { get; set; } 26 | public int Defeats { get; set; } 27 | public int DamagePlayer { get; set; } 28 | public int HeadShots { get; set; } 29 | public int Kills { get; set; } 30 | public int MostKillsInAGame { get; set; } 31 | public int Groggies { get; set; } 32 | public int LongestKill { get; set; } 33 | } 34 | 35 | public class WeaponSummary 36 | { 37 | public int XPTotal { get; set; } 38 | public int LevelCurrent { get; set; } 39 | public int TierCurrent { get; set; } 40 | public StatsTotal StatsTotal { get; set; } 41 | public OfficialStatsTotal OfficialStatsTotal { get; set; } 42 | public CompetitiveStatsTotal CompetitiveStatsTotal { get; set; } 43 | public List Medals { get; set; } 44 | } 45 | 46 | public class StatsTotal 47 | { 48 | public int MostDefeatsInAGame { get; set; } 49 | public int Defeats { get; set; } 50 | public int MostDamagePlayerInAGame { get; set; } 51 | public int DamagePlayer { get; set; } 52 | public int MostHeadShotsInAGame { get; set; } 53 | public int HeadShots { get; set; } 54 | public int LongestDefeat { get; set; } 55 | public int LongRangeDefeats { get; set; } 56 | public int Kills { get; set; } 57 | public int MostKillsInAGame { get; set; } 58 | public int Groggies { get; set; } 59 | public int MostGroggiesInAGame { get; set; } 60 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/Samples/PubgSamplesService.cs: -------------------------------------------------------------------------------- 1 | using JsonApiSerializer; 2 | using Newtonsoft.Json; 3 | using Pubg.Net.Extensions; 4 | using Pubg.Net.Infrastructure; 5 | using Pubg.Net.Models.Samples; 6 | using Pubg.Net.Services; 7 | using Pubg.Net.Values; 8 | using System.Collections.Generic; 9 | using System.Linq; 10 | using System.Threading; 11 | using System.Threading.Tasks; 12 | 13 | namespace Pubg.Net 14 | { 15 | public class PubgSamplesService : PubgService 16 | { 17 | public PubgSamplesService() : base() { } 18 | public PubgSamplesService(string apiKey) : base(apiKey) { } 19 | 20 | public PubgMatchSample GetMatchSamples(PubgPlatform platform, string apiKey = null) => GetMatchSamples(platform, new GetSamplesRequest { ApiKey = apiKey }); 21 | 22 | public PubgMatchSample GetMatchSamples(PubgPlatform platform, GetSamplesRequest request) 23 | { 24 | var url = RequestBuilder.BuildRequestUrl(Api.Samples.SamplesEndpoint(platform), request); 25 | var apiKey = string.IsNullOrEmpty(request.ApiKey) ? ApiKey : request.ApiKey; 26 | 27 | var collectionJson = HttpRequestor.GetString(url, apiKey); 28 | 29 | return JsonConvert.DeserializeObject>(collectionJson, new JsonApiSerializerSettings()).FirstOrDefault(); 30 | } 31 | 32 | public Task GetMatchSamplesAsync(PubgPlatform platform, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 33 | => GetMatchSamplesAsync(platform, new GetSamplesRequest { ApiKey = apiKey }, cancellationToken); 34 | 35 | public async Task GetMatchSamplesAsync(PubgPlatform platform, GetSamplesRequest request, CancellationToken cancellationToken = default(CancellationToken)) 36 | { 37 | var url = RequestBuilder.BuildRequestUrl(Api.Samples.SamplesEndpoint(platform), request); 38 | var apiKey = string.IsNullOrEmpty(request.ApiKey) ? ApiKey : request.ApiKey; 39 | 40 | var collectionJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); 41 | 42 | return JsonConvert.DeserializeObject>(collectionJson, new JsonApiSerializerSettings()).FirstOrDefault(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/pubg-dotnet.UnitTests/JsonConverters/DefaultEnumConverterTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using JsonApiSerializer; 3 | using Newtonsoft.Json; 4 | using Pubg.Net.Infrastructure.Attributes; 5 | using Pubg.Net.Infrastructure.JsonConverters; 6 | using System; 7 | using System.Collections.Generic; 8 | using Xunit; 9 | 10 | namespace Pubg.Net.UnitTests.JsonConverters 11 | { 12 | public class DefaultEnumConverterTests 13 | { 14 | public class TestArticle 15 | { 16 | [JsonProperty] 17 | public int Id { get; set; } 18 | 19 | [JsonProperty] 20 | public TestEnum TestEnum { get; set; } 21 | } 22 | 23 | [JsonConverter(typeof(DefaultValueStringEnumConverter))] 24 | public enum TestEnum 25 | { 26 | [DefaultEnumMember] 27 | Default = 0, 28 | NonDefault = 1 29 | } 30 | 31 | string jsonApiLiteral = 32 | @"{ 33 | ""data"": 34 | { 35 | ""type"": ""TestArticle"", 36 | ""id"": ""1"", 37 | ""attributes"": 38 | { 39 | ""testEnum"": ""%%ENUM_VALUE%%"", 40 | } 41 | } 42 | }"; 43 | 44 | [Fact] 45 | public void DefaultValueStringEnumConverter_Can_ConvertToValue() 46 | { 47 | var value = TestEnum.NonDefault; 48 | var valueJson = jsonApiLiteral.Replace("%%ENUM_VALUE%%", value.ToString()); 49 | var obj = JsonConvert.DeserializeObject(valueJson); 50 | 51 | obj.TestEnum.Should().Equals(value); 52 | } 53 | 54 | [Fact] 55 | public void DefaultValueStringEnumConverter_Can_ConvertFromEmptyString() 56 | { 57 | var valueJson = jsonApiLiteral.Replace("%%ENUM_VALUE%%", ""); 58 | var obj = JsonConvert.DeserializeObject(valueJson); 59 | 60 | obj.TestEnum.Should().Equals(TestEnum.Default); 61 | } 62 | 63 | [Fact] 64 | public void DefaultValueStringEnumConverter_Can_ConvertFromUnknownValue() 65 | { 66 | var valueJson = jsonApiLiteral.Replace("%%ENUM_VALUE%%", "RandomValue"); 67 | var obj = JsonConvert.DeserializeObject(valueJson); 68 | 69 | obj.TestEnum.Should().Equals(TestEnum.Default); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Stats/PubgParticipantStats.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Models.Participants; 3 | 4 | namespace Pubg.Net 5 | { 6 | public class PubgParticipantStats 7 | { 8 | [JsonProperty] 9 | public string Name { get; set; } 10 | 11 | [JsonProperty] 12 | public string PlayerId { get; set; } 13 | 14 | [JsonProperty("DBNOs")] 15 | public int DBNOs { get; set; } 16 | 17 | [JsonProperty] 18 | public int Assists { get; set; } 19 | 20 | [JsonProperty] 21 | public int Boosts { get; set; } 22 | 23 | [JsonProperty] 24 | public double DamageDealt { get; set; } 25 | 26 | [JsonProperty] 27 | public PubgParticipantDeathType DeathType { get; set; } 28 | 29 | [JsonProperty] 30 | public int HeadshotKills { get; set; } 31 | 32 | [JsonProperty] 33 | public int Heals { get; set; } 34 | 35 | [JsonProperty] 36 | public int KillPlace { get; set; } 37 | 38 | [JsonProperty] 39 | public int KillPointsDelta { get; set; } 40 | 41 | [JsonProperty] 42 | public int KillStreaks { get; set; } 43 | 44 | [JsonProperty] 45 | public int Kills { get; set; } 46 | 47 | [JsonProperty] 48 | public int LastKillPoints { get; set; } 49 | 50 | [JsonProperty] 51 | public int LastWinPoints { get; set; } 52 | 53 | [JsonProperty] 54 | public double LongestKill { get; set; } 55 | 56 | [JsonProperty] 57 | public int MostDamage { get; set; } 58 | 59 | [JsonProperty] 60 | public int Revives { get; set; } 61 | 62 | [JsonProperty] 63 | public double RideDistance { get; set; } 64 | 65 | [JsonProperty] 66 | public int RoadKills { get; set; } 67 | 68 | [JsonProperty] 69 | public float SwimDistance { get; set; } 70 | 71 | [JsonProperty] 72 | public int TeamKills { get; set; } 73 | 74 | [JsonProperty] 75 | public double TimeSurvived { get; set; } 76 | 77 | [JsonProperty] 78 | public int VehicleDestroys { get; set; } 79 | 80 | [JsonProperty] 81 | public double WalkDistance { get; set; } 82 | 83 | [JsonProperty] 84 | public int WeaponsAcquired { get; set; } 85 | 86 | [JsonProperty] 87 | public int WinPlace { get; set; } 88 | 89 | [JsonProperty] 90 | public int WinPointsDelta { get; set; } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/Tournaments/PubgTournamentService.cs: -------------------------------------------------------------------------------- 1 | using JsonApiSerializer; 2 | using Newtonsoft.Json; 3 | using Pubg.Net.Infrastructure; 4 | using Pubg.Net.Services; 5 | using Pubg.Net.Values; 6 | using System.Collections.Generic; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace Pubg.Net 11 | { 12 | public class PubgTournamentService : PubgService 13 | { 14 | public PubgTournamentService() : base() { } 15 | public PubgTournamentService(string apiKey) : base(apiKey) { } 16 | 17 | public virtual IEnumerable GetTournaments(string apiKey = null) 18 | { 19 | var url = Api.Tournaments.TournamentsEndpoint(); 20 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 21 | 22 | var matchJson = HttpRequestor.GetString(url, apiKey); 23 | 24 | return JsonConvert.DeserializeObject>(matchJson, new JsonApiSerializerSettings()); 25 | } 26 | 27 | public async virtual Task> GetTournamentsAsync(string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 28 | { 29 | var url = Api.Tournaments.TournamentsEndpoint(); 30 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 31 | 32 | var matchJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); 33 | 34 | return JsonConvert.DeserializeObject>(matchJson, new JsonApiSerializerSettings()); 35 | } 36 | 37 | public virtual PubgTournament GetTournament(string tournamentId, string apiKey = null) 38 | { 39 | var url = Api.Tournaments.TournamentsEndpoint(tournamentId); 40 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 41 | 42 | var matchJson = HttpRequestor.GetString(url, apiKey); 43 | 44 | return JsonConvert.DeserializeObject(matchJson, new JsonApiSerializerSettings()); 45 | } 46 | 47 | public async virtual Task GetTournamentAsync(string tournamentId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 48 | { 49 | var url = Api.Tournaments.TournamentsEndpoint(tournamentId); 50 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 51 | 52 | var matchJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); 53 | 54 | return JsonConvert.DeserializeObject(matchJson, new JsonApiSerializerSettings()); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /pubg-dotnet.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2010 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "pubg-dotnet", "src\pubg-dotnet\pubg-dotnet.csproj", "{8328DC72-47E0-48D5-9D46-190022FBAA85}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F9EECF5B-8169-4AE5-A281-AB7F25A94F29}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{67ADB0E2-8F40-40F8-B53F-7972BE5D8511}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "pubg-dotnet.Tests", "test\pubg-dotnet.Tests\pubg-dotnet.Tests.csproj", "{96E7E85F-67F2-4BE7-A2D6-607939FA5495}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pubg-dotnet.UnitTests", "test\pubg-dotnet.UnitTests\pubg-dotnet.UnitTests.csproj", "{3A628517-FF68-420B-90CF-B899F064D71D}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Release|Any CPU = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {8328DC72-47E0-48D5-9D46-190022FBAA85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {8328DC72-47E0-48D5-9D46-190022FBAA85}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {8328DC72-47E0-48D5-9D46-190022FBAA85}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {8328DC72-47E0-48D5-9D46-190022FBAA85}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {96E7E85F-67F2-4BE7-A2D6-607939FA5495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {96E7E85F-67F2-4BE7-A2D6-607939FA5495}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {96E7E85F-67F2-4BE7-A2D6-607939FA5495}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {96E7E85F-67F2-4BE7-A2D6-607939FA5495}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {3A628517-FF68-420B-90CF-B899F064D71D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {3A628517-FF68-420B-90CF-B899F064D71D}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {3A628517-FF68-420B-90CF-B899F064D71D}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {3A628517-FF68-420B-90CF-B899F064D71D}.Release|Any CPU.Build.0 = Release|Any CPU 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(NestedProjects) = preSolution 39 | {8328DC72-47E0-48D5-9D46-190022FBAA85} = {F9EECF5B-8169-4AE5-A281-AB7F25A94F29} 40 | {96E7E85F-67F2-4BE7-A2D6-607939FA5495} = {67ADB0E2-8F40-40F8-B53F-7972BE5D8511} 41 | {3A628517-FF68-420B-90CF-B899F064D71D} = {67ADB0E2-8F40-40F8-B53F-7972BE5D8511} 42 | EndGlobalSection 43 | GlobalSection(ExtensibilityGlobals) = postSolution 44 | SolutionGuid = {391B40FE-FE56-4259-9C99-7EC1F5970B4D} 45 | EndGlobalSection 46 | EndGlobal 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![PUBG Developer API Logo](https://d16ehlcspsm2m.cloudfront.net/0.0.39/assets/pubg/logo_large-a7a4f3e0242846f9d0d722ef21ad7729defdf2bac2d04ce82255a2b7b9ec4741.png) 2 | 3 | 4 | # Pubg-DotNet [![Build status](https://ci.appveyor.com/api/projects/status/w3vk9q4avelqpgcp?svg=true)](https://ci.appveyor.com/project/GavinPower747/pubg-dotnet) 5 | 6 | A sync/async client library for communicating with the Pubg developer api. Supporting .Net Standard 2.0. 7 | 8 | Contact GavinPower747 on the Pubg Api Discord for more details 9 | 10 | ## Installation 11 | 12 | ### Install via Nuget 13 | 14 | From the nuget command line: 15 | 16 | nuget install Pubg-DotNet 17 | 18 | From the .Net CLI 19 | 20 | dotnet add package Pubg-DotNet 21 | 22 | From Package Manager: 23 | 24 | PM> Install-Package Pubg-DotNet 25 | 26 | From within Visual Studio: 27 | 28 | 1. Open the Solution Explorer. 29 | 2. Right-click on a project within your solution. 30 | 3. Click on *Manage NuGet Packages...* 31 | 4. Click on the *Browse* tab and search for "Pubg-DotNet". 32 | 5. Click on the Pubg-DotNet package, select the appropriate version in the right-tab and click *Install*. 33 | 34 | # Contributions 35 | All contributions are welcome, feel free to create an issue to suggest improvements/missing features or just submit a PR to our Development branch with any work you want to contribute yourself. 36 | 37 | ## Configuring Api Key 38 | 39 | There are a number of ways to configure your api key. You can choose any of the below methods based on your circumstances, you only need to follow one of the examples below. 40 | 41 | 1. Static Configuration Method 42 | 43 | In order to configure your Api Key through our config class you just need to add the following code: 44 | 45 | **In Your Startup class** 46 | ```csharp 47 | PubgApiConfiguration.Configure(opt => 48 | { 49 | opt.ApiKey = "myApiKey"; 50 | }); 51 | ``` 52 | 53 | 2. Per Request 54 | 55 | When making a request to one of our services, all of our request objects contain an ApiKey field, simply provide your api key here. Below we use the GetPubgPlayersRequest as an example 56 | 57 | ```csharp 58 | var playerService = new PubgPlayerService(); 59 | var request = new GetPubgPlayersRequest 60 | { 61 | ApiKey = "myApiKey", 62 | PlayerNames = new string[] { "myplayername" } 63 | } 64 | 65 | playerService.GetPlayers(PubgRegion.PCEurope, request); 66 | ``` 67 | 68 | Or if the method doesn't need a request object the API key can be provided using an optional parameter at the end of each method call 69 | 70 | ```csharp 71 | var playerService = new PubgPlayerService(); 72 | 73 | playerService.GetPlayer(PubgRegion.PCEurope, "myplayerid", apiKey: "MyApiKey"); 74 | ``` 75 | 76 | 3. Service Instanciation 77 | 78 | When instanciating your service you can supply it with your api key 79 | 80 | ```csharp 81 | var matchService = new PubgMatchService("myApiKey"); 82 | ``` 83 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Match/PubgGameMode.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pubg.Net.Infrastructure.Attributes; 3 | using Pubg.Net.Infrastructure.JsonConverters; 4 | using System.Runtime.Serialization; 5 | 6 | namespace Pubg.Net 7 | { 8 | [JsonConverter(typeof(DefaultValueStringEnumConverter))] 9 | public enum PubgGameMode 10 | { 11 | [DefaultEnumMember] 12 | Unknown, 13 | [EnumMember (Value = "duo")] 14 | Duo, 15 | [EnumMember (Value = "duo-fpp")] 16 | DuoFpp, 17 | [EnumMember (Value = "solo")] 18 | Solo, 19 | [EnumMember (Value = "solo-fpp")] 20 | SoloFpp, 21 | [EnumMember (Value = "squad")] 22 | Squad, 23 | [EnumMember (Value = "squad-fpp")] 24 | SquadFpp, 25 | [EnumMember (Value = "conquest-duo")] 26 | ConquestDuo, 27 | [EnumMember (Value = "conquest-duo-fpp")] 28 | ConquestDuoFpp, 29 | [EnumMember (Value = "conquest-solo")] 30 | ConquestSolo, 31 | [EnumMember (Value = "conquest-solo-fpp")] 32 | ConquestSoloFpp, 33 | [EnumMember (Value = "conquest-squad")] 34 | ConquestSquad, 35 | [EnumMember (Value = "conquest-squad-fpp")] 36 | ConquestSquadFpp, 37 | [EnumMember (Value = "esports-duo")] 38 | EsportsDuo, 39 | [EnumMember (Value = "esports-duo-fpp")] 40 | EsportsDuoFpp, 41 | [EnumMember (Value = "esports-solo")] 42 | EsportsSolo, 43 | [EnumMember (Value = "esports-solo-fpp")] 44 | EsportsSoloFpp, 45 | [EnumMember (Value = "esports-squad")] 46 | EsportsSquad, 47 | [EnumMember (Value = "esports-squad-fpp")] 48 | EsportsSquadFpp, 49 | [EnumMember (Value = "normal-duo")] 50 | NormalDuo, 51 | [EnumMember (Value = "normal-duo-fpp")] 52 | NormalDuoFpp, 53 | [EnumMember (Value = "normal-solo")] 54 | NormalSolo, 55 | [EnumMember (Value = "normal-solo-fpp")] 56 | NormalSoloFpp, 57 | [EnumMember (Value = "normal-squad")] 58 | NormalSquad, 59 | [EnumMember (Value = "normal-squad-fpp")] 60 | NormalSquadFpp, 61 | [EnumMember (Value = "war-duo")] 62 | WarDuo, 63 | [EnumMember (Value = "war-duo-fpp")] 64 | WarDuoFpp, 65 | [EnumMember (Value = "war-solo")] 66 | WarSolo, 67 | [EnumMember (Value = "war-solo-fpp")] 68 | WarSoloFpp, 69 | [EnumMember (Value = "war-squad")] 70 | WarSquad, 71 | [EnumMember (Value = "war-squad-fpp")] 72 | WarSquadFpp, 73 | [EnumMember (Value = "zombie-duo")] 74 | ZombieDuo, 75 | [EnumMember (Value = "zombie-duo-fpp")] 76 | ZombieDuoFpp, 77 | [EnumMember (Value = "zombie-solo")] 78 | ZombieSolo, 79 | [EnumMember (Value = "zombie-solo-fpp")] 80 | ZombieSoloFpp, 81 | [EnumMember (Value = "zombie-squad")] 82 | ZombieSquad, 83 | [EnumMember (Value = "zombie-squad-fpp")] 84 | ZombieSquadFpp 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/Matches/MatchTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using Pubg.Net.Tests.Util; 3 | using Pubg.Net.Extensions; 4 | using System.Linq; 5 | using Xunit; 6 | using Pubg.Net.Exceptions; 7 | using System; 8 | using pubg.net.Tests; 9 | 10 | namespace Pubg.Net.Tests.Matches 11 | { 12 | public class MatchTests : TestBase 13 | { 14 | [Fact] 15 | public void Can_Retrieve_Match_ForPC() 16 | { 17 | var samples = Storage.GetSamples(PubgPlatform.Steam); 18 | var matchService = new PubgMatchService(Storage.ApiKey); 19 | 20 | var match = matchService.GetMatch(samples.MatchIds.FirstOrDefault()); 21 | 22 | match.Rosters.Should().NotBeNull(); 23 | match.GameMode.Should().NotBe(PubgGameMode.Unknown); 24 | 25 | Assert.All(match.Rosters, r => r.Stats.Rank.Should().BeGreaterThan(0)); 26 | match.Rosters.Should().ContainSingle(x => x.Won == true); 27 | 28 | var participants = match.Rosters.SelectMany(x => x.Participants); 29 | 30 | participants.Should().NotBeNullOrEmpty(); 31 | 32 | Assert.All(participants, p => p.Stats.Should().NotBeNull()); 33 | Assert.All(participants, p => p.Stats.KillPlace.Should().BeGreaterThan(0)); 34 | Assert.All(participants, p => p.Stats.WinPlace.Should().BeGreaterThan(0)); 35 | Assert.All(participants, p => p.Id.Should().NotBeNullOrWhiteSpace()); 36 | } 37 | 38 | [Fact] 39 | public void Can_Retrieve_Match_ForConsole() 40 | { 41 | var samples = Storage.GetSamples(PubgPlatform.Console); 42 | var matchService = new PubgMatchService(Storage.ApiKey); 43 | 44 | var match = matchService.GetMatch(PubgPlatform.Console, samples.MatchIds.FirstOrDefault()); 45 | 46 | match.Rosters.Should().NotBeNull(); 47 | 48 | Assert.All(match.Rosters, r => r.Stats.Rank.Should().BeGreaterThan(0)); 49 | match.Rosters.Should().ContainSingle(x => x.Won == true); 50 | 51 | var participants = match.Rosters.SelectMany(x => x.Participants); 52 | 53 | participants.Should().NotBeNullOrEmpty(); 54 | 55 | Assert.All(participants, p => p.Stats.Should().NotBeNull()); 56 | Assert.All(participants, p => p.Stats.KillPlace.Should().BeGreaterThan(0)); 57 | Assert.All(participants, p => p.Stats.WinPlace.Should().BeGreaterThan(0)); 58 | Assert.All(participants, p => p.Id.Should().NotBeNullOrWhiteSpace()); 59 | } 60 | 61 | [Fact] 62 | public void Throws_Exception_When_NotFound_OnPC() 63 | { 64 | Assert.Throws(() => new PubgMatchService(Storage.ApiKey).GetMatch(Guid.Empty.ToString())); 65 | } 66 | 67 | [Fact] 68 | public void Throws_Exception_When_NotFound_OnConsole() 69 | { 70 | Assert.Throws(() => new PubgMatchService(Storage.ApiKey).GetMatch(PubgPlatform.Console, Guid.Empty.ToString())); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Models/Stats/PubgGameModeStats.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Pubg.Net.Models.Stats 4 | { 5 | public class PubgGameModeStats 6 | { 7 | [JsonProperty] 8 | public int Assists { get; set; } 9 | 10 | [JsonProperty] 11 | public float BestRankPoints { get; set; } 12 | 13 | [JsonProperty] 14 | public int Boosts { get; set; } 15 | 16 | [JsonProperty] 17 | public int DBNOs { get; set; } 18 | 19 | [JsonProperty] 20 | public int DailyKills { get; set; } 21 | 22 | [JsonProperty] 23 | public int DailyWins { get; set; } 24 | 25 | [JsonProperty] 26 | public float DamageDealt { get; set; } 27 | 28 | [JsonProperty] 29 | public int Days { get; set; } 30 | 31 | [JsonProperty] 32 | public int HeadshotKills { get; set; } 33 | 34 | [JsonProperty] 35 | public int Heals { get; set; } 36 | 37 | [JsonProperty] 38 | public float KillPoints { get; set; } 39 | 40 | [JsonProperty] 41 | public int Kills { get; set; } 42 | 43 | [JsonProperty] 44 | public float LongestKill { get; set; } 45 | 46 | [JsonProperty] 47 | public float LongestTimeSurvived { get; set; } 48 | 49 | [JsonProperty] 50 | public int Losses { get; set; } 51 | 52 | [JsonProperty] 53 | public int MaxKillStreaks { get; set; } 54 | 55 | [JsonProperty] 56 | public float MostSurvivalTime { get; set; } 57 | 58 | [JsonProperty] 59 | public float RankPoints { get; set; } 60 | 61 | [JsonProperty] 62 | public PubgRankPointsTitle RankPointsTitle { get; set; } 63 | 64 | [JsonProperty] 65 | public int Revives { get; set; } 66 | 67 | [JsonProperty] 68 | public float RideDistance { get; set; } 69 | 70 | [JsonProperty] 71 | public int RoadKills { get; set; } 72 | 73 | [JsonProperty] 74 | public int RoundMostKills { get; set; } 75 | 76 | [JsonProperty] 77 | public int RoundsPlayed { get; set; } 78 | 79 | [JsonProperty] 80 | public int Suicides { get; set; } 81 | 82 | [JsonProperty] 83 | public float SwimDistance { get; set; } 84 | 85 | [JsonProperty] 86 | public int TeamKills { get; set; } 87 | 88 | [JsonProperty] 89 | public float TimeSurvived { get; set; } 90 | 91 | [JsonProperty] 92 | public int Top10s { get; set; } 93 | 94 | [JsonProperty] 95 | public int VehicleDestroys { get; set; } 96 | 97 | [JsonProperty] 98 | public float WalkDistance { get; set; } 99 | 100 | [JsonProperty] 101 | public int WeaponAcquired { get; set; } 102 | 103 | [JsonProperty] 104 | public int WeeklyKills { get; set; } 105 | 106 | [JsonProperty] 107 | public int WeeklyWins { get; set; } 108 | 109 | [JsonProperty] 110 | public float WinPoints { get; set; } 111 | 112 | [JsonProperty] 113 | public float WinRatio { get; set; } 114 | 115 | [JsonProperty] 116 | public int Wins { get; set; } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Infrastructure/HttpRequestor.cs: -------------------------------------------------------------------------------- 1 | using Pubg.Net.Exceptions; 2 | using System.Linq; 3 | using System.Net; 4 | using System.Net.Http; 5 | using System.Net.Http.Headers; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace Pubg.Net.Infrastructure 10 | { 11 | internal static class HttpRequestor 12 | { 13 | internal static HttpClient HttpClient { get; private set; } 14 | 15 | static HttpRequestor() 16 | { 17 | var clientHandler = new HttpClientHandler 18 | { 19 | AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate 20 | }; 21 | 22 | HttpClient = new HttpClient(clientHandler); 23 | 24 | var timeout = PubgApiConfiguration.GetHttpTimeout(); 25 | 26 | if (timeout.HasValue) 27 | HttpClient.Timeout = timeout.Value; 28 | } 29 | 30 | public static string GetString(string url, string apiToken = null) 31 | { 32 | var request = BuildRequest(url, apiToken); 33 | 34 | var response = HttpClient.SendAsync(request).ConfigureAwait(false).GetAwaiter().GetResult(); 35 | var responseContent = response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult(); 36 | 37 | return HandleResponse(response, responseContent); 38 | } 39 | 40 | public async static Task GetStringAsync(string url, CancellationToken cancellationToken, string apiToken = null) 41 | { 42 | var request = BuildRequest(url, apiToken); 43 | 44 | var response = await HttpClient.SendAsync(request, cancellationToken).ConfigureAwait(false); 45 | var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); 46 | 47 | return HandleResponse(response, responseContent); 48 | } 49 | 50 | private static HttpRequestMessage BuildRequest(string url, string apiToken) 51 | { 52 | var request = new HttpRequestMessage(HttpMethod.Get, url); 53 | 54 | if(!string.IsNullOrEmpty(apiToken)) 55 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiToken); 56 | 57 | request.Headers.Add("Accept-Encoding", "gzip"); 58 | request.Headers.Add("Accept", "application/vnd.api+json"); 59 | 60 | return request; 61 | } 62 | 63 | private static string HandleResponse(HttpResponseMessage response, string responseContent) 64 | { 65 | if (response.IsSuccessStatusCode) 66 | return responseContent; 67 | 68 | throw BuildException(response, responseContent); 69 | } 70 | 71 | private static PubgException BuildException(HttpResponseMessage response, string responseContent) 72 | { 73 | switch(response.StatusCode) 74 | { 75 | case HttpStatusCode.Unauthorized: return new PubgUnauthorizedException(); 76 | case HttpStatusCode.UnsupportedMediaType: return new PubgContentTypeException(); 77 | case HttpStatusCode.NotFound: return new PubgNotFoundException(); 78 | case (HttpStatusCode) 429: return new PubgTooManyRequestsException(response.Headers.GetValues("X-RateLimit-Reset").FirstOrDefault()); 79 | default: 80 | var errors = ErrorMapper.MapErrors(responseContent); 81 | return new PubgException("Errors have occured with your request", response.StatusCode, errors); 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/Util/Storage.cs: -------------------------------------------------------------------------------- 1 | using pubg.net.Tests.Extensions; 2 | using Pubg.Net; 3 | using Pubg.Net.Extensions; 4 | using Pubg.Net.Models.Base; 5 | using Pubg.Net.Models.Samples; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | 11 | namespace Pubg.Net.Tests.Util 12 | { 13 | public static class Storage 14 | { 15 | static Storage() 16 | { 17 | StoredItems = new List(); 18 | } 19 | 20 | public static string ApiKey => Environment.GetEnvironmentVariable("PUBG_API_KEY"); 21 | public static List StoredItems { get; set; } 22 | 23 | public static PubgMatchSample GetSamples(PubgPlatform platform) 24 | { 25 | var samples = StoredItems.OfType().FirstOrDefault(p => p.ShardId == platform.Serialize()); 26 | 27 | if (samples != null) 28 | return samples; 29 | 30 | var sampleService = new PubgSamplesService(ApiKey); 31 | 32 | samples = sampleService.GetMatchSamples(platform); 33 | 34 | StoredItems.Add(samples); 35 | 36 | return samples; 37 | } 38 | 39 | public static PubgPlayer GetPlayer(PubgPlatform platform) 40 | { 41 | var player = StoredItems.OfType().FirstOrDefault(p => p.ShardId == platform.Serialize()); 42 | 43 | if (player != null) 44 | return player; 45 | 46 | var playerService = new PubgPlayerService(ApiKey); 47 | 48 | var region = platform == PubgPlatform.Console ? PubgRegion.XboxEurope : PubgRegion.PCEurope; 49 | 50 | var playerNames = GetMatch(platform).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.Name).Take(5); 51 | var players = playerService.GetPlayers(platform, new GetPubgPlayersRequest { PlayerNames = playerNames.ToArray() }); 52 | 53 | StoredItems.AddRange(players); 54 | 55 | return players.FirstOrDefault(); 56 | } 57 | 58 | public static PubgMatch GetMatch(PubgPlatform platform) 59 | { 60 | var match = StoredItems.OfType().FirstOrDefault(p => p.ShardId == platform.Serialize()); 61 | 62 | if (match != null) 63 | return match; 64 | 65 | var samples = GetSamples(platform); 66 | var matchService = new PubgMatchService(ApiKey); 67 | 68 | match = matchService.GetMatch(platform, samples.MatchIds.First()); 69 | 70 | StoredItems.Add(match); 71 | 72 | return match; 73 | } 74 | 75 | public static PubgSeason GetSeason(PubgRegion region) 76 | { 77 | PubgSeason season = null; 78 | 79 | if(region.IsXbox()) 80 | season = StoredItems.OfType().FirstOrDefault(p => p.Id.ToLowerInvariant().Contains("xb")); 81 | else if(region.IsPC()) 82 | season = StoredItems.OfType().FirstOrDefault(p => !p.Id.ToLowerInvariant().Contains("xb")); 83 | 84 | if (season != null) 85 | return season; 86 | 87 | var seasonService = new PubgSeasonService(ApiKey); 88 | List seasons = new List(); 89 | 90 | if (region.IsPC()) 91 | seasons = seasonService.GetSeasonsPC().ToList(); 92 | else if (region.IsXbox()) 93 | seasons = seasonService.GetSeasonsXbox(region).ToList(); 94 | 95 | seasons.ForEach(s => StoredItems.Add(s)); 96 | 97 | return seasons.LastOrDefault(); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /test/pubg-dotnet.UnitTests/JsonConverters/TelemetryConverterTests.cs: -------------------------------------------------------------------------------- 1 | using AutoFixture; 2 | using AutoFixture.Kernel; 3 | using FluentAssertions; 4 | using Newtonsoft.Json; 5 | using Pubg.Net.Models.Telemetry.Events; 6 | using System; 7 | using Xunit; 8 | 9 | namespace Pubg.Net.UnitTests.JsonConverters 10 | { 11 | 12 | public class TelemetryConverterTests 13 | { 14 | [Theory] 15 | [InlineData(typeof(LogCarePackageLand))] 16 | [InlineData(typeof(LogCarePackageSpawn))] 17 | [InlineData(typeof(LogGameStatePeriodic))] 18 | [InlineData(typeof(LogItemAttach))] 19 | [InlineData(typeof(LogItemDetach))] 20 | [InlineData(typeof(LogItemDrop))] 21 | [InlineData(typeof(LogItemEquip))] 22 | [InlineData(typeof(LogItemPickup))] 23 | [InlineData(typeof(LogItemUnequip))] 24 | [InlineData(typeof(LogItemUse))] 25 | [InlineData(typeof(LogMatchDefinition))] 26 | [InlineData(typeof(LogMatchEnd))] 27 | [InlineData(typeof(LogMatchStart))] 28 | [InlineData(typeof(LogPlayerAttack))] 29 | [InlineData(typeof(LogPlayerCreate))] 30 | [InlineData(typeof(LogPlayerKill))] 31 | [InlineData(typeof(LogPlayerLogin))] 32 | [InlineData(typeof(LogPlayerLogout))] 33 | [InlineData(typeof(LogPlayerPosition))] 34 | [InlineData(typeof(LogPlayerTakeDamage))] 35 | [InlineData(typeof(LogVehicleDestroy))] 36 | [InlineData(typeof(LogVehicleLeave))] 37 | [InlineData(typeof(LogVehicleRide))] 38 | [InlineData(typeof(LogArmorDestroy))] 39 | [InlineData(typeof(LogSwimStart))] 40 | [InlineData(typeof(LogSwimEnd))] 41 | [InlineData(typeof(LogWheelDestroy))] 42 | [InlineData(typeof(LogPlayerMakeGroggy))] 43 | [InlineData(typeof(LogPlayerRevive))] 44 | [InlineData(typeof(LogHeal))] 45 | [InlineData(typeof(LogItemPickupFromCarePackage))] 46 | [InlineData(typeof(LogItemPickupFromLootBox))] 47 | [InlineData(typeof(LogObjectDestroy))] 48 | [InlineData(typeof(LogParachuteLanding))] 49 | [InlineData(typeof(LogRedZoneEnded))] 50 | [InlineData(typeof(LogVaultStart))] 51 | [InlineData(typeof(LogWeaponFireCount))] 52 | public void Can_Convert_All_TelemeteryEvents(Type eventType) 53 | { 54 | var fixture = new Fixture(); 55 | var testEvent = (PubgTelemetryEvent) new SpecimenContext(fixture).Resolve(eventType); 56 | testEvent.Type = eventType.Name; 57 | 58 | var json = JsonConvert.SerializeObject(testEvent); 59 | 60 | var deserializedObject = JsonConvert.DeserializeObject(json); 61 | 62 | Assert.Equal(eventType, deserializedObject.GetType()); 63 | 64 | deserializedObject.Should().BeEquivalentTo(testEvent); 65 | } 66 | 67 | [Fact] 68 | public void UnknownEvent_Returns_UnknownEventObject_WithTypeProperty() 69 | { 70 | var testEvent = new { _T = "RandomString", TestProp = "TestProp" }; 71 | 72 | var json = JsonConvert.SerializeObject(testEvent); 73 | 74 | var deserializedObject = JsonConvert.DeserializeObject(json); 75 | 76 | Assert.Equal(typeof(UnknownTelemetryEvent), deserializedObject.GetType()); 77 | 78 | deserializedObject.As().RawContent.Should().Equals(deserializedObject); 79 | } 80 | 81 | [Fact] 82 | public void UnknownEvent_Returns_UnknownEventObject_WithoutTypeProperty() 83 | { 84 | var testEvent = new { TestProp = "TestProp" }; 85 | 86 | var json = JsonConvert.SerializeObject(testEvent); 87 | 88 | var deserializedObject = JsonConvert.DeserializeObject(json); 89 | 90 | Assert.Equal(typeof(UnknownTelemetryEvent), deserializedObject.GetType()); 91 | 92 | deserializedObject.As().RawContent.Should().Equals(deserializedObject); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Values/Api.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Pubg.Net.Extensions; 4 | 5 | namespace Pubg.Net.Values 6 | { 7 | internal static class Api 8 | { 9 | internal const string DefaultBaseUrl = "https://api.pubg.com"; 10 | internal static string ShardedBaseUrl = PubgApiConfiguration.GetApiBase() + "/shards/{0}"; 11 | 12 | internal static class Leaderboard 13 | { 14 | internal static string LeaderboardEndpoint(PubgRegion region, string seasonId, PubgGameMode gameMode) 15 | => string.Format(ShardedBaseUrl + "/leaderboards/{1}/{2}", region.Serialize(), seasonId, 16 | gameMode.Serialize()); 17 | } 18 | 19 | internal static class Matches 20 | { 21 | internal static string MatchesEndpoint(PubgPlatform platform) => 22 | string.Format(ShardedBaseUrl + "/matches", platform.Serialize()); 23 | 24 | internal static string MatchesEndpoint(PubgPlatform platform, string matchId) => 25 | MatchesEndpoint(platform) + $"/{matchId}"; 26 | } 27 | 28 | internal static class Status 29 | { 30 | internal static string StatusEndpoint() => PubgApiConfiguration.GetApiBase() + "/status"; 31 | } 32 | 33 | internal static class Players 34 | { 35 | internal static string PlayersEndpoint(PubgPlatform platform) => 36 | string.Format(ShardedBaseUrl + "/players", platform.Serialize()); 37 | 38 | internal static string PlayersEndpoint(PubgPlatform platform, string playerId) => 39 | PlayersEndpoint(platform) + $"/{playerId}"; 40 | 41 | internal static string PlayerSeasonsEndpoint(PubgPlatform platform, string playerId, string seasonId) => 42 | string.Format(ShardedBaseUrl + "/players/{1}/seasons/{2}", platform.Serialize(), playerId, seasonId); 43 | } 44 | 45 | internal static class Samples 46 | { 47 | internal static string SamplesEndpoint(PubgPlatform platform) => 48 | string.Format(ShardedBaseUrl + "/samples", platform.Serialize()); 49 | } 50 | 51 | internal static class Seasons 52 | { 53 | internal static string SeasonsPCEndpoint(PubgPlatform platform) => 54 | string.Format(ShardedBaseUrl + "/seasons", platform.Serialize()); 55 | 56 | internal static string SeasonsXboxEndpoint(PubgRegion region) => 57 | string.Format(ShardedBaseUrl + "/seasons", region.Serialize()); 58 | } 59 | 60 | internal static class Tournaments 61 | { 62 | internal static string TournamentsEndpoint() => PubgApiConfiguration.GetApiBase() + "/tournaments"; 63 | 64 | internal static string TournamentsEndpoint(string tournamentId) => 65 | TournamentsEndpoint() + $"/{tournamentId}"; 66 | } 67 | 68 | internal static class LifetimeStats 69 | { 70 | internal static string LifetimeStatsEndpoint(PubgPlatform platform, string accountId) => 71 | string.Format($"{ShardedBaseUrl}/players/{accountId}/seasons/lifetime", platform.Serialize()); 72 | 73 | internal static string LifetimeStatsEndpoint(PubgPlatform platform, PubgGameMode gameMode, IEnumerable playerIds) => 74 | string.Format($"{ShardedBaseUrl}/seasons/lifetime/gameMode/{gameMode.Serialize()}/players?filter[playerIds]={string.Join(",", playerIds)}", platform.Serialize()); 75 | } 76 | 77 | internal static class Masteries 78 | { 79 | internal static string WeaponMasteryEndpoint(PubgPlatform platform, string accountId) => 80 | string.Format($"{ShardedBaseUrl}/players/{accountId}/weapon_mastery", platform.Serialize()); 81 | 82 | internal static string SurvivalMasteryEndpoint(PubgPlatform platform, string accountId) => 83 | string.Format($"{ShardedBaseUrl}/players/{accountId}/survival_mastery", platform.Serialize()); 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/Matches/PubgMatchService.cs: -------------------------------------------------------------------------------- 1 | using Pubg.Net.Services; 2 | using Pubg.Net.Infrastructure; 3 | using Pubg.Net.Values; 4 | using System.Collections.Generic; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using Newtonsoft.Json; 8 | using JsonApiSerializer; 9 | using System.Linq; 10 | 11 | namespace Pubg.Net 12 | { 13 | public class PubgMatchService : PubgService 14 | { 15 | public PubgMatchService() : base() { } 16 | public PubgMatchService(string apiKey) : base(apiKey) { } 17 | 18 | /// 19 | /// Get a specified match from the Api from the default platform (steam) 20 | /// 21 | /// The ID for the specified match 22 | /// Your Api Key (optional, not needed if specified elsewhere) 23 | /// PubgMatch object for the specified ID 24 | /// Exception thrown on the API side, details included on object 25 | /// The api is unable to find the specified match 26 | /// You have exceeded your rate limit 27 | /// Invalid API Key 28 | public virtual PubgMatch GetMatch(string matchId, string apiKey = null) => GetMatch(PubgPlatform.Steam, matchId, apiKey); 29 | 30 | /// 31 | /// Get a specified match from the Api from the specified platform 32 | /// 33 | /// The platform the match is on 34 | /// The ID for the specified match 35 | /// Your Api Key (optional, not needed if specified elsewhere) 36 | /// PubgMatch object for the specified ID 37 | /// Exception thrown on the API side, details included on object 38 | /// The api is unable to find the specified match 39 | /// You have exceeded your rate limit 40 | /// Invalid API Key 41 | public virtual PubgMatch GetMatch(PubgPlatform platform, string matchId, string apiKey = null) 42 | { 43 | var url = Api.Matches.MatchesEndpoint(platform, matchId); 44 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 45 | 46 | var matchJson = HttpRequestor.GetString(url, apiKey); 47 | 48 | return JsonConvert.DeserializeObject>(matchJson, new JsonApiSerializerSettings()).FirstOrDefault(); 49 | } 50 | 51 | /// 52 | /// Get a specified match from the Api from the specified platform asychronously 53 | /// 54 | /// The platform the match is on 55 | /// The ID for the specified match 56 | /// Your Api Key (optional, not needed if specified elsewhere) 57 | /// PubgMatch object for the specified ID 58 | /// Exception thrown on the API side, details included on object 59 | /// The api is unable to find the specified match 60 | /// You have exceeded your rate limit 61 | /// Invalid API Key 62 | public async virtual Task GetMatchAsync(PubgPlatform region, string matchId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 63 | { 64 | var url = Api.Matches.MatchesEndpoint(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>(matchJson, new JsonApiSerializerSettings()).FirstOrDefault(); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /test/pubg-dotnet.UnitTests/JsonConverters/RelationshipIdConverterTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using JsonApiSerializer; 3 | using Newtonsoft.Json; 4 | using Pubg.Net.Infrastructure.JsonConverters; 5 | using System; 6 | using System.Collections.Generic; 7 | using Xunit; 8 | 9 | namespace Pubg.Net.UnitTests.JsonConverters 10 | { 11 | public class RelationshipIdConverterTests 12 | { 13 | public class TestArticle 14 | { 15 | [JsonProperty] 16 | public int Id { get; set; } 17 | 18 | [JsonProperty] 19 | public string Title { get; set; } 20 | 21 | [JsonProperty] 22 | public string Body { get; set; } 23 | 24 | [JsonProperty] 25 | public DateTime Created { get; set; } 26 | 27 | [JsonProperty] 28 | public DateTime Updated { get; set; } 29 | 30 | [JsonProperty("author")] 31 | [JsonConverter(typeof(RelationshipIdConverter))] 32 | public IEnumerable AuthorIds { get; set; } 33 | } 34 | 35 | string jsonApiLiteral = 36 | @"{ 37 | ""data"": 38 | { 39 | ""type"": ""TestArticle"", 40 | ""id"": ""1"", 41 | ""attributes"": 42 | { 43 | ""title"": ""JSON API paints my bikeshed!"", 44 | ""body"": ""The shortest article. Ever."", 45 | ""created"": ""2015-05-22T14:56:29.000Z"", 46 | ""updated"": ""2015-05-22T14:56:28.000Z"" 47 | }, 48 | ""relationships"": 49 | { 50 | ""author"": 51 | { 52 | ""data"": 53 | [ 54 | {""id"": 42, ""type"": ""people""}, 55 | {""id"": 43, ""type"": ""people""}, 56 | {""id"": 44, ""type"": ""people""}, 57 | {""id"": 45, ""type"": ""people""} 58 | ] 59 | } 60 | } 61 | } 62 | }"; 63 | 64 | [Fact] 65 | public void RelationshipIdConverter_Converts_FromJsonApiFormat() 66 | { 67 | TestArticle testArticle = JsonConvert.DeserializeObject(jsonApiLiteral, new JsonApiSerializerSettings()); 68 | 69 | testArticle.Id.Should().Equals(1); 70 | testArticle.Title.Should().Equals("JSON API paints my bikeshed!"); 71 | testArticle.Body.Should().Equals("The shortest article. Ever."); 72 | testArticle.Created.Should().Equals(Convert.ToDateTime("2015-05-22T14:56:29.000Z")); 73 | testArticle.Updated.Should().Equals(Convert.ToDateTime("2015-05-22T14:56:28.000Z")); 74 | testArticle.AuthorIds.Should().NotBeNullOrEmpty(); 75 | testArticle.AuthorIds.Should().Contain(new [] { "42", "43", "44", "45" }); 76 | } 77 | 78 | [Fact] 79 | public void RelationshipIdConverter_Converts_FromJsonApiFormat_MultipleTimes() 80 | { 81 | TestArticle testArticle = JsonConvert.DeserializeObject(jsonApiLiteral, new JsonApiSerializerSettings()); 82 | 83 | var reserializedArticle = JsonConvert.SerializeObject(testArticle); 84 | var deserializedArticle = JsonConvert.DeserializeObject(reserializedArticle); 85 | 86 | deserializedArticle.Id.Should().Equals(1); 87 | deserializedArticle.Title.Should().Equals("JSON API paints my bikeshed!"); 88 | deserializedArticle.Body.Should().Equals("The shortest article. Ever."); 89 | deserializedArticle.Created.Should().Equals(Convert.ToDateTime("2015-05-22T14:56:29.000Z")); 90 | deserializedArticle.Updated.Should().Equals(Convert.ToDateTime("2015-05-22T14:56:28.000Z")); 91 | deserializedArticle.AuthorIds.Should().NotBeNullOrEmpty(); 92 | deserializedArticle.AuthorIds.Should().Contain(new[] { "42", "43", "44", "45" }); 93 | } 94 | 95 | [Fact] 96 | public void RelationshipIdConverter_Converts_FromApplicationJson() 97 | { 98 | var baseArticle = new TestArticle 99 | { 100 | Id = 1, 101 | Title = "adsd", 102 | Body = "asda", 103 | Created = Convert.ToDateTime("2015-05-22T14:56:29.000Z"), 104 | Updated = Convert.ToDateTime("2015-05-22T14:56:29.000Z"), 105 | AuthorIds = new[] { "11", "12" } 106 | }; 107 | 108 | var serializedArticle = JsonConvert.SerializeObject(baseArticle); 109 | 110 | var deSerialzedArticle = JsonConvert.DeserializeObject(serializedArticle); 111 | 112 | deSerialzedArticle.Id.Should().Equals(baseArticle.Id); 113 | deSerialzedArticle.Title.Should().Equals(baseArticle.Title); 114 | deSerialzedArticle.Body.Should().Equals(baseArticle.Body); 115 | deSerialzedArticle.Created.Should().Equals(baseArticle.Created); 116 | deSerialzedArticle.Updated.Should().Equals(baseArticle.Updated); 117 | deSerialzedArticle.AuthorIds.Should().NotBeNullOrEmpty(); 118 | deSerialzedArticle.AuthorIds.Should().Contain(baseArticle.AuthorIds); 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/Seasons/PubgSeasonService.cs: -------------------------------------------------------------------------------- 1 | using JsonApiSerializer; 2 | using Newtonsoft.Json; 3 | using Pubg.Net.Infrastructure; 4 | using Pubg.Net.Services; 5 | using Pubg.Net.Values; 6 | using System.Collections.Generic; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace Pubg.Net 11 | { 12 | public class PubgSeasonService : PubgService 13 | { 14 | public PubgSeasonService() : base() { } 15 | public PubgSeasonService(string apiKey) : base(apiKey) { } 16 | 17 | /// 18 | /// Get a list of seasons for the specified platform on the PC (default: Steam) 19 | /// 20 | /// The platform you wish to get the seasons for 21 | /// Your api key (optional) 22 | /// A list of seasons and their information 23 | /// Exception thrown on the API side, details included on object 24 | /// You have exceeded your rate limit 25 | /// Invalid API Key 26 | public virtual IEnumerable GetSeasonsPC(PubgPlatform platform = PubgPlatform.Steam, string apiKey = null) 27 | { 28 | var url = Api.Seasons.SeasonsPCEndpoint(platform); 29 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 30 | 31 | var seasonJson = HttpRequestor.GetString(url, apiKey); 32 | 33 | return JsonConvert.DeserializeObject>(seasonJson, new JsonApiSerializerSettings()); 34 | } 35 | 36 | /// 37 | /// Get a list of seasons for the specified platform on the PC (default: Steam) 38 | /// 39 | /// The platform you wish to get the seasons for 40 | /// Your api key (optional) 41 | /// A list of seasons and their information 42 | /// Exception thrown on the API side, details included on object 43 | /// You have exceeded your rate limit 44 | /// Invalid API Key 45 | public async virtual Task> GetSeasonsPCAsync(PubgPlatform platform = PubgPlatform.Steam, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 46 | { 47 | var url = Api.Seasons.SeasonsPCEndpoint(platform); 48 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 49 | 50 | var seasonJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); 51 | 52 | return JsonConvert.DeserializeObject>(seasonJson, new JsonApiSerializerSettings()); 53 | } 54 | 55 | /// 56 | /// Get a list of seasons for the specified region on Xbox 57 | /// 58 | /// The platform you wish to get the seasons for 59 | /// Your api key (optional) 60 | /// A list of seasons and their information 61 | /// Exception thrown on the API side, details included on object 62 | /// You have exceeded your rate limit 63 | /// Invalid API Key 64 | public virtual IEnumerable GetSeasonsXbox(PubgRegion region, string apiKey = null) 65 | { 66 | var url = Api.Seasons.SeasonsXboxEndpoint(region); 67 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 68 | 69 | var seasonJson = HttpRequestor.GetString(url, apiKey); 70 | 71 | return JsonConvert.DeserializeObject>(seasonJson, new JsonApiSerializerSettings()); 72 | } 73 | 74 | /// 75 | /// Get a list of seasons for the specified region on Xbox 76 | /// 77 | /// The platform you wish to get the seasons for 78 | /// Your api key (optional) 79 | /// A list of seasons and their information 80 | /// Exception thrown on the API side, details included on object 81 | /// You have exceeded your rate limit 82 | /// Invalid API Key 83 | public async virtual Task> GetSeasonsXboxAsync(PubgRegion region, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 84 | { 85 | var url = Api.Seasons.SeasonsXboxEndpoint(region); 86 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 87 | 88 | var seasonJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); 89 | 90 | return JsonConvert.DeserializeObject>(seasonJson, new JsonApiSerializerSettings()); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /test/pubg-dotnet.UnitTests/HttpRequestors/HttpRequestorTests.cs: -------------------------------------------------------------------------------- 1 | using AutoFixture; 2 | using FluentAssertions; 3 | using Newtonsoft.Json; 4 | using Pubg.Net.Exceptions; 5 | using Pubg.Net.Infrastructure; 6 | using Pubg.Net.Models.Errors; 7 | using RichardSzalay.MockHttp; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Net; 12 | using System.Net.Http; 13 | using System.Reflection; 14 | using Xunit; 15 | 16 | namespace Pubg.Net.UnitTests.HttpRequestors 17 | { 18 | public class HttpRequestorTests 19 | { 20 | [Fact] 21 | public void HttpRequestor_Takes_Timeout_From_Configuration() 22 | { 23 | var timeout = TimeSpan.FromMinutes(5); 24 | PubgApiConfiguration.SetHttpTimeout(timeout); 25 | 26 | var actualTimeout = HttpRequestor.HttpClient.Timeout; 27 | 28 | actualTimeout.Should().Equals(timeout); 29 | } 30 | 31 | [Fact] 32 | public void HttpRequestor_Attaches_ApiKey_To_Request() 33 | { 34 | var mockHttp = new MockHttpMessageHandler(); 35 | mockHttp.Fallback.Throw(new InvalidOperationException("No token attached to request")); 36 | 37 | var apiToken = "token"; 38 | 39 | mockHttp.Expect(HttpMethod.Get, "*").WithHeaders("Authorization", $"Bearer {apiToken}").Respond("application/json", "test string"); 40 | 41 | MockHttpClient(mockHttp); 42 | 43 | var result = HttpRequestor.GetString("http://www.random.url", apiToken); 44 | } 45 | 46 | [Fact] 47 | public void HttpRequestor_Requests_GzippedContent() 48 | { 49 | var mockHttp = new MockHttpMessageHandler(); 50 | mockHttp.Fallback.Throw(new InvalidOperationException("No gzip header was found")); 51 | 52 | mockHttp.Expect(HttpMethod.Get, "*").WithHeaders("Accept-Encoding", "gzip").Respond("application/json", "test string"); 53 | 54 | MockHttpClient(mockHttp); 55 | 56 | var result = HttpRequestor.GetString("http://www.random.url", "token"); 57 | } 58 | 59 | [Fact] 60 | public void HttpRequestor_Requests_CorrectMediaType() 61 | { 62 | var mockHttp = new MockHttpMessageHandler(); 63 | mockHttp.Fallback.Throw(new InvalidOperationException("No gzip header was found")); 64 | 65 | mockHttp.Expect(HttpMethod.Get, "*").WithHeaders("Accept", "application/vnd.api+json").Respond("application/json", "test string"); 66 | 67 | MockHttpClient(mockHttp); 68 | 69 | var result = HttpRequestor.GetString("http://www.random.url", "token"); 70 | } 71 | 72 | [Theory] 73 | [InlineData(HttpStatusCode.NotFound, typeof(PubgNotFoundException))] 74 | [InlineData(HttpStatusCode.UnsupportedMediaType, typeof(PubgContentTypeException))] 75 | [InlineData(HttpStatusCode.Unauthorized, typeof(PubgUnauthorizedException))] 76 | [InlineData((HttpStatusCode) 429, typeof(PubgTooManyRequestsException))] 77 | [InlineData(HttpStatusCode.BadRequest, typeof(PubgException))] 78 | public void HttpRequestor_Throws_CorrectErrorForHttpStatus(HttpStatusCode statusCode, Type errorType) 79 | { 80 | var mockHttp = new MockHttpMessageHandler(); 81 | 82 | mockHttp 83 | .When("*") 84 | .Respond(statusCode, new List>() { new KeyValuePair("X-RateLimit-Reset", "1000") }, new StringContent("{\"errors\" : []}")); 85 | 86 | MockHttpClient(mockHttp); 87 | 88 | Assert.Throws(errorType, () => HttpRequestor.GetString("http://random.url")); 89 | } 90 | 91 | [Theory] 92 | [InlineData(HttpStatusCode.NotFound)] 93 | [InlineData(HttpStatusCode.UnsupportedMediaType)] 94 | [InlineData(HttpStatusCode.Unauthorized)] 95 | [InlineData((HttpStatusCode)429)] 96 | [InlineData(HttpStatusCode.BadRequest)] 97 | public void PubgErrors_Have_Correct_HttpStatus(HttpStatusCode statusCode) 98 | { 99 | var mockHttp = new MockHttpMessageHandler(); 100 | 101 | mockHttp 102 | .When("*") 103 | .Respond(statusCode, new List>() { new KeyValuePair("X-RateLimit-Reset", "1000") }, new StringContent("{\"errors\" : []}")); 104 | 105 | MockHttpClient(mockHttp); 106 | 107 | try 108 | { 109 | HttpRequestor.GetString("http://random.url"); 110 | } 111 | catch(PubgException ex) 112 | { 113 | ex.HttpStatusCode.Should().Equals(statusCode); 114 | } 115 | } 116 | 117 | [Fact] 118 | public void PubgErrors_Have_ApiErrors_MappedCorrectly() 119 | { 120 | var mockHttp = new MockHttpMessageHandler(); 121 | var errors = new Fixture().CreateMany(); 122 | var errorsJson = JsonConvert.SerializeObject(errors); 123 | 124 | mockHttp 125 | .When("*") 126 | .Respond(HttpStatusCode.BadRequest, "application/json", $"{{ \"errors\": {errorsJson} }}"); 127 | 128 | MockHttpClient(mockHttp); 129 | 130 | try 131 | { 132 | HttpRequestor.GetString("http://random.url"); 133 | } 134 | catch (PubgException ex) 135 | { 136 | ex.Errors.Count().Should().Equals(errors.Count()); 137 | Assert.All(ex.Errors, err => errors.Contains(err)); 138 | } 139 | } 140 | 141 | private void MockHttpClient(MockHttpMessageHandler handler) 142 | { 143 | typeof(HttpRequestor).GetProperty(nameof(HttpRequestor.HttpClient), BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, handler.ToHttpClient()); 144 | } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /test/pubg-dotnet.Tests/Players/PlayerTests.cs: -------------------------------------------------------------------------------- 1 | using Pubg.Net.Tests.Util; 2 | using Pubg.Net.Exceptions; 3 | using System.Linq; 4 | using Xunit; 5 | using pubg.net.Tests; 6 | using FluentAssertions; 7 | 8 | namespace Pubg.Net.Tests.Players 9 | { 10 | public class PlayerTests : TestBase 11 | { 12 | [Fact] 13 | public void Can_Get_Players_ByName() 14 | { 15 | var playerService = new PubgPlayerService(Storage.ApiKey); 16 | 17 | var playerNames = Storage.GetMatch(PubgPlatform.Steam).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.Name).Take(5).ToArray(); 18 | 19 | var filter = new GetPubgPlayersRequest 20 | { 21 | PlayerNames = playerNames 22 | }; 23 | 24 | var players = playerService.GetPlayers(PubgPlatform.Steam, filter); 25 | 26 | Assert.NotEmpty(players); 27 | Assert.All(players.Select(p => p.Name), name => playerNames.Contains(name)); 28 | } 29 | 30 | [Fact] 31 | public void Can_Get_Players_ById() 32 | { 33 | var playerService = new PubgPlayerService(Storage.ApiKey); 34 | 35 | var playerIds = Storage.GetMatch(PubgPlatform.Steam).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.PlayerId).Take(5).ToArray(); 36 | 37 | var filter = new GetPubgPlayersRequest 38 | { 39 | PlayerIds = playerIds 40 | }; 41 | 42 | var players = playerService.GetPlayers(PubgPlatform.Steam, filter); 43 | 44 | Assert.NotEmpty(players); 45 | Assert.All(players.Select(p => p.Id), id => playerIds.Contains(id)); 46 | } 47 | 48 | [Fact] 49 | public void Can_Get_Player() 50 | { 51 | var playerService = new PubgPlayerService(Storage.ApiKey); 52 | 53 | var playerId = Storage.GetMatch(PubgPlatform.Steam).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.PlayerId).FirstOrDefault(); 54 | 55 | var player = playerService.GetPlayer(PubgPlatform.Steam, playerId); 56 | 57 | player.Id.Should().NotBeNull(); 58 | player.MatchIds.Should().NotBeNullOrEmpty(); 59 | player.Name.Should().NotBeNullOrWhiteSpace(); 60 | } 61 | 62 | [Fact] 63 | public void Can_Get_Season_For_Player_OnPC() 64 | { 65 | var playerService = new PubgPlayerService(Storage.ApiKey); 66 | 67 | var region = PubgRegion.PCEurope; 68 | var playerId = Storage.GetMatch(PubgPlatform.Steam).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.PlayerId).FirstOrDefault(); 69 | var seasonId = Storage.GetSeason(region).Id; 70 | 71 | var playerSeason = playerService.GetPlayerSeasonPC(playerId, seasonId); 72 | 73 | playerSeason.Should().NotBeNull(); 74 | playerSeason.GameModeStats.Should().NotBeNull(); 75 | playerSeason.SeasonId.Should().NotBeNullOrWhiteSpace(); 76 | playerSeason.PlayerId.Should().NotBeNullOrWhiteSpace(); 77 | playerSeason.GameModeStats.Should().NotBeNull(); 78 | playerSeason.GameModeStats.Solo.Should().NotBeNull(); 79 | playerSeason.GameModeStats.SoloFPP.Should().NotBeNull(); 80 | playerSeason.GameModeStats.Duo.Should().NotBeNull(); 81 | playerSeason.GameModeStats.DuoFPP.Should().NotBeNull(); 82 | playerSeason.GameModeStats.Squad.Should().NotBeNull(); 83 | playerSeason.GameModeStats.SquadFPP.Should().NotBeNull(); 84 | } 85 | 86 | [Fact] 87 | public void Can_Get_LifetimeStats_For_Player_OnPC() 88 | { 89 | var playerService = new PubgPlayerService(Storage.ApiKey); 90 | 91 | var playerId = Storage.GetMatch(PubgPlatform.Steam).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.PlayerId).FirstOrDefault(); 92 | 93 | var lifeTimeStats = playerService.GetPlayerLifetimeStats(PubgPlatform.Steam, playerId); 94 | 95 | lifeTimeStats.PlayerId.Should().BeEquivalentTo(playerId); 96 | lifeTimeStats.SeasonId.Should().BeEquivalentTo("lifetime"); 97 | lifeTimeStats.GameModeStats.Should().NotBeNull(); 98 | } 99 | 100 | public void Can_Get_Season_For_Player_OnXbox() 101 | { 102 | var playerService = new PubgPlayerService(Storage.ApiKey); 103 | 104 | var region = PubgRegion.XboxEurope; 105 | var playerId = Storage.GetMatch(PubgPlatform.Steam).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.PlayerId).FirstOrDefault(); 106 | var seasonId = Storage.GetSeason(region).Id; 107 | 108 | var playerSeason = playerService.GetPlayerSeasonConsole(region, playerId, seasonId); 109 | 110 | playerSeason.Should().NotBeNull(); 111 | playerSeason.GameModeStats.Should().NotBeNull(); 112 | playerSeason.SeasonId.Should().NotBeNullOrWhiteSpace(); 113 | playerSeason.PlayerId.Should().NotBeNullOrWhiteSpace(); 114 | playerSeason.GameModeStats.Should().NotBeNull(); 115 | playerSeason.GameModeStats.Solo.Should().NotBeNull(); 116 | playerSeason.GameModeStats.SoloFPP.Should().NotBeNull(); 117 | playerSeason.GameModeStats.Duo.Should().NotBeNull(); 118 | playerSeason.GameModeStats.DuoFPP.Should().NotBeNull(); 119 | playerSeason.GameModeStats.Squad.Should().NotBeNull(); 120 | playerSeason.GameModeStats.SquadFPP.Should().NotBeNull(); 121 | } 122 | 123 | [Fact] 124 | public void GetPlayers_Throws_Exception_When_NotFound() 125 | { 126 | var playerService = new PubgPlayerService(Storage.ApiKey); 127 | 128 | var filter = new GetPubgPlayersRequest 129 | { 130 | PlayerNames = new string[] { "NonExistantPlayerHopefully" } 131 | }; 132 | 133 | Assert.Throws(() => playerService.GetPlayers(PubgPlatform.Steam, filter)); 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # .NET Core 46 | project.lock.json 47 | project.fragment.lock.json 48 | artifacts/ 49 | **/Properties/launchSettings.json 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # Visual Studio code coverage results 117 | *.coverage 118 | *.coveragexml 119 | 120 | # NCrunch 121 | _NCrunch_* 122 | .*crunch*.local.xml 123 | nCrunchTemp_* 124 | 125 | # MightyMoose 126 | *.mm.* 127 | AutoTest.Net/ 128 | 129 | # Web workbench (sass) 130 | .sass-cache/ 131 | 132 | # Installshield output folder 133 | [Ee]xpress/ 134 | 135 | # DocProject is a documentation generator add-in 136 | DocProject/buildhelp/ 137 | DocProject/Help/*.HxT 138 | DocProject/Help/*.HxC 139 | DocProject/Help/*.hhc 140 | DocProject/Help/*.hhk 141 | DocProject/Help/*.hhp 142 | DocProject/Help/Html2 143 | DocProject/Help/html 144 | 145 | # Click-Once directory 146 | publish/ 147 | 148 | # Publish Web Output 149 | *.[Pp]ublish.xml 150 | *.azurePubxml 151 | # TODO: Comment the next line if you want to checkin your web deploy settings 152 | # but database connection strings (with potential passwords) will be unencrypted 153 | *.pubxml 154 | *.publishproj 155 | 156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 157 | # checkin your Azure Web App publish settings, but sensitive information contained 158 | # in these scripts will be unencrypted 159 | PublishScripts/ 160 | 161 | # NuGet Packages 162 | *.nupkg 163 | # The packages folder can be ignored because of Package Restore 164 | **/packages/* 165 | # except build/, which is used as an MSBuild target. 166 | !**/packages/build/ 167 | # Uncomment if necessary however generally it will be regenerated when needed 168 | #!**/packages/repositories.config 169 | # NuGet v3's project.json files produces more ignorable files 170 | *.nuget.props 171 | *.nuget.targets 172 | 173 | # Microsoft Azure Build Output 174 | csx/ 175 | *.build.csdef 176 | 177 | # Microsoft Azure Emulator 178 | ecf/ 179 | rcf/ 180 | 181 | # Windows Store app package directories and files 182 | AppPackages/ 183 | BundleArtifacts/ 184 | Package.StoreAssociation.xml 185 | _pkginfo.txt 186 | 187 | # Visual Studio cache files 188 | # files ending in .cache can be ignored 189 | *.[Cc]ache 190 | # but keep track of directories ending in .cache 191 | !*.[Cc]ache/ 192 | 193 | # Others 194 | ClientBin/ 195 | ~$* 196 | *~ 197 | *.dbmdl 198 | *.dbproj.schemaview 199 | *.jfm 200 | *.pfx 201 | *.publishsettings 202 | orleans.codegen.cs 203 | 204 | # Since there are multiple workflows, uncomment next line to ignore bower_components 205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 206 | #bower_components/ 207 | 208 | # RIA/Silverlight projects 209 | Generated_Code/ 210 | 211 | # Backup & report files from converting an old project file 212 | # to a newer Visual Studio version. Backup files are not needed, 213 | # because we have git ;-) 214 | _UpgradeReport_Files/ 215 | Backup*/ 216 | UpgradeLog*.XML 217 | UpgradeLog*.htm 218 | 219 | # SQL Server files 220 | *.mdf 221 | *.ldf 222 | *.ndf 223 | 224 | # Business Intelligence projects 225 | *.rdl.data 226 | *.bim.layout 227 | *.bim_*.settings 228 | 229 | # Microsoft Fakes 230 | FakesAssemblies/ 231 | 232 | # GhostDoc plugin setting file 233 | *.GhostDoc.xml 234 | 235 | # Node.js Tools for Visual Studio 236 | .ntvs_analysis.dat 237 | node_modules/ 238 | 239 | # Typescript v1 declaration files 240 | typings/ 241 | 242 | # Visual Studio 6 build log 243 | *.plg 244 | 245 | # Visual Studio 6 workspace options file 246 | *.opt 247 | 248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 249 | *.vbw 250 | 251 | # Visual Studio LightSwitch build output 252 | **/*.HTMLClient/GeneratedArtifacts 253 | **/*.DesktopClient/GeneratedArtifacts 254 | **/*.DesktopClient/ModelManifest.xml 255 | **/*.Server/GeneratedArtifacts 256 | **/*.Server/ModelManifest.xml 257 | _Pvt_Extensions 258 | 259 | # Paket dependency manager 260 | .paket/paket.exe 261 | paket-files/ 262 | 263 | # FAKE - F# Make 264 | .fake/ 265 | 266 | # JetBrains Rider 267 | .idea/ 268 | *.sln.iml 269 | 270 | # CodeRush 271 | .cr/ 272 | 273 | # Python Tools for Visual Studio (PTVS) 274 | __pycache__/ 275 | *.pyc 276 | 277 | # Cake - Uncomment if you are using it 278 | # tools/** 279 | # !tools/packages.config 280 | 281 | # Telerik's JustMock configuration file 282 | *.jmconfig 283 | 284 | # BizTalk build output 285 | *.btp.cs 286 | *.btm.cs 287 | *.odx.cs 288 | *.xsd.cs 289 | -------------------------------------------------------------------------------- /src/pubg-dotnet/Services/Players/PubgPlayerService.cs: -------------------------------------------------------------------------------- 1 | using JsonApiSerializer; 2 | using Newtonsoft.Json; 3 | using Pubg.Net.Infrastructure; 4 | using Pubg.Net.Services; 5 | using Pubg.Net.Values; 6 | using System.Collections.Generic; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace Pubg.Net 11 | { 12 | public class PubgPlayerService : PubgService 13 | { 14 | private const string LIFETIME_SEASON_NAME = "lifetime"; 15 | 16 | public PubgPlayerService() : base() { } 17 | public PubgPlayerService(string apiKey) : base(apiKey) { } 18 | 19 | public virtual PubgPlayer GetPlayer(PubgPlatform platform, string playerId, string apiKey = null) 20 | { 21 | var url = Api.Players.PlayersEndpoint(platform, playerId); 22 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 23 | 24 | var playerJson = HttpRequestor.GetString(url, apiKey); 25 | 26 | return JsonConvert.DeserializeObject(playerJson, new JsonApiSerializerSettings()); 27 | } 28 | 29 | public virtual async Task GetPlayerAsync(PubgPlatform platform, string playerId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 30 | { 31 | var url = Api.Players.PlayersEndpoint(platform, playerId); 32 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 33 | 34 | var playerJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); 35 | 36 | return JsonConvert.DeserializeObject(playerJson, new JsonApiSerializerSettings()); 37 | } 38 | 39 | public virtual IEnumerable GetPlayers(PubgPlatform platform, GetPubgPlayersRequest filter) 40 | { 41 | var url = RequestBuilder.BuildRequestUrl(Api.Players.PlayersEndpoint(platform), filter); 42 | var apiKey = string.IsNullOrEmpty(filter.ApiKey) ? ApiKey : filter.ApiKey; 43 | 44 | var collectionJson = HttpRequestor.GetString(url, apiKey); 45 | 46 | return JsonConvert.DeserializeObject>(collectionJson, new JsonApiSerializerSettings()); 47 | } 48 | 49 | public virtual async Task> GetPlayersAsync(PubgPlatform platform, GetPubgPlayersRequest filter, CancellationToken cancellationToken = default(CancellationToken)) 50 | { 51 | var url = RequestBuilder.BuildRequestUrl(Api.Players.PlayersEndpoint(platform), filter); 52 | var apiKey = string.IsNullOrEmpty(filter.ApiKey) ? ApiKey : filter.ApiKey; 53 | 54 | var collectionJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); 55 | 56 | return JsonConvert.DeserializeObject>(collectionJson, new JsonApiSerializerSettings()); 57 | } 58 | 59 | public virtual PubgStatEntity GetPlayerLifetimeStats(PubgPlatform platform, string playerId, string apiKey = null) 60 | { 61 | var url = Api.Players.PlayerSeasonsEndpoint(platform, playerId, LIFETIME_SEASON_NAME); 62 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 63 | 64 | var seasonJson = HttpRequestor.GetString(url, apiKey); 65 | 66 | return JsonConvert.DeserializeObject(seasonJson, new JsonApiSerializerSettings()); 67 | } 68 | 69 | public virtual async Task GetPlayerLifetimeStatsAsync(PubgPlatform platform, string playerId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 70 | { 71 | var url = Api.Players.PlayerSeasonsEndpoint(platform, playerId, LIFETIME_SEASON_NAME); 72 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 73 | 74 | var seasonJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); 75 | 76 | return JsonConvert.DeserializeObject(seasonJson, new JsonApiSerializerSettings()); 77 | } 78 | 79 | /// 80 | /// Gets the players season stats and matches for the specified platform 81 | /// 82 | /// The platform on which the season took place 83 | /// The ID of the player you wish to retrieve the season stats for 84 | /// The ID of the season you wish to recieve stats and matches for 85 | /// Your API key (optional) 86 | /// Stats and matches for a given player during a given season 87 | /// Exception thrown on the API side, details included on object 88 | /// The api is unable to find the specified player 89 | /// You have exceeded your rate limit 90 | /// Invalid API Key 91 | public virtual PubgPlayerSeason GetPlayerSeason(PubgPlatform platform, string playerId, string seasonId, string apiKey = null) 92 | { 93 | var url = Api.Players.PlayerSeasonsEndpoint(platform, playerId, seasonId); 94 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 95 | 96 | var seasonJson = HttpRequestor.GetString(url, apiKey); 97 | 98 | return JsonConvert.DeserializeObject(seasonJson, new JsonApiSerializerSettings()); 99 | } 100 | 101 | /// 102 | /// Gets the players season stats and matches for the specified platform asychronusly 103 | /// 104 | /// The platform on which the season took place 105 | /// The ID of the player you wish to retrieve the season stats for 106 | /// The ID of the season you wish to recieve stats and matches for 107 | /// Your API key (optional) 108 | /// Stats and matches for a given player during a given season 109 | /// Exception thrown on the API side, details included on object 110 | /// The api is unable to find the specified player 111 | /// You have exceeded your rate limit 112 | /// Invalid API Key 113 | public async virtual Task GetPlayerSeasonAsync(PubgPlatform platform, string playerId, string seasonId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 114 | { 115 | var url = Api.Players.PlayerSeasonsEndpoint(platform, playerId, seasonId); 116 | apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; 117 | 118 | var seasonJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); 119 | 120 | return JsonConvert.DeserializeObject(seasonJson, new JsonApiSerializerSettings()); 121 | } 122 | 123 | /// 124 | /// Gets the players season stats and matches for the default platform (steam) 125 | /// 126 | /// **NOTE**: This method has been deprecated and will be removed in the next major version. 127 | /// 128 | /// The ID of the player you wish to retrieve the season stats for 129 | /// The ID of the season you wish to recieve stats and matches for 130 | /// Your API key (optional) 131 | /// Stats and matches for a given player during a given season 132 | /// Exception thrown on the API side, details included on object 133 | /// The api is unable to find the specified player 134 | /// You have exceeded your rate limit 135 | /// Invalid API Key 136 | public virtual PubgPlayerSeason GetPlayerSeasonPC(string playerId, string seasonId, string apiKey = null) => GetPlayerSeason(PubgPlatform.Steam, playerId, seasonId, apiKey); 137 | 138 | /// 139 | /// Gets the players season stats and matches for the specified platform 140 | /// 141 | /// **NOTE**: This method has been deprecated and will be removed in the next major version. 142 | /// 143 | /// The platform on which the season took place 144 | /// The ID of the player you wish to retrieve the season stats for 145 | /// The ID of the season you wish to recieve stats and matches for 146 | /// Your API key (optional) 147 | /// Stats and matches for a given player during a given season 148 | /// Exception thrown on the API side, details included on object 149 | /// The api is unable to find the specified player 150 | /// You have exceeded your rate limit 151 | /// Invalid API Key 152 | public virtual PubgPlayerSeason GetPlayerSeasonPC(PubgPlatform platform, string playerId, string seasonId, string apiKey = null) 153 | => GetPlayerSeason(platform, playerId, seasonId, apiKey); 154 | 155 | /// 156 | /// Gets the players season stats and matches for the specified platform asynchronusly 157 | /// 158 | /// **NOTE**: This method has been deprecated and will be removed in the next major version. 159 | /// 160 | /// The platform on which the season took place 161 | /// The ID of the player you wish to retrieve the season stats for 162 | /// The ID of the season you wish to recieve stats and matches for 163 | /// Your API key (optional) 164 | /// Stats and matches for a given player during a given season 165 | /// Exception thrown on the API side, details included on object 166 | /// The api is unable to find the specified player 167 | /// You have exceeded your rate limit 168 | /// Invalid API Key 169 | public async virtual Task GetPlayerSeasonPCAsync(PubgPlatform platform, string playerId, string seasonId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 170 | => await GetPlayerSeasonAsync(platform, playerId, seasonId, apiKey, cancellationToken); 171 | 172 | /// 173 | /// Gets the players season stats and matches played on a console in the specified region 174 | /// 175 | /// **NOTE**: This method has been deprecated and will be removed in the next major version. 176 | /// 177 | /// The region which the player is located in 178 | /// The ID of the player you wish to retrieve the season stats for 179 | /// The ID of the season you wish to recieve stats and matches for 180 | /// Your API key (optional) 181 | /// Stats and matches for a given player during a given season 182 | /// Exception thrown on the API side, details included on object 183 | /// The api is unable to find the specified player 184 | /// You have exceeded your rate limit 185 | /// Invalid API Key 186 | public virtual PubgPlayerSeason GetPlayerSeasonConsole(PubgRegion region, string playerId, string seasonId, string apiKey = null) 187 | => GetPlayerSeason(PubgPlatform.Console, playerId, seasonId, apiKey); 188 | 189 | /// 190 | /// Gets the players season stats and matches played on a console in the specified region asychronusly 191 | /// 192 | /// **NOTE**: This method has been deprecated and will be removed in the next major version. 193 | /// 194 | /// The region which the player is located in 195 | /// The ID of the player you wish to retrieve the season stats for 196 | /// The ID of the season you wish to recieve stats and matches for 197 | /// Your API key (optional) 198 | /// Stats and matches for a given player during a given season 199 | /// Exception thrown on the API side, details included on object 200 | /// The api is unable to find the specified player 201 | /// You have exceeded your rate limit 202 | /// Invalid API Key 203 | public async virtual Task GetPlayerSeasonConsoleAsync(PubgRegion region, string playerId, string seasonId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) 204 | => await GetPlayerSeasonAsync(PubgPlatform.Console, playerId, seasonId, apiKey, cancellationToken); 205 | } 206 | } 207 | --------------------------------------------------------------------------------