mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-20 21:54:58 -04:00
Updated Nancy to 2.0
This commit is contained in:
@@ -3,12 +3,10 @@ using System.Linq;
|
||||
using FluentValidation;
|
||||
using FluentValidation.Results;
|
||||
using Nancy;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Validation;
|
||||
using Sonarr.Http;
|
||||
using Sonarr.Http.Extensions;
|
||||
|
||||
namespace Sonarr.Api.V3
|
||||
{
|
||||
@@ -26,10 +24,10 @@ namespace Sonarr.Api.V3
|
||||
_providerFactory = providerFactory;
|
||||
_resourceMapper = resourceMapper;
|
||||
|
||||
Get["schema"] = x => GetTemplates();
|
||||
Post["test"] = x => Test(ReadResourceFromRequest(true));
|
||||
Post["testall"] = x => TestAll();
|
||||
Post["action/{action}"] = x => RequestAction(x.action, ReadResourceFromRequest(true));
|
||||
Get("schema", x => GetTemplates());
|
||||
Post("test", x => Test(ReadResourceFromRequest(true)));
|
||||
Post("testall", x => TestAll());
|
||||
Post("action/{action}", x => RequestAction(x.action, ReadResourceFromRequest(true)));
|
||||
|
||||
GetResourceAll = GetAll;
|
||||
GetResourceById = GetProviderById;
|
||||
@@ -112,7 +110,7 @@ namespace Sonarr.Api.V3
|
||||
_providerFactory.Delete(id);
|
||||
}
|
||||
|
||||
private Response GetTemplates()
|
||||
private object GetTemplates()
|
||||
{
|
||||
var defaultDefinitions = _providerFactory.GetDefaultDefinitions().OrderBy(p => p.ImplementationName).ToList();
|
||||
|
||||
@@ -133,10 +131,10 @@ namespace Sonarr.Api.V3
|
||||
result.Add(providerResource);
|
||||
}
|
||||
|
||||
return result.AsResponse();
|
||||
return result;
|
||||
}
|
||||
|
||||
private Response Test(TProviderResource providerResource)
|
||||
private object Test(TProviderResource providerResource)
|
||||
{
|
||||
var providerDefinition = GetDefinition(providerResource, true);
|
||||
|
||||
@@ -145,7 +143,7 @@ namespace Sonarr.Api.V3
|
||||
return "{}";
|
||||
}
|
||||
|
||||
private Response TestAll()
|
||||
private object TestAll()
|
||||
{
|
||||
var providerDefinitions = _providerFactory.All()
|
||||
.Where(c => c.Settings.Validate().IsValid && c.Enable)
|
||||
@@ -163,10 +161,10 @@ namespace Sonarr.Api.V3
|
||||
});
|
||||
}
|
||||
|
||||
return result.AsResponse(result.Any(c => !c.IsValid) ? HttpStatusCode.BadRequest : HttpStatusCode.OK);
|
||||
return ResponseWithCode(result, result.Any(c => !c.IsValid) ? HttpStatusCode.BadRequest : HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
private Response RequestAction(string action, TProviderResource providerResource)
|
||||
private object RequestAction(string action, TProviderResource providerResource)
|
||||
{
|
||||
var providerDefinition = GetDefinition(providerResource, true, false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user