diff --git a/src/NzbDrone.Core/Notifications/PushBullet/PushBulletProxy.cs b/src/NzbDrone.Core/Notifications/PushBullet/PushBulletProxy.cs index 93d17bb62..eb85e573f 100644 --- a/src/NzbDrone.Core/Notifications/PushBullet/PushBulletProxy.cs +++ b/src/NzbDrone.Core/Notifications/PushBullet/PushBulletProxy.cs @@ -7,18 +7,18 @@ namespace NzbDrone.Core.Notifications.PushBullet { public interface IPushBulletProxy { - void SendNotification(string title, string message, string apiKey, long deviceId); + void SendNotification(string title, string message, string apiKey, string deviceId); } public class PushBulletProxy : IPushBulletProxy, IExecute { private const string URL = "https://api.pushbullet.com/api/pushes"; - public void SendNotification(string title, string message, string apiKey, long deviceId) + public void SendNotification(string title, string message, string apiKey, string deviceId) { var client = new RestClient(URL); - var request = new RestRequest(Method.POST); - request.AddParameter("device_id", deviceId); + var request = BuildRequest(deviceId); + request.AddParameter("type", "note"); request.AddParameter("title", title); request.AddParameter("body", message); @@ -27,6 +27,24 @@ namespace NzbDrone.Core.Notifications.PushBullet client.ExecuteAndValidate(request); } + public RestRequest BuildRequest(string deviceId) + { + var request = new RestRequest(Method.POST); + long integerId; + + if (Int64.TryParse(deviceId, out integerId)) + { + request.AddParameter("device_id", integerId); + } + + else + { + request.AddParameter("device_iden", deviceId); + } + + return request; + } + public void Execute(TestPushBulletCommand message) { const string title = "Test Notification"; diff --git a/src/NzbDrone.Core/Notifications/PushBullet/PushBulletSettings.cs b/src/NzbDrone.Core/Notifications/PushBullet/PushBulletSettings.cs index 1525f6413..375590a0b 100644 --- a/src/NzbDrone.Core/Notifications/PushBullet/PushBulletSettings.cs +++ b/src/NzbDrone.Core/Notifications/PushBullet/PushBulletSettings.cs @@ -11,7 +11,7 @@ namespace NzbDrone.Core.Notifications.PushBullet public PushBulletSettingsValidator() { RuleFor(c => c.ApiKey).NotEmpty(); - RuleFor(c => c.DeviceId).GreaterThan(0); + RuleFor(c => c.DeviceId).NotEmpty(); } } @@ -23,13 +23,13 @@ namespace NzbDrone.Core.Notifications.PushBullet public String ApiKey { get; set; } [FieldDefinition(1, Label = "Device ID")] - public Int64 DeviceId { get; set; } + public String DeviceId { get; set; } public bool IsValid { get { - return !String.IsNullOrWhiteSpace(ApiKey) && DeviceId > 0; + return !String.IsNullOrWhiteSpace(ApiKey) && !String.IsNullOrWhiteSpace(DeviceId); } } diff --git a/src/NzbDrone.Core/Notifications/PushBullet/TestPushBulletCommand.cs b/src/NzbDrone.Core/Notifications/PushBullet/TestPushBulletCommand.cs index e4fe19e83..fd0f6732d 100644 --- a/src/NzbDrone.Core/Notifications/PushBullet/TestPushBulletCommand.cs +++ b/src/NzbDrone.Core/Notifications/PushBullet/TestPushBulletCommand.cs @@ -13,6 +13,6 @@ namespace NzbDrone.Core.Notifications.PushBullet } } public string ApiKey { get; set; } - public long DeviceId { get; set; } + public string DeviceId { get; set; } } }