Beispiel #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);
        }