Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        public virtual List <screenshot> GetUserScreenshots(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/screenshots");

            return(GetList <screenshot>(requestDetails));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 4
0
        public virtual List <activity_item> GetUserActivities(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/activity");

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

            return(GetList <xbox_user>(requestDetails));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 7
0
        public T GetSingle <T>(RestRequestDetails requestDetails) where T : new()
        {
            var result = ExecuteAsync <T>(requestDetails).Result;

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

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

            return GetList<screenshot>(requestDetails);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 11
0
        public virtual List<activity_item> GetUserActivities(long xboxUserId)
        {
            var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/activity");

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

            return GetList<xbox_user>(requestDetails);
        }
Ejemplo n.º 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);
        }