Esempio n. 1
0
        public void SendWebhook(WebhookPayload body, WebhookSettings settings)
        {
            try
            {
                var request = new HttpRequestBuilder(settings.Url)
                              .Accept(HttpAccept.Json)
                              .Build();

                request.Method = settings.Method switch
                {
                    (int)WebhookMethod.POST => HttpMethod.Post,
                    (int)WebhookMethod.PUT => HttpMethod.Put,
                    _ => throw new ArgumentOutOfRangeException($"Invalid Webhook method {settings.Method}")
                };

                request.Headers.ContentType = "application/json";
                request.SetContent(body.ToJson());

                if (settings.Username.IsNotNullOrWhiteSpace() || settings.Password.IsNotNullOrWhiteSpace())
                {
                    request.AddBasicAuthentication(settings.Username, settings.Password);
                }

                _httpClient.Execute(request);
            }
            catch (HttpException ex)
            {
                throw new WebhookException("Unable to post to webhook: {0}", ex, ex.Message);
            }
        }
Esempio n. 2
0
        public void SendWebhook(WebhookPayload body, WebhookSettings settings)
        {
            try
            {
                var request = new HttpRequestBuilder(settings.Url)
                              .Accept(HttpAccept.Json)
                              .Build();

                request.Method = (HttpMethod)settings.Method;
                request.Headers.ContentType = "application/json";
                request.SetContent(body.ToJson());

                if (!String.IsNullOrEmpty(settings.Username) || !String.IsNullOrEmpty(settings.Password))
                {
                    var authInfo = settings.Username + ":" + settings.Password;
                    authInfo = Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(authInfo));
                    request.Headers.Set("Authorization", "Basic " + authInfo);
                }

                _httpClient.Execute(request);
            }
            catch (RestException ex)
            {
                throw new WebhookException("Unable to post to webhook: {0}", ex, ex.Message);
            }
        }
Esempio n. 3
0
        public override void OnTrackRetag(TrackRetagMessage message)
        {
            var payload = new WebhookPayload
            {
                EventType = "Retag",
                Artist    = new WebhookArtist(message.Artist)
            };

            _proxy.SendWebhook(payload, Settings);
        }
Esempio n. 4
0
        public override void OnRename(Artist artist)
        {
            var payload = new WebhookPayload
            {
                EventType = "Rename",
                Artist    = new WebhookArtist(artist)
            };

            _proxy.SendWebhook(payload, Settings);
        }
Esempio n. 5
0
        public override void OnMovieRename(Movie movie)
        {
            var payload = new WebhookPayload
            {
                EventType = "Rename",
                Movie     = new WebhookMovie(movie)
            };

            _proxy.SendWebhook(payload, Settings);
        }
Esempio n. 6
0
        public void OnRename(Series series, WebhookSettings settings)
        {
            var payload = new WebhookPayload
            {
                EventType = "Rename",
                Series = new WebhookSeries(series)
            };

            NotifyWebhook(payload, settings);
        }
Esempio n. 7
0
        public override void OnRename(Series series)
        {
            var payload = new WebhookPayload
            {
                EventType = "Rename",
                Series    = new WebhookSeries(series)
            };

            _proxy.SendWebhook(payload, Settings);
        }
Esempio n. 8
0
        public void OnRename(Movie movie, WebhookSettings settings)
        {
            var payload = new WebhookPayload
            {
                EventType = "Rename",
                Movie     = new WebhookMovie(movie)
            };

            NotifyWebhook(payload, settings);
        }
Esempio n. 9
0
        public override void OnBookRetag(BookRetagMessage message)
        {
            var payload = new WebhookPayload
            {
                EventType = "Retag",
                Author    = new WebhookAuthor(message.Author)
            };

            _proxy.SendWebhook(payload, Settings);
        }
Esempio n. 10
0
        public void OnRename(Series series, WebhookSettings settings)
        {
            var payload = new WebhookPayload
            {
                EventType = "Rename",
                Series    = new WebhookSeries(series)
            };

            NotifyWebhook(payload, settings);
        }
Esempio n. 11
0
        public override void OnRename(Author author)
        {
            var payload = new WebhookPayload
            {
                EventType = "Rename",
                Author    = new WebhookAuthor(author)
            };

            _proxy.SendWebhook(payload, Settings);
        }
Esempio n. 12
0
        public void OnGrab(Movie movie, RemoteMovie remoteMovie, QualityModel quality, WebhookSettings settings)
        {
            var payload = new WebhookPayload
            {
                EventType   = "Grab",
                Movie       = new WebhookMovie(movie),
                RemoteMovie = new WebhookRemoteMovie(remoteMovie)
            };

            NotifyWebhook(payload, settings);
        }
Esempio n. 13
0
        public void OnDownload(Movie movie, MovieFile movieFile, WebhookSettings settings)
        {
            var payload = new WebhookPayload
            {
                EventType   = "Download",
                Movie       = new WebhookMovie(movie, movieFile),
                RemoteMovie = new WebhookRemoteMovie(movie)
            };

            NotifyWebhook(payload, settings);
        }
