1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-30 19:45:57 +00:00
Lidarr/NzbDrone.Api/Notifications/NotificationSchemaModule.cs

42 lines
1.3 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using NzbDrone.Api.ClientSchema;
using NzbDrone.Common.Reflection;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Notifications;
using Omu.ValueInjecter;
namespace NzbDrone.Api.Notifications
{
public class NotificationSchemaModule : NzbDroneRestModule<NotificationResource>
{
private readonly INotificationService _notificationService;
public NotificationSchemaModule(INotificationService notificationService)
: base("notification/schema")
{
_notificationService = notificationService;
2013-05-28 00:19:07 +00:00
GetResourceAll = GetSchema;
}
2013-05-28 00:19:07 +00:00
private List<NotificationResource> GetSchema()
{
//Need to get all the possible Notification's same as we would for settiings (but keep them empty)
var notifications = _notificationService.Schema();
var result = new List<NotificationResource>(notifications.Count);
foreach (var notification in notifications)
{
var notificationResource = new NotificationResource();
notificationResource.InjectFrom(notification);
notificationResource.Fields = SchemaBuilder.GenerateSchema(notification.Settings);
result.Add(notificationResource);
}
return result;
}
}
}