Beispiel #1
0
        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));;
        }
Beispiel #2
0
        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> >());
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }