Class: Io::Flow::V0::Models::PaymentMethodData

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 = {}) ⇒ PaymentMethodData

Returns a new instance of PaymentMethodData.



13762
13763
13764
13765
13766
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13762

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:type], 'PaymentMethodData')
  @type = HttpClient::Preconditions.assert_class('type', opts.delete(:type), String)
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



13760
13761
13762
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13760

def type
  @type
end

Class Method Details

.from_json(hash) ⇒ Object



13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13776

def PaymentMethodData.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[payment_method_data] requires a field named 'type'"
  end
  case discriminator
    when Types::PAYMENT_METHOD_DATA_INIT_KLARNA; PaymentMethodDataInitKlarna.new(hash)
    when Types::PAYMENT_METHOD_DATA_INIT_AFTERPAY; PaymentMethodDataInitAfterpay.new(hash)
    when Types::PAYMENT_METHOD_DATA_INIT_APPLEPAY; PaymentMethodDataInitApplepay.new(hash)
    when Types::PAYMENT_METHOD_DATA_INIT_GOOGLEPAY; PaymentMethodDataInitGooglepay.new(hash)
    when Types::PAYMENT_METHOD_DATA_INIT_PAYPAL; PaymentMethodDataInitPaypal.new(hash)
    when Types::PAYMENT_METHOD_DATA_INIT_IDEAL; PaymentMethodDataInitIdeal.new(hash)
    when Types::PAYMENT_METHOD_DATA_INIT_SOFORT; PaymentMethodDataInitSofort.new(hash)
    when Types::PAYMENT_METHOD_DATA_INIT_BANCONTACT; PaymentMethodDataInitBancontact.new(hash)
    when Types::PAYMENT_METHOD_DATA_VALIDATE_APPLEPAY; PaymentMethodDataValidateApplepay.new(hash)
    when Types::PAYMENT_METHOD_DATA_AUTHORIZE_CARD; PaymentMethodDataAuthorizeCard.new(hash)
    when Types::PAYMENT_METHOD_DATA_AUTHORIZE_GOOGLEPAY; PaymentMethodDataAuthorizeGooglepay.new(hash)
    when Types::PAYMENT_METHOD_DATA_AUTHORIZE_APPLEPAY; PaymentMethodDataAuthorizeApplepay.new(hash)
    when Types::PAYMENT_METHOD_DATA_AUTHORIZE_PAYPAL; PaymentMethodDataAuthorizePaypal.new(hash)
    when Types::PAYMENT_METHOD_DATA_AUTHORIZE_KLARNA; PaymentMethodDataAuthorizeKlarna.new(hash)
    when Types::PAYMENT_METHOD_DATA_SELECTED_PAYMENT_OPTION; PaymentMethodDataSelectedPaymentOption.new(hash)
    when Types::PAYMENT_METHOD_DATA_COMPLETE_AUTHORIZATION_CARD; PaymentMethodDataCompleteAuthorizationCard.new(hash)
    else PaymentMethodDataUndefinedType.new(:type => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



13768
13769
13770
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13768

def subtype_to_hash
  raise 'Cannot serialize an instance of payment_method_data directly - must use one of the specific types: payment_method_data_init_klarna, payment_method_data_init_afterpay, payment_method_data_init_applepay, payment_method_data_init_googlepay, payment_method_data_init_paypal, payment_method_data_init_ideal, payment_method_data_init_sofort, payment_method_data_init_bancontact, payment_method_data_validate_applepay, payment_method_data_authorize_card, payment_method_data_authorize_googlepay, payment_method_data_authorize_applepay, payment_method_data_authorize_paypal, payment_method_data_authorize_klarna, payment_method_data_selected_payment_option, payment_method_data_complete_authorization_card'
end

#to_hashObject



13772
13773
13774
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13772

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