mirror of https://github.com/docusealco/docuseal
				
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							27 lines
						
					
					
						
							624 B
						
					
					
				
			
		
		
	
	
							27 lines
						
					
					
						
							624 B
						
					
					
				| # 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
 |