Example #1
0
        public async Task <T> ExecuteAsync <T>(RestRequestDetails requestDetails) where T : new()
        {
            var policy = Policy.Handle <Exception>().RetryAsync();

            HttpClient          client = new HttpClient();
            HttpResponseMessage httpResponseMessage = null;

            return(await policy.ExecuteAsync(() =>
            {
                var requestMessage = requestDetails.ToHttpRequestMessage();

                // move to config
                requestMessage.Headers.Add("X-AUTH", "fa0b97bb037d0decef75cf9c9693ffb5d5878118");

                httpResponseMessage = client.SendAsync(requestMessage).Result;
                var responseContent = httpResponseMessage.Content.ReadAsStringAsync().Result;

                return httpResponseMessage.Content.ReadAsAsync <T>(new MediaTypeFormatter[]
                                                                   { CreateMediaTypeFormatter() });
            }).ConfigureAwait(false));
        }
Example #2
0
        public virtual List <screenshot> GetUserScreenshots(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/screenshots");

            return(GetList <screenshot>(requestDetails));
        }
Example #3
0
        public virtual List <game_clip> GetUserGameClips(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/game-clips");

            return(GetList <game_clip>(requestDetails));
        }
Example #4
0
        public virtual List <activity_item> GetUserActivities(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/activity");

            return(GetSingle <activity>(requestDetails).activityItems);
        }
Example #5
0
        public virtual List <xbox_user> GetFriends(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/friends");

            return(GetList <xbox_user>(requestDetails));
        }
Example #6
0
        // endpoints (https://xboxapi.com/documentation)
        // TODO: add endpoints here

        public virtual xbox_user GetUser(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/profile");

            return(GetSingle <xbox_user>(requestDetails));
        }
Example #7
0
        public T GetSingle <T>(RestRequestDetails requestDetails) where T : new()
        {
            var result = ExecuteAsync <T>(requestDetails).Result;

            return(result);
        }
Example #8
0
        public List <T> GetList <T>(RestRequestDetails requestDetails) where T : new()
        {
            var result = ExecuteAsync <List <T> >(requestDetails).Result;

            return(result ?? new List <T>());
        }
Example #9
0
        public virtual List<screenshot> GetUserScreenshots(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/screenshots");

            return GetList<screenshot>(requestDetails);
        }
Example #10
0
        public virtual List<game_clip> GetUserGameClips(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/game-clips");

            return GetList<game_clip>(requestDetails);
        }
Example #11
0
        public virtual List<activity_item> GetUserActivities(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/activity");

            return GetSingle<activity>(requestDetails).activityItems;
        }
Example #12
0
        public virtual List<xbox_user> GetFriends(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/friends");

            return GetList<xbox_user>(requestDetails);
        }
Example #13
0
        // endpoints (https://xboxapi.com/documentation)
        // TODO: add endpoints here

        public virtual xbox_user GetUser(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/profile");

            return GetSingle<xbox_user>(requestDetails);
        }