Lidarr/src/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs

53 lines
1.7 KiB
C#
Raw Normal View History

2013-07-25 07:24:09 +00:00
using System;
using FluentValidation;
2013-07-25 07:24:09 +00:00
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
2013-07-25 07:24:09 +00:00
namespace NzbDrone.Core.Notifications.Pushover
{
public class PushoverSettingsValidator : AbstractValidator<PushoverSettings>
{
public PushoverSettingsValidator()
{
RuleFor(c => c.UserKey).NotEmpty();
}
}
public class PushoverSettings : IProviderConfig
2013-07-25 07:24:09 +00:00
{
private static readonly PushoverSettingsValidator Validator = new PushoverSettingsValidator();
2014-08-05 20:51:06 +00:00
public PushoverSettings()
{
Priority = 0;
}
//TODO: Get Pushover to change our app name (or create a new app) when we have a new logo
[FieldDefinition(0, Label = "API Key", HelpLink = "https://pushover.net/apps/clone/nzbdrone")]
public string ApiKey { get; set; }
[FieldDefinition(1, Label = "User Key", HelpLink = "https://pushover.net/")]
public string UserKey { get; set; }
2013-07-25 07:24:09 +00:00
[FieldDefinition(2, Label = "Priority", Type = FieldType.Select, SelectOptions = typeof(PushoverPriority) )]
public int Priority { get; set; }
2013-07-25 07:24:09 +00:00
[FieldDefinition(3, Label = "Sound", Type = FieldType.Textbox, HelpText = "Notification sound, leave blank to use the default", HelpLink = "https://pushover.net/api#sounds")]
public string Sound { get; set; }
2013-07-25 07:24:09 +00:00
public bool IsValid
{
get
{
return !string.IsNullOrWhiteSpace(UserKey) && Priority >= -1 && Priority <= 2;
2013-07-25 07:24:09 +00:00
}
}
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));
}
2013-07-25 07:24:09 +00:00
}
}