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 virtual IEnumerable <PubgTelemetryEvent> GetTelemetry(PubgRegion region, string url) { var collectionJson = HttpRequestor.GetString(url); return(JsonConvert.DeserializeObject <IEnumerable <PubgTelemetryEvent> >(collectionJson, new JsonSerializerSettings { ContractResolver = new TelemetryContractResolver(region.Serialize()) })); }
public virtual PubgMatch GetMatch(PubgRegion region, string matchId, string apiKey = null) { var url = string.Format(Api.Matches.MatchesEndpoint + "/{1}", region.Serialize(), matchId); apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; var matchJson = HttpRequestor.GetString(url, apiKey); return(JsonConvert.DeserializeObject <IEnumerable <PubgMatch> >(matchJson, new JsonApiSerializerSettings()).FirstOrDefault()); }
public async virtual Task <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())); }
public virtual PubgPlayerSeason GetPlayerSeason(PubgRegion region, string playerId, string seasonId, string apiKey = null) { var url = string.Format(Api.Players.PlayerSeasonsEndpoint, region.Serialize(), playerId, seasonId); apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; var seasonJson = HttpRequestor.GetString(url, apiKey); return(JsonConvert.DeserializeObject <PubgPlayerSeason>(seasonJson, new JsonApiSerializerSettings())); }
public virtual IEnumerable <PubgSeason> GetSeasons(PubgRegion region, string apiKey = null) { var url = string.Format(Api.Seasons.SeasonsEndpoint, region.Serialize()); apiKey = string.IsNullOrEmpty(apiKey) ? ApiKey : apiKey; var seasonJson = HttpRequestor.GetString(url, apiKey); return(JsonConvert.DeserializeObject <IEnumerable <PubgSeason> >(seasonJson, new JsonApiSerializerSettings())); }
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()); }
public async Task <PlayerResponse> GetPlayer(PubgRegion region, string playerId) { var url = new Uri(_baseUri, $"{region.Serialize()}/players/{playerId}"); var data = await SendRequestAsync <PlayerResponse>(url, HttpMethod.Get, _defaultHeaders); if (!data.Success) { throw new Exception($"ERROR: Faild to get player - {data.ErrorCode} - {data.ErrorMessage}"); } return(data.Data); }
public async Task <FindPlayersResponse> FilterPlayersById(PubgRegion region, params string[] playerIds) { var playersUrl = new Uri(_baseUri, $"{region.Serialize()}/players"); var url = new UriBuilder(playersUrl); var query = HttpUtility.ParseQueryString(url.Query); query["filter[playerIds]"] = string.Join(',', playerIds); url.Query = query.ToString(); var data = await SendRequestAsync <FindPlayersResponse>(url.Uri, HttpMethod.Get, _defaultHeaders); if (!data.Success) { throw new Exception($"ERROR: Faild to find players - {data.ErrorCode} - {data.ErrorMessage}"); } return(data.Data); }
public static bool IsXbox(this PubgRegion region) => region.Serialize().ToLowerInvariant().Contains("xbox");
public virtual async Task <IEnumerable <PubgPlayer> > GetPlayersAsync(PubgRegion region, GetPubgPlayersRequest filter, CancellationToken cancellationToken = default(CancellationToken)) { var url = RequestBuilder.BuildRequestUrl(string.Format(Api.Players.PlayersEndpoint, region.Serialize()), filter); var apiKey = string.IsNullOrEmpty(filter.ApiKey) ? ApiKey : filter.ApiKey; var collectionJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey); return(JsonConvert.DeserializeObject <IEnumerable <PubgPlayer> >(collectionJson, new JsonApiSerializerSettings())); }
public static PubgMatch GetMatch(PubgRegion region) { var match = StoredItems.OfType <PubgMatch>().FirstOrDefault(p => p.ShardId == region.Serialize()); if (match != null) { return(match); } var samples = GetSamples(region); match = new PubgMatchService(ApiKey).GetMatch(region, samples.MatchIds.First()); StoredItems.Add(match); return(match); }
internal static string PlayersEndpoint(PubgRegion region) => string.Format(ShardedBaseUrl + "/players", region.Serialize());
public static PubgMatchSample GetSamples(PubgRegion region) { var samples = StoredItems.OfType<PubgMatchSample>().FirstOrDefault(p => p.ShardId == region.Serialize()); if (samples != null) return samples; var sampleService = new PubgSamplesService(ApiKey); samples = sampleService.GetMatchSamples(region); StoredItems.Add(samples); return samples; }
public async Task <PubgMatchSample> GetMatchSamplesAsync(PubgRegion region, GetSamplesRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var url = RequestBuilder.BuildRequestUrl(string.Format(Api.Samples.SamplesEndpoint, region.Serialize()), request); var apiKey = string.IsNullOrEmpty(request.ApiKey) ? ApiKey : request.ApiKey; var collectionJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey); return(JsonConvert.DeserializeObject <IEnumerable <PubgMatchSample> >(collectionJson, new JsonApiSerializerSettings()).FirstOrDefault()); }
public PubgMatchSample GetMatchSamples(PubgRegion region, GetSamplesRequest request) { var url = RequestBuilder.BuildRequestUrl(string.Format(Api.Samples.SamplesEndpoint, region.Serialize()), request); var apiKey = string.IsNullOrEmpty(request.ApiKey) ? ApiKey : request.ApiKey; var collectionJson = HttpRequestor.GetString(url, apiKey); return(JsonConvert.DeserializeObject <IEnumerable <PubgMatchSample> >(collectionJson, new JsonApiSerializerSettings()).FirstOrDefault()); }
internal static string MatchesEndpoint(PubgRegion region) => string.Format(ShardedBaseUrl + "/matches", region.Serialize());
public virtual IEnumerable <PubgPlayer> GetPlayers(PubgRegion region, GetPubgPlayersRequest filter) { var url = RequestBuilder.BuildRequestUrl(string.Format(Api.Players.PlayersEndpoint, region.Serialize()), filter); var apiKey = string.IsNullOrEmpty(filter.ApiKey) ? ApiKey : filter.ApiKey; var collectionJson = HttpRequestor.GetString(url, apiKey); return(JsonConvert.DeserializeObject <IEnumerable <PubgPlayer> >(collectionJson, new JsonApiSerializerSettings())); }
internal static string SeasonsEndpoint(PubgRegion region) => string.Format(ShardedBaseUrl + "/seasons", region.Serialize());
public static PubgPlayer GetPlayer(PubgRegion region) { var player = StoredItems.OfType <PubgPlayer>().FirstOrDefault(p => p.ShardId == region.Serialize()); if (player != null) { return(player); } var playerService = new PubgPlayerService(ApiKey); var playerNames = GetMatch(region).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.Name).Take(5); var players = playerService.GetPlayers(region, new GetPubgPlayersRequest { PlayerNames = playerNames.ToArray() }); StoredItems.AddRange(players); return(players.FirstOrDefault()); }