Esempio n. 14
0
 public void NotifyWebhook(WebhookPayload body, WebhookSettings settings)
 {
     try {
         var client  = RestClientFactory.BuildClient(settings.Url);
         var request = new RestRequest((Method)settings.Method);
         request.RequestFormat = DataFormat.Json;
         request.AddBody(body);
         client.ExecuteAndValidate(request);
     }
     catch (RestException ex)
     {
         throw new WebhookException("Unable to post to webhook: {0}", ex, ex.Message);
     }
 }
Esempio n. 15
0
 public void NotifyWebhook(WebhookPayload body, WebhookSettings settings)
 {
     try {
         var client = RestClientFactory.BuildClient(settings.Url);
         var request = new RestRequest((Method) settings.Method);
         request.RequestFormat = DataFormat.Json;
         request.AddBody(body);
         client.ExecuteAndValidate(request);
     }
     catch (RestException ex)
     {
         throw new WebhookException("Unable to post to webhook: {0}", ex, ex.Message);
     }
 }
Esempio n. 16
0
 public void OnGrab(Series series, RemoteEpisode episode, QualityModel quality, WebhookSettings settings)
 {
     var payload = new WebhookPayload
     {
         EventType = "Grab",
         Series = new WebhookSeries(series),
         Episodes = episode.Episodes.ConvertAll(x => new WebhookEpisode(x)
         {
             Quality = quality.Quality.Name,
             QualityVersion = quality.Revision.Version,
             ReleaseGroup = episode.ParsedEpisodeInfo.ReleaseGroup
         })
     };
     NotifyWebhook(payload, settings);
 }
Esempio n. 17
0
        public void OnGrab(Series series, RemoteEpisode episode, QualityModel quality, WebhookSettings settings)
        {
            var payload = new WebhookPayload
            {
                EventType = "Grab",
                Series    = new WebhookSeries(series),
                Episodes  = episode.Episodes.ConvertAll(x => new WebhookEpisode(x)
                {
                    Quality        = quality.Quality.Name,
                    QualityVersion = quality.Revision.Version,
                    ReleaseGroup   = episode.ParsedEpisodeInfo.ReleaseGroup
                })
            };

            NotifyWebhook(payload, settings);
        }
Esempio n. 18
0
        public void OnDownload(Series series, EpisodeFile episodeFile, WebhookSettings settings)
        {
            var payload = new WebhookPayload
            {
                EventType = "Download",
                Series = new WebhookSeries(series),
                Episodes = episodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x) {
                    Quality = episodeFile.Quality.Quality.Name,
                    QualityVersion = episodeFile.Quality.Revision.Version,
                    ReleaseGroup = episodeFile.ReleaseGroup,
                    SceneName = episodeFile.SceneName
                })
            };

            NotifyWebhook(payload, settings);
        }
Esempio n. 19
0
        public void OnDownload(Series series, EpisodeFile episodeFile, WebhookSettings settings)
        {
            var payload = new WebhookPayload
            {
                EventType = "Download",
                Series    = new WebhookSeries(series),
                Episodes  = episodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x)
                {
                    Quality        = episodeFile.Quality.Quality.Name,
                    QualityVersion = episodeFile.Quality.Revision.Version,
                    ReleaseGroup   = episodeFile.ReleaseGroup,
                    SceneName      = episodeFile.SceneName
                })
            };

            NotifyWebhook(payload, settings);
        }
Esempio n. 20
0
        public void SendWebhook(WebhookPayload body, WebhookSettings settings)
        {
            try
            {
                var request = new HttpRequestBuilder(settings.Url)
                              .Accept(HttpAccept.Json)
                              .Build();

                request.Method = (HttpMethod)settings.Method;
                request.Headers.ContentType = "application/json";
                request.SetContent(body.ToJson());

                _httpClient.Execute(request);
            }
            catch (RestException ex)
            {
                throw new WebhookException("Unable to post to webhook: {0}", ex, ex.Message);
            }
        }
Esempio n. 21
0
        public void SendWebhook(WebhookPayload body, WebhookSettings settings)
        {
            try
            {
                var request = new HttpRequestBuilder(settings.Url)
                              .Accept(HttpAccept.Json)
                              .Build();

                request.Method = (HttpMethod)settings.Method;
                request.Headers.ContentType = "application/json";
                request.SetContent(body.ToJson());

                if (settings.Username.IsNotNullOrWhiteSpace() || settings.Password.IsNotNullOrWhiteSpace())
                {
                    request.AddBasicAuthentication(settings.Username, settings.Password);
                }
                _httpClient.Execute(request);
            }
            catch (HttpException ex)
            {
                throw new WebhookException("Unable to post to webhook: {0}", ex, ex.Message);
            }
        }