private Response SavePushbulletNotifications() { var settings = this.Bind <PushbulletNotificationSettings>(); var valid = this.Validate(settings); if (!valid.IsValid) { return(Response.AsJson(valid.SendJsonError())); } Log.Trace(settings.DumpJson()); var result = PushbulletService.SaveSettings(settings); if (settings.Enabled) { NotificationService.Subscribe(new PushbulletNotification(PushbulletApi, PushbulletService)); } else { NotificationService.UnSubscribe(new PushbulletNotification(PushbulletApi, PushbulletService)); } Log.Info("Saved email settings, result: {0}", result); return(Response.AsJson(result ? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for Pushbullet Notifications!" } : new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." })); }
public void TestPushbulletAddress() { PushMessage message = new PushMessage(); message.device_iden = TestDeviceId; message.type = new Address { name = "John Doe", address = "Big yella house" }; PushResponse response = PushbulletService.Push(message); Assert.IsInstanceOfType(response, typeof(PushResponse)); }
public void TestPushbulletLink() { PushMessage message = new PushMessage(); message.device_iden = TestDeviceId; message.type = new Link { title = "Test C# API Title", url = "http://www.google.co.uk" }; PushResponse response = PushbulletService.Push(message); Assert.IsInstanceOfType(response, typeof(PushResponse)); }
public void TestPushbulletNote() { PushMessage message = new PushMessage(); message.device_iden = TestDeviceId; message.type = new Note { title = "Test C# API Title", body = "Test C# API Body" }; PushResponse response = PushbulletService.Push(message); Assert.IsInstanceOfType(response, typeof(PushResponse)); }
public void TestPushbulletList() { PushMessage message = new PushMessage(); message.device_iden = TestDeviceId; message.type = new List { title = "Shopping", items = new List <string> { "Eggs", "Milk", "Bread", "Corn Flakes", "Butter" } }; PushResponse response = PushbulletService.Push(message); Assert.IsInstanceOfType(response, typeof(PushResponse)); }
private async Task <Response> TestPushbulletNotifications() { var settings = this.Bind <PushbulletNotificationSettings>(); var valid = this.Validate(settings); if (!valid.IsValid) { return(Response.AsJson(valid.SendJsonError())); } var notificationModel = new NotificationModel { NotificationType = NotificationType.Test, DateTime = DateTime.Now }; var currentSettings = await PushbulletService.GetSettingsAsync(); try { NotificationService.Subscribe(new PushbulletNotification(PushbulletApi, PushbulletService)); settings.Enabled = true; await NotificationService.Publish(notificationModel, settings); Log.Info("Sent pushbullet notification test"); } catch (Exception) { Log.Error("Failed to subscribe and publish test Pushbullet Notification"); } finally { if (!currentSettings.Enabled) { NotificationService.UnSubscribe(new PushbulletNotification(PushbulletApi, PushbulletService)); } } return(Response.AsJson(new JsonResponseModel { Result = true, Message = "Successfully sent a test Pushbullet Notification!" })); }
private Negotiator PushbulletNotifications() { var settings = PushbulletService.GetSettings(); return(View["PushbulletNotifications", settings]); }
public static void InitializePushbulletTests(TestContext testContext) { PushbulletService.APIKEY = ConfigurationManager.AppSettings["APIKEY"]; TestDeviceId = PushbulletService.GetDevices().devices.First(d => d.extras.model == "GT-I9300").iden; }