mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 05:23:31 -07:00
Added PushBullet notifications
This commit is contained in:
parent
742a21252c
commit
42efef0bb2
5 changed files with 129 additions and 0 deletions
38
NzbDrone.Core/Notifications/PushBullet/PushBulletProxy.cs
Normal file
38
NzbDrone.Core/Notifications/PushBullet/PushBulletProxy.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using RestSharp;
|
||||
using NzbDrone.Core.Rest;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.PushBullet
|
||||
{
|
||||
public interface IPushBulletProxy
|
||||
{
|
||||
void SendNotification(string title, string message, string apiKey, int deviceId);
|
||||
}
|
||||
|
||||
public class PushBulletProxy : IPushBulletProxy, IExecute<TestPushBulletCommand>
|
||||
{
|
||||
private const string URL = "https://www.pushbullet.com/api/pushes";
|
||||
|
||||
public void SendNotification(string title, string message, string apiKey, int deviceId)
|
||||
{
|
||||
var client = new RestClient(URL);
|
||||
var request = new RestRequest(Method.POST);
|
||||
request.AddParameter("device_id", deviceId);
|
||||
request.AddParameter("type", "note");
|
||||
request.AddParameter("title", title);
|
||||
request.AddParameter("body", message);
|
||||
|
||||
client.Authenticator = new HttpBasicAuthenticator(apiKey, String.Empty);
|
||||
client.ExecuteAndValidate(request);
|
||||
}
|
||||
|
||||
public void Execute(TestPushBulletCommand message)
|
||||
{
|
||||
const string title = "Test Notification";
|
||||
const string body = "This is a test message from NzbDrone";
|
||||
|
||||
SendNotification(title, body, message.ApiKey, message.DeviceId);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue