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.
Prowlarr/src/NzbDrone.Core/Notifications/Webhook/WebhookSettings.cs

43 lines
1.4 KiB

using System;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Notifications.Webhook
{
public class WebhookSettingsValidator : AbstractValidator<WebhookSettings>
{
public WebhookSettingsValidator()
{
RuleFor(c => c.Url).IsValidUrl();
}
}
public class WebhookSettings : NotificationBaseSettings
{
private static readonly WebhookSettingsValidator Validator = new WebhookSettingsValidator();
public WebhookSettings()
{
Method = Convert.ToInt32(WebhookMethod.POST);
}
[FieldDefinition(0, Label = "URL", Type = FieldType.Url)]
public string Url { get; set; }
[FieldDefinition(1, Label = "Method", Type = FieldType.Select, SelectOptions = typeof(WebhookMethod), HelpText = "Which HTTP method to use submit to the Webservice")]
public int Method { get; set; }
[FieldDefinition(2, Label = "Username", HelpText = "Username", Type = FieldType.Textbox, Privacy = PrivacyLevel.UserName)]
public string Username { get; set; }
[FieldDefinition(3, Label = "Password", HelpText = "Password", Type = FieldType.Password, Privacy = PrivacyLevel.Password)]
public string Password { get; set; }
public override NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));
}
}
}