diff --git a/NzbDrone.Api/Notifications/NotificationModule.cs b/NzbDrone.Api/Notifications/NotificationModule.cs new file mode 100644 index 000000000..34b51865d --- /dev/null +++ b/NzbDrone.Api/Notifications/NotificationModule.cs @@ -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 + { + private readonly INotificationService _notificationService; + + public NotificationModule(INotificationService notificationService) + { + _notificationService = notificationService; + GetResourceAll = GetAll; + } + + private List GetAll() + { + var notifications = _notificationService.All(); + + var result = new List(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; + } + } +} \ No newline at end of file diff --git a/NzbDrone.Api/Notifications/NotificationResource.cs b/NzbDrone.Api/Notifications/NotificationResource.cs new file mode 100644 index 000000000..77deb5426 --- /dev/null +++ b/NzbDrone.Api/Notifications/NotificationResource.cs @@ -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 Fields { get; set; } + } +} \ No newline at end of file diff --git a/NzbDrone.Api/NzbDrone.Api.csproj b/NzbDrone.Api/NzbDrone.Api.csproj index ddac818a3..d23daf537 100644 --- a/NzbDrone.Api/NzbDrone.Api.csproj +++ b/NzbDrone.Api/NzbDrone.Api.csproj @@ -112,6 +112,8 @@ + +