public virtual PubgLeaderboard GetGameModeLeaderboard(PubgPlatform platform, PubgGameMode gameMode, string apiKey = null) { var url = Api.Leaderboard.LeaderboardEndpoint(platform, gameMode); apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; var leaderboardJson = HttpRequestor.GetString(url, apiKey); return(JsonConvert.DeserializeObject <PubgLeaderboard>(leaderboardJson, new JsonApiSerializerSettings())); }
public void Can_Get_Leaderboard(PubgGameMode gameMode) { var service = new PubgLeaderboardService(Storage.ApiKey); var leaderboard = service.GetGameModeLeaderboard(PubgPlatform.Steam, gameMode); leaderboard.Id.Should().NotBeNullOrEmpty(); leaderboard.ShardId.Should().NotBeNullOrEmpty(); Assert.All(leaderboard.Players, player => player.Id.Should().NotBeNullOrEmpty()); Assert.All(leaderboard.Players, player => player.Name.Should().NotBeNullOrEmpty()); }
internal static string LeaderboardEndpoint(PubgPlatform platform, PubgGameMode gameMode) => string.Format(ShardedBaseUrl + "/leaderboards/{1}", platform.Serialize(), gameMode.Serialize());
public virtual async Task <PubgLeaderboard> GetGameModeLeaderboardAsync(PubgPlatform platform, PubgGameMode gameMode, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken)) { var url = Api.Leaderboard.LeaderboardEndpoint(platform, gameMode); apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; var leaderboardJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false); return(JsonConvert.DeserializeObject <PubgLeaderboard>(leaderboardJson, new JsonApiSerializerSettings())); }