using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using RequestPlex.Api.Interfaces; using RestSharp; namespace RequestPlex.Api { public class ApiRequest : IApiRequest { /// /// An API request handler /// /// The type of class you want to deserialize /// The request. /// The base URI. /// The type of class you want to deserialize public T Execute(IRestRequest request, Uri baseUri) where T : new() { var client = new RestClient { BaseUrl = baseUri }; var response = client.Execute(request); if (response.ErrorException != null) { var message = "Error retrieving response. Check inner details for more info."; throw new ApplicationException(message, response.ErrorException); } return response.Data; } } }