Class: Io::Flow::V0::Models::Action
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Action
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
ActionDisplayInlineWindow, ActionExecuteScript, ActionRedirect, ActionSelectPaymentOption, ActionUndefinedType, ActionUseSdkAdyenV3, ActionUseSdkAdyenV4, ActionUseSdkApplepayJsCompleteValidation, ActionUseSdkApplepayJsCreateSession, ActionUseSdkGooglepay, ActionUseSdkKlarnaV1, ActionUseSdkPaypal, ActionUseSdkStripeV3, ActionWait
Defined Under Namespace
Modules: Types
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ Action
constructor
A new instance of Action.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Action
Returns a new instance of Action.
9314 9315 9316 9317 9318 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9314 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:type], 'Action') @type = HttpClient::Preconditions.assert_class('type', opts.delete(:type), String) end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
9312 9313 9314 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9312 def type @type end |
Class Method Details
.from_json(hash) ⇒ Object
9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9328 def Action.from_json(hash) HttpClient::Preconditions.assert_class('hash', hash, Hash) discriminator = HttpClient::Helper.symbolize_keys(hash)[:type].to_s.strip if discriminator.empty? raise "Union type[action] requires a field named 'type'" end case discriminator when Types::ACTION_REDIRECT; ActionRedirect.new(hash) when Types::ACTION_USE_SDK_KLARNA_V1; ActionUseSdkKlarnaV1.new(hash) when Types::ACTION_USE_SDK_APPLEPAY_JS_CREATE_SESSION; ActionUseSdkApplepayJsCreateSession.new(hash) when Types::ACTION_USE_SDK_APPLEPAY_JS_COMPLETE_VALIDATION; ActionUseSdkApplepayJsCompleteValidation.new(hash) when Types::ACTION_USE_SDK_GOOGLEPAY; ActionUseSdkGooglepay.new(hash) when Types::ACTION_USE_SDK_PAYPAL; ActionUseSdkPaypal.new(hash) when Types::ACTION_USE_SDK_STRIPE_V3; ActionUseSdkStripeV3.new(hash) when Types::ACTION_USE_SDK_ADYEN_V3; ActionUseSdkAdyenV3.new(hash) when Types::ACTION_USE_SDK_ADYEN_V4; ActionUseSdkAdyenV4.new(hash) when Types::ACTION_SELECT_PAYMENT_OPTION; ActionSelectPaymentOption.new(hash) when Types::ACTION_EXECUTE_SCRIPT; ActionExecuteScript.new(hash) when Types::ACTION_DISPLAY_INLINE_WINDOW; ActionDisplayInlineWindow.new(hash) when Types::ACTION_WAIT; ActionWait.new(hash) else ActionUndefinedType.new(:type => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
9320 9321 9322 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9320 def subtype_to_hash raise 'Cannot serialize an instance of action directly - must use one of the specific types: action_redirect, action_use_sdk_klarna_v1, action_use_sdk_applepay_js_create_session, action_use_sdk_applepay_js_complete_validation, action_use_sdk_googlepay, action_use_sdk_paypal, action_use_sdk_stripe_v3, action_use_sdk_adyen_v3, action_use_sdk_adyen_v4, action_select_payment_option, action_execute_script, action_display_inline_window, action_wait' end |
#to_hash ⇒ Object
9324 9325 9326 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9324 def to_hash subtype_to_hash.merge(:type => @type) end |