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) ⇒ Object
Unmarshals the given body, while also validating it using the given request headers.
-
#validate(body, request_headers) ⇒ Object
Validates incoming request using request headers.
Constructor Details
#initialize(marshaller, secret_key_store) ⇒ WebhooksHelper
Returns a new instance of WebhooksHelper.
9 10 11 12 13 14 |
# File 'lib/onlinepayments/sdk/webhooks/webhooks_helper.rb', line 9 def initialize(marshaller, secret_key_store) raise ArgumentError unless marshaller raise ArgumentError unless secret_key_store @marshaller = marshaller @secret_key_store = secret_key_store end |
Instance Method Details
#unmarshal(body, request_headers) ⇒ Object
Unmarshals the given body, while also validating it using the given request headers.
20 21 22 23 24 25 |
# File 'lib/onlinepayments/sdk/webhooks/webhooks_helper.rb', line 20 def unmarshal(body, request_headers) validate(body, request_headers) event = @marshaller.unmarshal(body, WebhooksEvent) validate_api_version(event) event end |
#validate(body, request_headers) ⇒ Object
Validates incoming request using request headers
31 32 33 |
# File 'lib/onlinepayments/sdk/webhooks/webhooks_helper.rb', line 31 def validate(body, request_headers) validate_body(body, request_headers) end |