mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 00:53:57 -07:00
Updated restmodule, moved series, root folder to the new restmodule.
This commit is contained in:
parent
4878556e14
commit
a2e84a8f83
16 changed files with 321 additions and 219 deletions
|
@ -1,29 +1,32 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using FluentAssertions;
|
||||
using FluentValidation;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Api.REST;
|
||||
using RestSharp;
|
||||
|
||||
namespace NzbDrone.Integration.Test.Client
|
||||
{
|
||||
public abstract class ClientBase<TResource> where TResource : new()
|
||||
public class ClientBase<TResource> where TResource : RestResource, new()
|
||||
{
|
||||
private readonly IRestClient _restClient;
|
||||
private readonly string _resource;
|
||||
|
||||
private readonly Logger _logger;
|
||||
|
||||
protected ClientBase(IRestClient restClient, string resource)
|
||||
public ClientBase(IRestClient restClient, string resource = null)
|
||||
{
|
||||
if (resource == null)
|
||||
{
|
||||
resource = new TResource().ResourceName;
|
||||
}
|
||||
|
||||
_restClient = restClient;
|
||||
_resource = resource;
|
||||
_logger = LogManager.GetLogger("REST");
|
||||
}
|
||||
|
||||
public List<TResource> GetAll()
|
||||
public List<TResource> All()
|
||||
{
|
||||
var request = BuildRequest();
|
||||
return Get<List<TResource>>(request);
|
||||
|
@ -36,6 +39,12 @@ namespace NzbDrone.Integration.Test.Client
|
|||
return Post<TResource>(request);
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
var request = BuildRequest(id.ToString());
|
||||
Delete(request);
|
||||
}
|
||||
|
||||
public List<string> InvalidPost(TResource body)
|
||||
{
|
||||
var request = BuildRequest();
|
||||
|
@ -63,6 +72,12 @@ namespace NzbDrone.Integration.Test.Client
|
|||
return Execute<T>(request, statusCode);
|
||||
}
|
||||
|
||||
public void Delete(IRestRequest request, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||
{
|
||||
request.Method = Method.DELETE;
|
||||
Execute<object>(request, statusCode);
|
||||
}
|
||||
|
||||
private T Execute<T>(IRestRequest request, HttpStatusCode statusCode) where T : new()
|
||||
{
|
||||
_logger.Info("{0}: {1}", request.Method, _restClient.BuildUri(request));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue