Class: UnivapayClientSdk::TokenReplacedHandler
- Inherits:
-
Object
- Object
- UnivapayClientSdk::TokenReplacedHandler
- Includes:
- CoreLibrary
- Defined in:
- lib/univapay_client_sdk/events/webhooks/token_replaced_handler.rb
Overview
TokenReplacedHandler is responsible for verifying request signatures and parsing incoming tokenReplaced events into strongly typed objects.
Instance Method Summary collapse
-
#initialize ⇒ TokenReplacedHandler
constructor
Creates a new instance of the TokenReplacedHandler.
-
#parse_event(request) ⇒ Object
Parse the event.
Constructor Details
#initialize ⇒ TokenReplacedHandler
Creates a new instance of the TokenReplacedHandler.
12 |
# File 'lib/univapay_client_sdk/events/webhooks/token_replaced_handler.rb', line 12 def initialize; end |
Instance Method Details
#parse_event(request) ⇒ Object
Parse the event.
@return[TokenReplacedWebhookCallback, UnknownEvent] TokenReplacedWebhookCallback for successful parsing; UnknownEvent for unknown events.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/univapay_client_sdk/events/webhooks/token_replaced_handler.rb', line 21 def parse_event(request) return UnknownEvent.new(['Invalid request env.']) unless request.respond_to?(:env) && request.env.is_a?(Hash) raw_body = RackRequestHelper.read_raw_body(request) return UnknownEvent.new(['Invalid request body.']) if raw_body.nil? || raw_body.empty? # Deserialize payload begin union = UnionTypeLookUp.get(:TokenReplaced) raw = RackRequestHelper.read_raw_body(request) APIHelper.deserialize_union_type(union, raw, false, true) rescue StandardError => e UnknownEvent.new(['Deserialization failed.', e.]) end end |