Class: Io::Flow::V0::Models::PaymentForm

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

Overview

Represents the data needed to initiate an online payment

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PaymentForm

Returns a new instance of PaymentForm.



6695
6696
6697
6698
6699
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6695

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

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



6693
6694
6695
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6693

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6709

def PaymentForm.from_json(hash)
  HttpClient::Preconditions.assert_class('hash', hash, Hash)
  discriminator = HttpClient::Helper.symbolize_keys(hash)[:discriminator].to_s.strip
  if discriminator.empty?
    raise "Union type[payment_form] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::MERCHANT_OF_RECORD_PAYMENT_FORM; MerchantOfRecordPaymentForm.new(hash)
    else PaymentFormUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



6701
6702
6703
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6701

def subtype_to_hash
  raise 'Cannot serialize an instance of payment_form directly - must use one of the specific types: merchant_of_record_payment_form'
end

#to_hashObject



6705
6706
6707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6705

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