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
25
26
27
28
29
30
31
32
33
|
# File 'lib/onfido/resources/webhook.rb', line 25
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
14
15
16
|
# File 'lib/onfido/resources/webhook.rb', line 14
def all
get(path: 'webhooks')
end
|
#create(url:, **payload) ⇒ Object
5
6
7
8
|
# File 'lib/onfido/resources/webhook.rb', line 5
def create(url:, **payload)
payload[:url] = url
post(path: 'webhooks', payload: payload)
end
|
#destroy(webhook_id) ⇒ Object
18
19
20
|
# File 'lib/onfido/resources/webhook.rb', line 18
def destroy(webhook_id)
delete(path: "webhooks/#{webhook_id}")
end
|
#find(webhooks_id) ⇒ Object
10
11
12
|
# File 'lib/onfido/resources/webhook.rb', line 10
def find(webhooks_id)
get(path: "webhooks/#{webhooks_id}")
end
|