@ -1,4 +1,5 @@
using NzbDrone.Core.Messaging.Commands ;
using NzbDrone.Common ;
using NzbDrone.Core.Messaging.Commands ;
using RestSharp ;
using NzbDrone.Core.Rest ;
@ -6,14 +7,14 @@ namespace NzbDrone.Core.Notifications.Pushover
{
public interface IPushoverProxy
{
void SendNotification ( string title , string message , string apiKey , string userKey , PushoverPriority priority );
void SendNotification ( string title , string message , string apiKey , string userKey , PushoverPriority priority , string sound );
}
public class PushoverProxy : IPushoverProxy , IExecute < TestPushoverCommand >
{
private const string URL = "https://api.pushover.net/1/messages.json" ;
public void SendNotification ( string title , string message , string apiKey , string userKey , PushoverPriority priority )
public void SendNotification ( string title , string message , string apiKey , string userKey , PushoverPriority priority , string sound )
{
var client = new RestClient ( URL ) ;
var request = new RestRequest ( Method . POST ) ;
@ -23,6 +24,9 @@ namespace NzbDrone.Core.Notifications.Pushover
request . AddParameter ( "message" , message ) ;
request . AddParameter ( "priority" , ( int ) priority ) ;
if ( ! sound . IsNullOrWhiteSpace ( ) ) request . AddParameter ( "sound" , sound ) ;
client . ExecuteAndValidate ( request ) ;
}
@ -31,7 +35,7 @@ namespace NzbDrone.Core.Notifications.Pushover
const string title = "Test Notification" ;
const string body = "This is a test message from NzbDrone" ;
SendNotification ( title , body , message . ApiKey , message . UserKey , ( PushoverPriority ) message . Priority );
SendNotification ( title , body , message . ApiKey , message . UserKey , ( PushoverPriority ) message . Priority , message . Sound );
}
}
}