mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
First pass with RequestPlex
This commit is contained in:
parent
83848865e8
commit
a4f892b702
38 changed files with 8028 additions and 0 deletions
41
RequestPlex/RequestPlex.Api/ApiRequest.cs
Normal file
41
RequestPlex/RequestPlex.Api/ApiRequest.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
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
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// An API request handler
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of class you want to deserialize</typeparam>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <param name="baseUri">The base URI.</param>
|
||||
/// <returns>The type of class you want to deserialize</returns>
|
||||
public T Execute<T>(IRestRequest request, Uri baseUri) where T : new()
|
||||
{
|
||||
var client = new RestClient { BaseUrl = baseUri };
|
||||
|
||||
var response = client.Execute<T>(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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue