Class: Onfido::Webhook
Constant Summary
Constants inherited
from Resource
Resource::REQUEST_TIMEOUT_HTTP_CODE, Resource::VALID_HTTP_METHODS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resource
#initialize
Class Method Details
.valid?(request_body, request_signature, token) ⇒ Boolean
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
23
24
25
26
27
28
29
30
31
|
# File 'lib/onfido/resources/webhook.rb', line 23
def self.valid?(request_body, request_signature, token)
if [request_body, request_signature, token].any?(&:nil?)
raise ArgumentError, "A request body, request signature and token " \
"must be provided"
end
computed_signature = generate_signature(request_body, token)
Rack::Utils.secure_compare(request_signature, computed_signature)
end
|
Instance Method Details
#all ⇒ Object
12
13
14
|
# File 'lib/onfido/resources/webhook.rb', line 12
def all
get(path: 'webhooks')
end
|
#create(url:, **payload) ⇒ Object
3
4
5
6
|
# File 'lib/onfido/resources/webhook.rb', line 3
def create(url:, **payload)
payload[:url] = url
post(path: 'webhooks', payload: payload)
end
|
#destroy(webhook_id) ⇒ Object
16
17
18
|
# File 'lib/onfido/resources/webhook.rb', line 16
def destroy(webhook_id)
delete(path: "webhooks/#{webhook_id}")
end
|
#find(webhooks_id) ⇒ Object
8
9
10
|
# File 'lib/onfido/resources/webhook.rb', line 8
def find(webhooks_id)
get(path: "webhooks/#{webhooks_id}")
end
|