11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/pdf_mage/workers/send_webhook.rb', line 11
def perform(file_url_or_path, callback_url, meta = nil)
LOGGER.info "Sending webhook to [#{callback_url}] for file [#{file_url_or_path}] and meta: #{meta.inspect}"
params = {
file: file_url_or_path,
meta: meta
}
data = params.to_json
= {
'content-type' => 'application/json',
'user-agent' => 'PdfMage/1.0'
}
['X-Pdf-Signature'] = OpenSSL::HMAC.hexdigest('sha256', CONFIG.api_secret, data) if CONFIG.api_secret
response = Typhoeus.post(callback_url, headers: , body: data, ssl_verifypeer: !CONFIG.env.development)
LOGGER.info "Received response with status [#{response.code}]: #{response.body}"
end
|