Class: UnivapayClientSdk::RefundHandler
- Inherits:
-
Object
- Object
- UnivapayClientSdk::RefundHandler
- Includes:
- CoreLibrary
- Defined in:
- lib/univapay_client_sdk/events/webhooks/refund_handler.rb
Overview
RefundHandler is responsible for verifying request signatures and parsing incoming refund events into strongly typed objects.
Instance Method Summary collapse
-
#initialize ⇒ RefundHandler
constructor
Creates a new instance of the RefundHandler.
-
#parse_event(request) ⇒ Object
Parse the event.
Constructor Details
#initialize ⇒ RefundHandler
Creates a new instance of the RefundHandler.
12 |
# File 'lib/univapay_client_sdk/events/webhooks/refund_handler.rb', line 12 def initialize; end |
Instance Method Details
#parse_event(request) ⇒ Object
Parse the event.
@return[RefundWebhookCallback, UnknownEvent] RefundWebhookCallback 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/refund_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(:Refund) raw = RackRequestHelper.read_raw_body(request) APIHelper.deserialize_union_type(union, raw, false, true) rescue StandardError => e UnknownEvent.new(['Deserialization failed.', e.]) end end |