Class: Io::Flow::V0::Models::CardAuthorizationForm

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

Overview

Similar to a merchant of record authorization form, but it allows card information to be included rather than tokenizing first. If the amount is $0, then

Instance Attribute Summary collapse

Attributes inherited from AuthorizationForm

#discriminator

Instance Method Summary collapse

Methods inherited from AuthorizationForm

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ CardAuthorizationForm

Returns a new instance of CardAuthorizationForm.



19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19462

def initialize(incoming={})
  super(:discriminator => AuthorizationForm::Types::CARD_AUTHORIZATION_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:card], 'CardAuthorizationForm')
  @card = (x = opts.delete(:card); x.is_a?(::Io::Flow::V0::Models::CardAuthorizationData) ? x : ::Io::Flow::V0::Models::CardAuthorizationData.from_json(x))
  @order_number = (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', x, String))
  @amount = (x = opts.delete(:amount); x.nil? ? nil : HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(x), BigDecimal))
  @currency = (x = opts.delete(:currency); x.nil? ? nil : HttpClient::Preconditions.assert_class('currency', x, String))
  @key = (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, String))
  @cvv = (x = opts.delete(:cvv); x.nil? ? nil : HttpClient::Preconditions.assert_class('cvv', x, String))
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
  @ip = (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String))
  @options = (x = opts.delete(:options); x.nil? ? nil : HttpClient::Preconditions.assert_class('options', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::AuthorizationOption) ? x : ::Io::Flow::V0::Models::AuthorizationOption.apply(x)) })
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



19460
19461
19462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19460

def amount
  @amount
end

#attributesObject (readonly)

Returns the value of attribute attributes.



19460
19461
19462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19460

def attributes
  @attributes
end

#cardObject (readonly)

Returns the value of attribute card.



19460
19461
19462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19460

def card
  @card
end

#currencyObject (readonly)

Returns the value of attribute currency.



19460
19461
19462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19460

def currency
  @currency
end

#cvvObject (readonly)

Returns the value of attribute cvv.



19460
19461
19462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19460

def cvv
  @cvv
end

#ipObject (readonly)

Returns the value of attribute ip.



19460
19461
19462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19460

def ip
  @ip
end

#keyObject (readonly)

Returns the value of attribute key.



19460
19461
19462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19460

def key
  @key
end

#optionsObject (readonly)

Returns the value of attribute options.



19460
19461
19462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19460

def options
  @options
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



19460
19461
19462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19460

def order_number
  @order_number
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



19481
19482
19483
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19481

def copy(incoming={})
  CardAuthorizationForm.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#subtype_to_hashObject



19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19485

def subtype_to_hash
  {
    :card => card.to_hash,
    :order_number => order_number,
    :amount => amount,
    :currency => currency,
    :key => key,
    :cvv => cvv,
    :attributes => attributes.nil? ? nil : attributes,
    :ip => ip,
    :options => options.nil? ? nil : options.map { |o| o.value }
  }
end

#to_jsonObject



19477
19478
19479
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19477

def to_json
  JSON.dump(to_hash)
end