Class: Ingenico::Connect::SDK::Webhooks::WebhooksHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/ingenico/connect/sdk/webhooks/webhooks_helper.rb

Overview

Ingenico ePayments platform webhooks Helper, Thread-safe.

Instance Method Summary collapse

Constructor Details

#initialize(marshaller, secret_key_store) ⇒ WebhooksHelper

Returns a new instance of WebhooksHelper.

Raises:

  • (ArgumentError)


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.

Parameters:



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

Parameters:



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