2013-07-25 07:24:09 +00:00
using System ;
2013-10-12 18:44:40 +00:00
using FluentValidation ;
2013-09-21 07:09:26 +00:00
using FluentValidation.Results ;
2013-07-25 07:24:09 +00:00
using NzbDrone.Core.Annotations ;
2013-09-21 06:39:26 +00:00
using NzbDrone.Core.ThingiProvider ;
2013-07-25 07:24:09 +00:00
namespace NzbDrone.Core.Notifications.Pushover
{
2013-10-12 18:44:40 +00:00
public class PushoverSettingsValidator : AbstractValidator < PushoverSettings >
{
public PushoverSettingsValidator ( )
{
RuleFor ( c = > c . UserKey ) . NotEmpty ( ) ;
}
}
2013-09-21 06:39:26 +00:00
public class PushoverSettings : IProviderConfig
2013-07-25 07:24:09 +00:00
{
2013-10-12 18:44:40 +00:00
private static readonly PushoverSettingsValidator Validator = new PushoverSettingsValidator ( ) ;
2014-08-05 20:51:06 +00:00
public PushoverSettings ( )
{
Priority = 0 ;
}
2013-12-31 04:48:14 +00:00
[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/")]
2013-07-25 07:24:09 +00:00
public String UserKey { get ; set ; }
2013-12-31 04:48:14 +00:00
[FieldDefinition(2, Label = "Priority", Type = FieldType.Select, SelectOptions = typeof(PushoverPriority) )]
2013-07-25 07:24:09 +00:00
public Int32 Priority { get ; set ; }
2014-04-03 14:05:38 +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
{
2014-07-04 08:09:48 +00:00
return ! string . IsNullOrWhiteSpace ( UserKey ) & & Priority > = - 1 & & Priority < = 2 ;
2013-07-25 07:24:09 +00:00
}
}
2013-09-21 07:09:26 +00:00
public ValidationResult Validate ( )
{
2013-10-12 18:44:40 +00:00
return Validator . Validate ( this ) ;
2013-09-21 07:09:26 +00:00
}
2013-07-25 07:24:09 +00:00
}
}