Exemplo n.º 1
0
        public virtual async Task <IEnumerable <PubgTelemetryEvent> > GetTelemetryAsync(PubgRegion region, string url, CancellationToken cancellationToken = default(CancellationToken))
        {
            var collectionJson = await HttpRequestor.GetStringAsync(url, cancellationToken);

            return(JsonConvert.DeserializeObject <IEnumerable <PubgTelemetryEvent> >(collectionJson, new JsonSerializerSettings {
                ContractResolver = new TelemetryContractResolver(region.Serialize())
            }));
        }
        public async Task <PubgMatchSample> GetMatchSamplesAsync(PubgPlatform platform, GetSamplesRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url    = RequestBuilder.BuildRequestUrl(Api.Samples.SamplesEndpoint(platform), request);
            var apiKey = string.IsNullOrEmpty(request.ApiKey) ? ApiKey : request.ApiKey;

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

            return(JsonConvert.DeserializeObject <IEnumerable <PubgMatchSample> >(collectionJson, new JsonApiSerializerSettings()).FirstOrDefault());
        }
Exemplo n.º 3
0
        public virtual async Task <IEnumerable <PubgPlayer> > GetPlayersAsync(PubgPlatform platform, GetPubgPlayersRequest filter, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url    = RequestBuilder.BuildRequestUrl(Api.Players.PlayersEndpoint(platform), filter);
            var apiKey = string.IsNullOrEmpty(filter.ApiKey) ? ApiKey : filter.ApiKey;

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

            return(JsonConvert.DeserializeObject <IEnumerable <PubgPlayer> >(collectionJson, new JsonApiSerializerSettings()));
        }
Exemplo n.º 4
0
        public async virtual Task <PubgMatch> GetMatchAsync(PubgRegion region, string matchId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = string.Format(Api.Matches.MatchesEndpoint + "/{1}", region.Serialize(), matchId);

            apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

            return(JsonConvert.DeserializeObject <IEnumerable <PubgMatch> >(matchJson, new JsonApiSerializerSettings()).FirstOrDefault());
        }
Exemplo n.º 5
0
        /// <summary>
        ///  Get a list of seasons for the specified region on Xbox
        /// </summary>
        /// <param name="platform">The platform you wish to get the seasons for</param>
        /// <param name="apiKey">Your api key (optional)</param>
        /// <returns>A list of seasons and their information</returns>
        /// <exception cref="Pubg.Net.Exceptions.PubgException">Exception thrown on the API side, details included on object</exception>
        /// <exception cref="Pubg.Net.Exceptions.PubgTooManyRequestsException">You have exceeded your rate limit</exception>
        /// <exception cref="Pubg.Net.Exceptions.PubgUnauthorizedException">Invalid API Key</exception>
        public async virtual Task <IEnumerable <PubgSeason> > GetSeasonsXboxAsync(PubgRegion region, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = Api.Seasons.SeasonsXboxEndpoint(region);

            apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

            return(JsonConvert.DeserializeObject <IEnumerable <PubgSeason> >(seasonJson, new JsonApiSerializerSettings()));
        }
Exemplo n.º 6
0
        public virtual async Task <PubgStatEntity> GetPlayerLifetimeStatsAsync(PubgPlatform platform, string playerId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = Api.Players.PlayerSeasonsEndpoint(platform, playerId, LIFETIME_SEASON_NAME);

            apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

            return(JsonConvert.DeserializeObject <PubgStatEntity>(seasonJson, new JsonApiSerializerSettings()));
        }
Exemplo n.º 7
0
        public virtual async Task <PubgPlayer> GetPlayerAsync(PubgPlatform platform, string playerId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = Api.Players.PlayersEndpoint(platform, playerId);

            apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

            return(JsonConvert.DeserializeObject <PubgPlayer>(playerJson, new JsonApiSerializerSettings()));
        }
Exemplo n.º 8
0
        public async virtual Task <PubgPlayerSeason> GetPlayerSeasonAsync(PubgRegion region, string playerId, string seasonId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = string.Format(Api.Players.PlayerSeasonsEndpoint, region.Serialize(), playerId, seasonId);

            apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

            return(JsonConvert.DeserializeObject <PubgPlayerSeason>(seasonJson, new JsonApiSerializerSettings()));
        }
Exemplo n.º 9
0
        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()));
        }
Exemplo n.º 10
0
        public virtual async Task <PubgStatus> GetStatusAsync(string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = Api.Status.StatusEndpoint();

            apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

            return(JsonConvert.DeserializeObject <PubgStatus>(objectJson, new JsonApiSerializerSettings()));
        }
Exemplo n.º 11
0
        public async virtual Task <PubgTournament> GetTournamentAsync(string tournamentId, string apiKey = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = Api.Tournaments.TournamentsEndpoint(tournamentId);

            apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey;

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

            return(JsonConvert.DeserializeObject <PubgTournament>(matchJson, new JsonApiSerializerSettings()));
        }
Exemplo n.º 12
0
        public virtual async Task <IEnumerable <PubgTelemetryEvent> > GetTelemetryAsync(PubgRegion region, string url, CancellationToken cancellationToken = default(CancellationToken))
        {
            var collectionJson = await HttpRequestor.GetStringAsync(url, cancellationToken).ConfigureAwait(false);

            return(JsonConvert.DeserializeObject <IEnumerable <PubgTelemetryEvent> >(collectionJson));
        }