Esempio n. 1
0
        public void Send(PushoverMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            var data = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("token", message.Token),
                new KeyValuePair <string, string>("user", message.User),
                new KeyValuePair <string, string>("message", message.Message)
            };

            if (!string.IsNullOrEmpty(message.Title))
            {
                data.Add(new KeyValuePair <string, string>("title", message.Title));
            }

            var uri      = new Uri(ApiUri, "1/messages.json");
            var response = _httpClient.PostAsync(uri, new FormUrlEncodedContent(data)).Result;

            if (!response.IsSuccessStatusCode)
            {
                _logger.Error(string.Format("Error pushing message. Response status code: {0}.", response.StatusCode));
            }
        }
Esempio n. 2
0
        public void Notify(Notification notification)
        {
            var config = _keyValueStore.Get<PushoverConfig>("pushover.config");
            
            if (config == null)
            {
                _logger.Warn("Pushover not configured.");
                return;
            }

            var message = new PushoverMessage(config.AppKey, config.UserKey, notification.Message)
            {
                Title = notification.Title
            };

            _pushoverClient.Send(message);
        }
Esempio n. 3
0
        public void Send(PushoverMessage message)
        {
            if (message == null) throw new ArgumentNullException("message");

            var data = new List<KeyValuePair<string, string>>
                {
                    new KeyValuePair<string, string>("token", message.Token),
                    new KeyValuePair<string, string>("user", message.User),
                    new KeyValuePair<string, string>("message", message.Message)
                };

            if (!string.IsNullOrEmpty(message.Title))
            {
                data.Add(new KeyValuePair<string, string>("title", message.Title));
            }

            var uri = new Uri(ApiUri, "1/messages.json");
            var response = _httpClient.PostAsync(uri, new FormUrlEncodedContent(data)).Result;

            if (!response.IsSuccessStatusCode)
            {
                _logger.Error(string.Format("Error pushing message. Response status code: {0}.", response.StatusCode));
            }
        }
Esempio n. 4
0
 public void TestConfig(PushoverConfig config)
 {
     var message = new PushoverMessage(config.AppKey, config.UserKey, "Test notification from Hadouken");
     _pushoverClient.Send(message);
 }