You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
GetResourceAll = GetSchema;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
notificationResource.Command = String.Format("test{0}", notification.Implementation.ToLowerInvariant());
|
|
|
|
|
|
|
|
|
|
result.Add(notificationResource);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|