lib/onfido/resources/webhook.rb in onfido-0.15.1 vs lib/onfido/resources/webhook.rb in onfido-1.0.0
- old
+ new
@@ -1,20 +1,18 @@
module Onfido
class Webhook < Resource
- def create(payload)
- post(
- url: url_for('webhooks'),
- payload: payload
- )
+ def create(url:, **payload)
+ payload[:url] = url
+ post(path: 'webhooks', payload: payload)
end
def find(webhooks_id)
- get(url: url_for("webhooks/#{webhooks_id}"))
+ get(path: "webhooks/#{webhooks_id}")
end
- def all(page: 1, per_page: 20)
- get(url: url_for("webhooks?page=#{page}&per_page=#{per_page}"))
+ def all
+ get(path: 'webhooks')
end
# As well as being a normal resource, Onfido::Webhook also supports
# verifying the authenticity of a webhook by comparing the signature on the
# request to one computed from the body
@@ -27,10 +25,10 @@
computed_signature = generate_signature(request_body, token)
Rack::Utils.secure_compare(request_signature, computed_signature)
end
def self.generate_signature(request_body, token)
- OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), token, request_body)
+ OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, request_body)
end
private_class_method :generate_signature
end
end