Class: OnlinePayments::SDK::Webhooks::WebhooksHelper
- Inherits:
-
Object
- Object
- OnlinePayments::SDK::Webhooks::WebhooksHelper
- Defined in:
- lib/onlinepayments/sdk/webhooks/webhooks_helper.rb
Overview
Online Payments platform webhooks Helper, Thread-safe.
Instance Method Summary collapse
-
#initialize(marshaller, secret_key_store) ⇒ WebhooksHelper
constructor
A new instance of WebhooksHelper.
-
#unmarshal(body, request_headers) ⇒ OnlinePayments::SDK::Webhooks::WebhooksEvent
Unmarshals the given body, while also validating it using the given request headers.
Constructor Details
#initialize(marshaller, secret_key_store) ⇒ WebhooksHelper
Returns a new instance of WebhooksHelper.
10 11 12 13 14 |
# File 'lib/onlinepayments/sdk/webhooks/webhooks_helper.rb', line 10 def initialize(marshaller, secret_key_store) raise ArgumentError if marshaller.nil? @marshaller = marshaller @signature_validator = OnlinePayments::SDK::Webhooks::SignatureValidator.new(secret_key_store) end |
Instance Method Details
#unmarshal(body, request_headers) ⇒ OnlinePayments::SDK::Webhooks::WebhooksEvent
Unmarshals the given body, while also validating it using the given request headers.
21 22 23 24 25 26 27 |
# File 'lib/onlinepayments/sdk/webhooks/webhooks_helper.rb', line 21 def unmarshal(body, request_headers) @signature_validator.validate(body, request_headers) event = @marshaller.unmarshal(body, OnlinePayments::SDK::Webhooks::WebhooksEvent) validate_api_version(event) event end |