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)); }
public virtual List <screenshot> GetUserScreenshots(long xboxUserId) { var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/screenshots"); return(GetList <screenshot>(requestDetails)); }
public virtual List <game_clip> GetUserGameClips(long xboxUserId) { var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/game-clips"); return(GetList <game_clip>(requestDetails)); }
public virtual List <activity_item> GetUserActivities(long xboxUserId) { var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/activity"); return(GetSingle <activity>(requestDetails).activityItems); }
public virtual List <xbox_user> GetFriends(long xboxUserId) { var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/friends"); return(GetList <xbox_user>(requestDetails)); }
// 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)); }
public T GetSingle <T>(RestRequestDetails requestDetails) where T : new() { var result = ExecuteAsync <T>(requestDetails).Result; return(result); }
public List <T> GetList <T>(RestRequestDetails requestDetails) where T : new() { var result = ExecuteAsync <List <T> >(requestDetails).Result; return(result ?? new List <T>()); }
public virtual List<screenshot> GetUserScreenshots(long xboxUserId) { var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/screenshots"); return GetList<screenshot>(requestDetails); }
public virtual List<game_clip> GetUserGameClips(long xboxUserId) { var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/game-clips"); return GetList<game_clip>(requestDetails); }
public virtual List<activity_item> GetUserActivities(long xboxUserId) { var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/activity"); return GetSingle<activity>(requestDetails).activityItems; }
public virtual List<xbox_user> GetFriends(long xboxUserId) { var requestDetails = new RestRequestDetails(HttpMethod.Get, apiResourceUrl + xboxUserId + "/friends"); return GetList<xbox_user>(requestDetails); }
// 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); }