Class: Ingenico::Connect::SDK::Webhooks::WebhooksHelper
- Inherits:
-
Object
- Object
- Ingenico::Connect::SDK::Webhooks::WebhooksHelper
- Defined in:
- lib/ingenico/connect/sdk/webhooks/webhooks_helper.rb
Overview
Ingenico ePayments 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.
13 14 15 16 17 |
# File 'lib/ingenico/connect/sdk/webhooks/webhooks_helper.rb', line 13 def initialize(marshaller, secret_key_store) raise ArgumentError if marshaller.nil? @marshaller = marshaller @signature_validator = SignatureValidator.new(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.
23 24 25 26 27 28 |
# File 'lib/ingenico/connect/sdk/webhooks/webhooks_helper.rb', line 23 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
34 35 36 |
# File 'lib/ingenico/connect/sdk/webhooks/webhooks_helper.rb', line 34 def validate(body, request_headers) @signature_validator.validate(body, request_headers) end |