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.



12923
12924
12925
12926
12927
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12923

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.



12921
12922
12923
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12921

def type
  @type
end

Class Method Details

.from_json(hash) ⇒ Object



12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12937

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



12929
12930
12931
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12929

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



12933
12934
12935
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12933

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