change open/read timeout for webhook requests

This commit is contained in:
Alex Turchyn
2025-01-22 20:58:47 +02:00
committed by GitHub
parent d52c57df72
commit 4dc325a6bb
10 changed files with 44 additions and 135 deletions
+26
View File
@@ -0,0 +1,26 @@
# frozen_string_literal: true
module SendWebhookRequest
USER_AGENT = 'DocuSeal.com Webhook'
module_function
def call(webhook_url, event_type:, data:)
Faraday.post(webhook_url.url) do |req|
req.headers['Content-Type'] = 'application/json'
req.headers['User-Agent'] = USER_AGENT
req.headers.merge!(webhook_url.secret.to_h) if webhook_url.secret.present?
req.body = {
event_type: event_type,
timestamp: Time.current,
data: data
}.to_json
req.options.read_timeout = 8
req.options.open_timeout = 8
end
rescue Faraday::Error
nil
end
end