Exemplo n.º 1
0
        public async Task <FNBRStats> GetStatsAsync(FNPlatform platform = FNPlatform.PC, FNStatWindow?window = null)
        {
            if (Platforms.Contains(platform))
            {
                var request = new RestRequest("users/public/br_stats", Method.GET);
                request.AddParameter("user_id", UserID.UIDToString());
                request.AddParameter("platform", platform.ToString().ToLower());
                if (window != null)
                {
                    request.AddParameter("window", window.ToString().ToLower());
                }

                IRestResponse response = await FNAPI.SendRestRequestAsync(request).ConfigureAwait(false);

                if (response.ResponseStatus != ResponseStatus.Completed)
                {
                    return(null);
                }

                var tempUser = JsonConvert.DeserializeObject <FNBRTempUser>(response.Content);
                if (tempUser == null)
                {
                    return(null);
                }

                return(new FNBRStats(tempUser));
            }
            return(null);
        }
Exemplo n.º 2
0
        public async Task <FNStatus> GetStatusAsync()
        {
            var           request  = new RestRequest("status/fortnite_server_status", Method.GET);
            IRestResponse response = await FNAPI.SendRestRequestAsync(request).ConfigureAwait(false);

            if (response.ResponseStatus != ResponseStatus.Completed)
            {
                return(null);
            }

            return(JsonConvert.DeserializeObject <FNStatus>(response.Content));
        }
Exemplo n.º 3
0
        public async Task <List <FNPatchnoteItem> > GetPatchnotesAsync()
        {
            var           request  = new RestRequest("patchnotes/get", Method.GET);
            IRestResponse response = await FNAPI.SendRestRequestAsync(request).ConfigureAwait(false);

            if (response.ResponseStatus != ResponseStatus.Completed)
            {
                return(null);
            }

            return(JObject.Parse(response.Content)["blogList"].ToObject <List <FNPatchnoteItem> >());
        }
Exemplo n.º 4
0
        public async Task <List <FNBRStoreItem> > GetUpcomingItemsAsync()
        {
            var request = new RestRequest("upcoming/get", Method.GET);

            IRestResponse response = await FNAPI.SendRestRequestAsync(request).ConfigureAwait(false);

            if (response.ResponseStatus != ResponseStatus.Completed)
            {
                return(null);
            }

            return(JObject.Parse(response.Content)["items"].ToObject <List <FNBRStoreItem> >());
        }
Exemplo n.º 5
0
        public async Task <FNBRItem> GetItemAsync(UID UID)
        {
            var request = new RestRequest("item/get", Method.GET);

            request.AddParameter("ids", UID.UIDToString());
            IRestResponse response = await FNAPI.SendRestRequestAsync(request).ConfigureAwait(false);

            if (response.ResponseStatus != ResponseStatus.Completed)
            {
                return(null);
            }

            return(JsonConvert.DeserializeObject <FNBRItem>(response.Content));
        }
Exemplo n.º 6
0
        public async Task <FNBRStore> GetStoreAsync()
        {
            var request = new RestRequest("store/get", Method.GET);

            request.AddParameter("language", "en");
            IRestResponse response = await FNAPI.SendRestRequestAsync(request).ConfigureAwait(false);

            if (response.ResponseStatus != ResponseStatus.Completed)
            {
                return(null);
            }

            return(JsonConvert.DeserializeObject <FNBRStore>(response.Content));
        }
Exemplo n.º 7
0
        public FNUser(string username)
        {
            var request = new RestRequest("users/id", Method.GET);

            request.AddParameter("username", username);
            IRestResponse response = FNAPI.SendRestRequestAsync(request).Result;

            if (response.ResponseStatus != ResponseStatus.Completed)
            {
                return;
            }

            JsonConvert.PopulateObject(response.Content, this);
        }
Exemplo n.º 8
0
        public async Task <FNChallenges> GetChallengesAsync(FNSeason season = FNSeason.CURRENT)
        {
            var request = new RestRequest("challenges/get", Method.GET);

            request.AddParameter("season", season.ToString().ToLower());
            IRestResponse response = await FNAPI.SendRestRequestAsync(request).ConfigureAwait(false);

            if (response.ResponseStatus != ResponseStatus.Completed)
            {
                return(null);
            }

            return(JsonConvert.DeserializeObject <FNChallenges>(response.Content));
        }
Exemplo n.º 9
0
        public async Task <List <FNBRLeaderboardItem> > GetLeaderboardAsync(FNLeaderboardType leaderboardType, int userCount)
        {
            if (userCount > 0 && userCount <= 100)
            {
                var request = new RestRequest("leaderboards/worldwide", Method.GET);
                request.AddParameter("window", leaderboardType.ToString().ToLower());
                request.AddParameter("users_per_page", userCount.ToString());
                IRestResponse response = await FNAPI.SendRestRequestAsync(request).ConfigureAwait(false);

                if (response.ResponseStatus != ResponseStatus.Completed)
                {
                    return(null);
                }

                return(JObject.Parse(response.Content)["entries"].ToObject <List <FNBRLeaderboardItem> >());
            }
            return(null);
        }
Exemplo n.º 10
0
        public FNUser(UID userID)
        {
            var request = new RestRequest("users/username out of id", Method.GET);

            request.AddParameter("ids[0]", userID.UIDToString());
            IRestResponse response = FNAPI.SendRestRequestAsync(request).Result;

            if (response.ResponseStatus != ResponseStatus.Completed)
            {
                return;
            }

            var user = JsonConvert.DeserializeObject <List <FNUser> >(response.Content)[0];

            if (user != null)
            {
                Username  = user.Username;
                UserID    = user.UserID;
                Platforms = user.Platforms;
            }
        }