public async Task <CODStats> GetStatsAsync(GameType gameType, PlatformType platformType) { var request = new RestRequest("stats/{gameType}/{username}/{platformType}", Method.GET); request.AddUrlSegment("username", User.Username); request.AddUrlSegment("gameType", gameType.GetQueryName()); request.AddUrlSegment("platformType", platformType.ToString().ToLower()); switch (gameType) { case GameType.BO4BO: request.AddParameter("type", "blackout"); break; case GameType.BO4: case GameType.BO4MP: request.AddParameter("type", "multiplayer"); break; case GameType.BO4Z: request.AddParameter("type", "zombies"); break; } request.AddParameter("u", User.UserId); IRestResponse response = await CODAPI.SendRestRequestAsync(request).ConfigureAwait(false); if (response.ResponseStatus != ResponseStatus.Completed || String.IsNullOrWhiteSpace(response.Content)) { return(null); } return(JsonConvert.DeserializeObject <CODStats>(response.Content));; }
public CODUser(UID UniqueId) { var request = new RestRequest("users/ids", Method.GET); request.AddParameter("id", UniqueId.ToString()); IRestResponse response = CODAPI.SendRestRequest(request); if (response.ResponseStatus != ResponseStatus.Completed || String.IsNullOrWhiteSpace(response.Content)) { return; } JsonConvert.PopulateObject(response.Content, this); }
public async Task <List <MatchItem> > GetMatchAsync(UID matchId) { var request = new RestRequest("matches/get", Method.GET); request.AddParameter("id", matchId.ToString()); IRestResponse response = await CODAPI.SendRestRequestAsync(request).ConfigureAwait(false); if (response.ResponseStatus != ResponseStatus.Completed || String.IsNullOrWhiteSpace(response.Content)) { return(null); } return(JObject.Parse(response.Content)["entry"].ToObject <List <MatchItem> >()); }
public async Task <List <MatchItem> > GetRecentMatchesAsync(int entryCount = 100) { if (entryCount > 0 && entryCount <= 100) { var request = new RestRequest("matches/recent", Method.GET); request.AddParameter("rows", entryCount); IRestResponse response = await CODAPI.SendRestRequestAsync(request).ConfigureAwait(false); if (response.ResponseStatus != ResponseStatus.Completed || String.IsNullOrWhiteSpace(response.Content)) { return(null); } return(JObject.Parse(response.Content)["entries"].ToObject <List <MatchItem> >()); } return(null); }
public CODUser(string username, GameType gameType, PlatformType platformType) { var request = new RestRequest("validate/{gameType}/{username}/{platformType}", Method.GET); request.AddUrlSegment("username", username); request.AddUrlSegment("gameType", gameType.ToString().ToLower()); request.AddUrlSegment("platformType", platformType.ToString().ToLower()); IRestResponse response = CODAPI.SendRestRequest(request); if (response.ResponseStatus != ResponseStatus.Completed || String.IsNullOrWhiteSpace(response.Content)) { return; } Game = gameType; Platform = platformType; JsonConvert.PopulateObject(response.Content, this); }
public async Task <List <LeaderboardItem> > GetLeaderboardAsync(GameType gameType, LeaderboardPlatformType platformType = LeaderboardPlatformType.ALL, LeaderboardType leaderboardType = LeaderboardType.WINS, int entryCount = 100) { if (entryCount > 0 && entryCount <= 100) { var request = new RestRequest("leaderboard/{gameType}/{platformType}/{leaderboardType}", Method.GET); request.AddUrlSegment("gameType", gameType.ToString().ToLower()); request.AddUrlSegment("platformType", platformType.ToString().ToLower()); request.AddUrlSegment("leaderboardType", leaderboardType.ToString().ToLower()); request.AddParameter("rows", entryCount); IRestResponse response = await CODAPI.SendRestRequestAsync(request).ConfigureAwait(false); if (response.ResponseStatus != ResponseStatus.Completed || String.IsNullOrWhiteSpace(response.Content)) { return(null); } return(JObject.Parse(response.Content)["entries"].ToObject <List <LeaderboardItem> >()); } return(null); }