Class: Io::Flow::V0::Models::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Action

Returns a new instance of Action.



8844
8845
8846
8847
8848
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8844

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

#typeObject (readonly)

Returns the value of attribute type.



8842
8843
8844
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8842

def type
  @type
end

Class Method Details

.from_json(hash) ⇒ Object



8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8858

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_hashObject



8850
8851
8852
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8850

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_hashObject



8854
8855
8856
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8854

def to_hash
  subtype_to_hash.merge(:type => @type)
end