public void SendNotification(string title, string message, string apiKey, NotificationPriority priority = NotificationPriority.Normal, string url = null) { try { var notification = new Prowlin.Notification { Application = BuildInfo.AppName, Description = message, Event = title, Priority = priority, Url = url }; notification.AddApiKey(apiKey.Trim()); var client = new ProwlClient(); _logger.Debug("Sending Prowl Notification"); var notificationResult = client.SendNotification(notification); if (!string.IsNullOrWhiteSpace(notificationResult.ErrorMessage)) { throw new InvalidApiKeyException("API Key: " + apiKey + " is invalid"); } } catch (Exception ex) { _logger.Debug(ex, ex.Message); _logger.Warn("Invalid API Key: {0}", apiKey); } }
public virtual bool SendNotification(string title, string message, string apiKeys, NotificationPriority priority = NotificationPriority.Normal, string url = null) { try { var notification = new Notification { Application = "NzbDrone", Description = message, Event = title, Priority = priority, Url = url }; foreach (var apiKey in apiKeys.Split(',')) notification.AddApiKey(apiKey.Trim()); var client = new ProwlClient(); Logger.Trace("Sending Prowl Notification"); var notificationResult = client.SendNotification(notification); if (String.IsNullOrWhiteSpace(notificationResult.ErrorMessage)) return true; } catch (Exception ex) { Logger.TraceException(ex.Message, ex); Logger.Warn("Invalid API Key(s): {0}", apiKeys); } return false; }
public void SendNotification(string title, string message, string apiKey, NotificationPriority priority = NotificationPriority.Normal, string url = null) { try { var notification = new Prowlin.Notification { Application = "Sonarr", Description = message, Event = title, Priority = priority, Url = url }; notification.AddApiKey(apiKey.Trim()); var client = new ProwlClient(); _logger.Debug("Sending Prowl Notification"); var notificationResult = client.SendNotification(notification); if (!string.IsNullOrWhiteSpace(notificationResult.ErrorMessage)) { throw new InvalidApiKeyException("API Key: " + apiKey + " is invalid"); } } catch (Exception ex) { _logger.DebugException(ex.Message, ex); _logger.Warn("Invalid API Key: {0}", apiKey); } }
public void Execute(params object[] list) { INotification notification = new Prowlin.Notification() { Application = "FeuerwehrCloud", Description = (string)list[1], Event = (string)list[0], Priority = NotificationPriority.Emergency, Url = "https://" + System.Environment.MachineName + ".feuerwehrcloud.de:10443/alert.php?alerid=" + (string)list[2] }; notification.AddApiKey("6b9ea4e98c84381c2606dd3ec48ea1033a4d127a"); ProwlClient prowlClient = new ProwlClient(); NotificationResult notificationResult = prowlClient.SendNotification(notification); }
public static void SendNotification(this ProwlClient prowlClient, string eventTitle, string description, string url, string apikey) { Contract.Requires(prowlClient != null); Contract.Requires(eventTitle.NotEmpty()); Contract.Requires(description.NotEmpty()); Contract.Requires(url.IsUri()); Contract.Requires(apikey.NotEmpty()); var notification = new Notification { Application = Application.ProductName, Description = description, Event = eventTitle, Priority = NotificationPriority.High, Url = url }; notification.AddApiKey(apikey); prowlClient.SendNotification(notification); }
public void should_build_dictionary_correctly_from_notification() { Notification notif = new Notification() { Application = "app", Description = "descr", Event = "evt", Priority = NotificationPriority.Emergency, Url = "http://www.nnihlen.com/blog" }; notif.AddApiKey("asdf"); RequestBuilderHelper helper = new RequestBuilderHelper(); Dictionary<string, string> dict = helper.BuildDictionaryForNotificataion(notif); Assert.True(dict.ContainsKey("application")); Assert.Equal("app", dict["application"]); Assert.True(dict.ContainsKey("description")); Assert.Equal("descr", dict["description"]); Assert.True(dict.ContainsKey("event")); Assert.Equal("evt", dict["event"]); Assert.True(dict.ContainsKey("priority")); Assert.Equal("2", dict["priority"]); Assert.True(dict.ContainsKey("url")); Assert.Equal("http://www.nnihlen.com/blog", dict["url"]); Assert.True(dict.ContainsKey("apikey")); Assert.Equal("asdf", dict["apikey"]); }