/// <summary> /// Get a collection of up to 10 players. /// Given a list of player ids or player names, queries for those players. /// </summary> /// <remarks> /// Cannot query by both names and ids. Prefers ids when provided. /// </remarks> /// <param name="ids">Filters by player IDs</param> /// <param name="names">Filters by player names</param> public List <Player> GetPlayers(PlatformShard shard, List <string> ids, List <string> names) { if ((ids == null || !ids.Any()) && (names == null || !names.Any())) { return(new List <Player>()); } string shardUri = BuildShardUri(shard); string playerUri = shardUri + "players"; if (ids != null && ids.Any()) { string concatenatedIds = string.Join(",", ids); playerUri = playerUri + "?filter[playerIds]=" + concatenatedIds; } else if (names != null && names.Any()) { string concatenatedNames = string.Join(",", names); playerUri = playerUri + "?filter[playerNames]=" + concatenatedNames; } IRestResponse response = MakeRequest(playerUri); return(Player.DeserializePlayerList(response.Content)); }
/// <summary> /// Gets a PUBG match by ID. /// </summary> public Match GetMatch(PlatformShard shard, string matchId) { string shardUri = BuildShardUri(shard); string matchUri = shardUri + "matches/" + matchId; IRestResponse response = MakeRequest(matchUri); return(Match.Deserialize(response.Content)); }
/// <summary> /// Get season information for a single player. /// </summary> /// <param name="accountId">The account ID to search for.</param> /// <param name="seasonId">The season ID to search for.</param> public Stats GetSeasonStatsForPlayer(PlatformShard shard, string accountId, string seasonId) { string shardUri = BuildShardUri(shard); string statsUri = shardUri + "players/" + accountId + "/seasons/" + seasonId; IRestResponse response = MakeRequest(statsUri); return(Stats.Deserialize(response.Content)); }
/// <summary> /// Get the list of available seasons. /// </summary> /// <remarks> /// Note: The list of seasons will only be changing about once every /// two months when a new season is added. Applications should not be /// querying for the list of seasons more than once per month. /// </remarks> public List <Season> GetSeasons(PlatformShard shard) { string shardUri = BuildShardUri(shard); string seasonUri = shardUri + "seasons"; IRestResponse response = MakeRequest(seasonUri); return(Season.Deserialize(response.Content)); }
/// <summary> /// Get a single player. /// Makes a request to the PUBG API for information about a player, by player id. /// </summary> /// <param name="id">The account ID to search for</param> public Player GetPlayer(PlatformShard shard, string id) { string shardUri = BuildShardUri(shard); string playerUri = shardUri + "players/" + id; IRestResponse response = MakeRequest(playerUri); return(Player.Deserialize(response.Content)); }
/// <summary> /// Given a players username, gets the Id associated for that account. /// </summary> public string GetPlayerId(PlatformShard shard, string playerName) { string shardUri = BuildShardUri(shard); string playerUri = shardUri + "players?filter[playerNames]=" + playerName; IRestResponse response = MakeRequest(playerUri); return(Player.DeserializePlayerList(response.Content)[0].Id); }
/// <summary> /// Get the leaderboard for a game mode. /// </summary> /// <param name="gameMode">The game mode to search for.</param> /// <param name="page">The leaderboard page to search for.</param> public Leaderboard GetLeaderboard(PlatformShard shard, string gameMode, int page) { string shardUri = BuildShardUri(shard); string leaderboardUri = shardUri + "leaderboards/" + gameMode + "?page[number]=" + page; IRestResponse response = MakeRequest(leaderboardUri); return(Leaderboard.Deserialize(response.Content)); }
/// <summary> /// Get season information for up to 10 players. /// </summary> /// <param name="seasonId">The season ID to search for.</param> /// <param name="gameMode">The game mode to search for.</param> /// <param name="playerIds">Filters by player IDs.</param> public List <Stats> GetSeasonStatsForMultiplePlayers(PlatformShard shard, string seasonId, string gameMode, List <string> playerIds) { string shardUri = BuildShardUri(shard); string statsUri = shardUri + "seasons/" + seasonId + "/gamemode" + gameMode + "/players?filter[playerIds]=" + String.Join(",", playerIds); IRestResponse response = MakeRequest(statsUri); throw new NotImplementedException(); // TODO: deserialize multiple stats // return Stats.Deserialize(response.Content); }
/// <summary> /// Gets a set of sample matches /// </summary> /// <remarks> /// The number of matches per shard may vary. Requests for samples /// need to be at least 24hrs in the past UTC time using the /// filter[createdAt-start] query parameter. The default if not /// specified is the latest sample. /// </remarks> /// <param name="createdAtFilter">The starting search date in UTC. Null by default.</param> public Sample GetSampleMatches(PlatformShard shard, DateTime?createdAtFilter = null) { string shardUri = BuildShardUri(shard); string sampleUri = shardUri + "samples"; if (createdAtFilter != null) { sampleUri += "?filter[createdAt-start]=" + createdAtFilter.Value.ToString("yyyy-MM-ddTHH:mm:ssZ"); } IRestResponse response = MakeRequest(sampleUri); return(Sample.Deserialize(response.Content)); }
/// <summary> /// Get lifetime stats for up to 10 players. /// </summary> /// <param name="gameMode">The game mode to search for.</param> /// <param name="playerIds">Filters by player IDs.</param> public List <Stats> GetLifetimeStatsForMultiplePlayers(PlatformShard shard, string gameMode, List <string> playerIds) { return(GetSeasonStatsForMultiplePlayers(shard, "lifetime", gameMode, playerIds)); }
/// <summary> /// Get lifetime stats for a single player. /// </summary> /// <param name="accountId">The account ID to search for.</param> public Stats GetLifetimeStatsForPlayer(PlatformShard shard, string accountId) { return(GetSeasonStatsForPlayer(shard, accountId, "lifetime")); }
/// <summary> /// Given a Shard enum, builds the shard portion of the Uri string for a request. /// </summary> /// <remarks> /// We must do this because C# doesn't allow enums with the '-' character, /// so we have to pull the uri-friendly string out of the description of the Shard value.s /// </remarks> private string BuildShardUri(PlatformShard shard) { return("/shards/" + shard.ToString().ToLower() + "/"); }