Class: Revolut::WebhookEvent
- Defined in:
- lib/revolut/resources/webhook_event.rb
Class Method Summary collapse
-
.construct_from(request, signing_secret) ⇒ WebhookEvent
Constructs a new instance of the WebhookEvent class from a request object and a signing secret.
Methods inherited from Resource
coerce_with, create, delete, http_client, #initialize, list, retrieve, skip_coertion_for, #to_json, to_proc, update
Constructor Details
This class inherits a constructor from Revolut::Resource
Class Method Details
.construct_from(request, signing_secret) ⇒ WebhookEvent
Constructs a new instance of the WebhookEvent class from a request object and a signing secret.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/revolut/resources/webhook_event.rb', line 14 def self.construct_from(request, signing_secret) json = request.body.read = request.headers["Revolut-Request-Timestamp"] header_signatures = request.headers["Revolut-Signature"].split(",") payload_to_sign = "v1.#{}.#{json}" digest = OpenSSL::Digest.new("sha256") signature_digest = "v1=" + OpenSSL::HMAC.hexdigest(digest, signing_secret, payload_to_sign) if header_signatures.include? signature_digest new(JSON.parse(json)) else raise Revolut::SignatureVerificationError, "Signature verification failed" end end |