mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
NotificationModule added to API
This commit is contained in:
36
NzbDrone.Api/Notifications/NotificationModule.cs
Normal file
36
NzbDrone.Api/Notifications/NotificationModule.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using NzbDrone.Api.ClientSchema;
|
||||||
|
using NzbDrone.Core.Notifications;
|
||||||
|
using Omu.ValueInjecter;
|
||||||
|
|
||||||
|
namespace NzbDrone.Api.Notifications
|
||||||
|
{
|
||||||
|
public class NotificationModule : NzbDroneRestModule<NotificationResource>
|
||||||
|
{
|
||||||
|
private readonly INotificationService _notificationService;
|
||||||
|
|
||||||
|
public NotificationModule(INotificationService notificationService)
|
||||||
|
{
|
||||||
|
_notificationService = notificationService;
|
||||||
|
GetResourceAll = GetAll;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<NotificationResource> GetAll()
|
||||||
|
{
|
||||||
|
var notifications = _notificationService.All();
|
||||||
|
|
||||||
|
var result = new List<NotificationResource>(notifications.Count);
|
||||||
|
|
||||||
|
foreach (var notification in notifications)
|
||||||
|
{
|
||||||
|
var indexerResource = new NotificationResource();
|
||||||
|
indexerResource.InjectFrom(notification);
|
||||||
|
indexerResource.Fields = SchemaBuilder.GenerateSchema(notification.Settings);
|
||||||
|
|
||||||
|
result.Add(indexerResource);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
NzbDrone.Api/Notifications/NotificationResource.cs
Normal file
14
NzbDrone.Api/Notifications/NotificationResource.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NzbDrone.Api.ClientSchema;
|
||||||
|
using NzbDrone.Api.REST;
|
||||||
|
|
||||||
|
namespace NzbDrone.Api.Notifications
|
||||||
|
{
|
||||||
|
public class NotificationResource : RestResource
|
||||||
|
{
|
||||||
|
public Boolean Enable { get; set; }
|
||||||
|
public String Name { get; set; }
|
||||||
|
public List<Field> Fields { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -112,6 +112,8 @@
|
|||||||
<Compile Include="Mapping\ResourceMappingException.cs" />
|
<Compile Include="Mapping\ResourceMappingException.cs" />
|
||||||
<Compile Include="Mapping\ValueInjectorExtensions.cs" />
|
<Compile Include="Mapping\ValueInjectorExtensions.cs" />
|
||||||
<Compile Include="Missing\MissingModule.cs" />
|
<Compile Include="Missing\MissingModule.cs" />
|
||||||
|
<Compile Include="Notifications\NotificationModule.cs" />
|
||||||
|
<Compile Include="Notifications\NotificationResource.cs" />
|
||||||
<Compile Include="NzbDroneRestModule.cs" />
|
<Compile Include="NzbDroneRestModule.cs" />
|
||||||
<Compile Include="PagingResource.cs" />
|
<Compile Include="PagingResource.cs" />
|
||||||
<Compile Include="Resolvers\NullableDatetimeToString.cs" />
|
<Compile Include="Resolvers\NullableDatetimeToString.cs" />
|
||||||
|
Reference in New Issue
Block a user