Class: Ingenico::Direct::SDK::Webhooks::WebhooksHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/ingenico/direct/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)


9
10
11
12
13
14
# File 'lib/ingenico/direct/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.

Parameters:



20
21
22
23
24
25
# File 'lib/ingenico/direct/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

Parameters:



31
32
33
# File 'lib/ingenico/direct/sdk/webhooks/webhooks_helper.rb', line 31

def validate(body, request_headers)
  validate_body(body, request_headers)
end