Beispiel #1
0
        public void TestConfig(PushalotConfig config)
        {
            var msg = new Message(config.AuthorizationToken, "Test notification from Hadouken.")
            {
                Title = "Hadouken"
            };

            _pushalotClient.Send(msg);
        }
Beispiel #2
0
        public void Send(Message message)
        {
            if (message == null) throw new ArgumentNullException("message");

            var data = new List<KeyValuePair<string, string>>
            {
                new KeyValuePair<string, string>("AuthorizationToken", message.AuthorizationToken),
                new KeyValuePair<string, string>("Body", message.Body),
                new KeyValuePair<string, string>("Title", message.Title),
                new KeyValuePair<string, string>("Source", message.Source)
            };

            var response = _httpClient.PostAsync(ApiUri, new FormUrlEncodedContent(data)).Result;

            if (!response.IsSuccessStatusCode)
            {
                _logger.Error("Error pushing message. Response status code: {StatusCode}.", response.StatusCode);
            }
        }
Beispiel #3
0
        public void Notify(Notification notification)
        {
            var config = _keyValueStore.Get<PushalotConfig>("pushalot.config");

            if (config == null)
            {
                _logger.Warn("Pushalot not configured.");
                return;
            }

            if (string.IsNullOrEmpty(config.AuthorizationToken))
            {
                _logger.Warn("Pushalot authorization token not set.");
                return;
            }

            var msg = new Message(config.AuthorizationToken, notification.Message)
            {
                Title = notification.Title
            };

            _pushalotClient.Send(msg);
        }