2020-02-14 17:49:17 +00:00
|
|
|
class Webhooks::Trigger
|
|
|
|
def self.execute(url, payload)
|
2021-10-28 09:56:20 +00:00
|
|
|
response = RestClient::Request.execute(
|
2021-03-31 11:09:57 +00:00
|
|
|
method: :post,
|
|
|
|
url: url, payload: payload.to_json,
|
|
|
|
headers: { content_type: :json, accept: :json },
|
|
|
|
timeout: 5
|
|
|
|
)
|
2021-10-28 09:56:20 +00:00
|
|
|
Rails.logger.info "Performed Request: Code - #{response.code}"
|
2022-05-06 09:20:55 +00:00
|
|
|
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS, URI::InvalidURIError => e
|
2021-10-28 09:56:20 +00:00
|
|
|
Rails.logger.error "Exception: invalid webhook url #{url} : #{e.message}"
|
2020-02-14 17:49:17 +00:00
|
|
|
rescue StandardError => e
|
2021-10-28 09:56:20 +00:00
|
|
|
Rails.logger.error "Exception: invalid webhook url #{url} : #{e.message}"
|
2022-05-09 08:53:19 +00:00
|
|
|
ChatwootExceptionTracker.new(e).capture_exception
|
2020-02-14 17:49:17 +00:00
|
|
|
end
|
|
|
|
end
|