1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00
Radarr/NzbDrone.Api/Notifications/NotificationSchemaModule.cs

42 lines
1.4 KiB
C#
Raw Normal View History

2013-06-13 04:55:11 +02:00
using System;
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 02:19:07 +02:00
GetResourceAll = GetSchema;
}
2013-05-28 02:19:07 +02:00
private List<NotificationResource> GetSchema()
{
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);
2013-06-13 04:55:11 +02:00
notificationResource.Command = String.Format("test{0}", notification.Implementation.ToLowerInvariant());
result.Add(notificationResource);
}
return result;
}
}
}