Пример #1
0
        public void SendNotification(string title, string message, ProwlSettings settings)
        {
            try
            {
                var requestBuilder = new HttpRequestBuilder(PUSH_URL);

                var request = requestBuilder.Post()
                              .AddFormParameter("apikey", settings.ApiKey)
                              .AddFormParameter("application", BuildInfo.AppName)
                              .AddFormParameter("event", title)
                              .AddFormParameter("description", message)
                              .AddFormParameter("priority", settings.Priority)
                              .Build();

                _httpClient.Post(request);
            }
            catch (HttpException ex)
            {
                if (ex.Response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    _logger.Error(ex, "Apikey is invalid: {0}", settings.ApiKey);
                    throw new ProwlException("Apikey is invalid", ex);
                }

                throw new ProwlException("Unable to send text message: " + ex.Message, ex);
            }
            catch (WebException ex)
            {
                throw new ProwlException("Failed to connect to prowl, please check your settings.", ex);
            }
        }
Пример #2
0
        public ValidationFailure Test(ProwlSettings settings)
        {
            try
            {
                const string title = "Test Notification";
                const string body  = "This is a test message from Lidarr";

                SendNotification(title, body, settings.ApiKey);
            }
            catch (Exception ex)
            {
                return(new ValidationFailure("ApiKey", ex.Message));
            }

            return(null);
        }
Пример #3
0
        public ValidationFailure Test(ProwlSettings settings)
        {
            try
            {
                Verify(settings.ApiKey);

                const string title = "Test Notification";
                string       body  = $"This is a test message from {BuildInfo.AppName}";

                SendNotification(title, body, settings.ApiKey);
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Unable to send test message");
                return(new ValidationFailure("ApiKey", "Unable to send test message"));
            }

            return(null);
        }
Пример #4
0
        public ValidationFailure Test(ProwlSettings settings)
        {
            try
            {
                Verify(settings.ApiKey);

                const string title = "Test Notification";
                const string body  = "This is a test message from Sonarr";

                SendNotification(title, body, settings.ApiKey);
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Unable to send test message: " + ex.Message, ex);
                return(new ValidationFailure("ApiKey", "Unable to send test message"));
            }

            return(null);
        }