Class: Io::Flow::V0::Models::PaymentMethodCard

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

Returns a new instance of PaymentMethodCard.



12381
12382
12383
12384
12385
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12381

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

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



12379
12380
12381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12379

def type
  @type
end

Class Method Details

.from_json(hash) ⇒ Object



12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12395

def PaymentMethodCard.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_card] requires a field named 'type'"
  end
  case discriminator
    when Types::PAYMENT_METHOD_CARD_PCI_DETAILS; PaymentMethodCardPciDetails.new(hash)
    when Types::PAYMENT_METHOD_CARD_TOKEN; PaymentMethodCardToken.new(hash)
    else PaymentMethodCardUndefinedType.new(:type => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



12387
12388
12389
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12387

def subtype_to_hash
  raise 'Cannot serialize an instance of payment_method_card directly - must use one of the specific types: payment_method_card_pci_details, payment_method_card_token'
end

#to_hashObject



12391
12392
12393
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12391

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