Class: Io::Flow::V0::Models::DirectAuthorizationForm

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

Overview

Creates an authorization for a transaction in which you remain the merchant of record. An authorization is used to check and reserve funds w/ a given payment method. No funds are actually transferred; once you have you an authorization, you can capture up to the amount of the authorization.

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

Returns a new instance of DirectAuthorizationForm.



26700
26701
26702
26703
26704
26705
26706
26707
26708
26709
26710
26711
26712
26713
26714
26715
26716
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26700

def initialize(incoming={})
  super(:discriminator => AuthorizationForm::Types::DIRECT_AUTHORIZATION_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:token, :amount, :currency], 'DirectAuthorizationForm')
  @token = HttpClient::Preconditions.assert_class('token', opts.delete(:token), String)
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @customer = (x = opts.delete(:customer); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderCustomer) ? x : ::Io::Flow::V0::Models::OrderCustomer.new(x)))
  @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 })
  @destination = (x = opts.delete(:destination); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x)))
  @billing_address = (x = opts.delete(:billing_address); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::BillingAddress) ? x : ::Io::Flow::V0::Models::BillingAddress.new(x)))
  @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)) })
  @redirect_urls = (x = opts.delete(:redirect_urls); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PostPaymentRedirectUrls) ? x : ::Io::Flow::V0::Models::PostPaymentRedirectUrls.new(x)))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

def amount
  @amount
end

#attributesObject (readonly)

Returns the value of attribute attributes.



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

def attributes
  @attributes
end

#billing_addressObject (readonly)

Returns the value of attribute billing_address.



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

def billing_address
  @billing_address
end

#currencyObject (readonly)

Returns the value of attribute currency.



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

def currency
  @currency
end

#customerObject (readonly)

Returns the value of attribute customer.



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

def customer
  @customer
end

#cvvObject (readonly)

Returns the value of attribute cvv.



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

def cvv
  @cvv
end

#destinationObject (readonly)

Returns the value of attribute destination.



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

def destination
  @destination
end

#ipObject (readonly)

Returns the value of attribute ip.



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

def ip
  @ip
end

#keyObject (readonly)

Returns the value of attribute key.



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

def key
  @key
end

#optionsObject (readonly)

Returns the value of attribute options.



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

def options
  @options
end

#redirect_urlsObject (readonly)

Returns the value of attribute redirect_urls.



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

def redirect_urls
  @redirect_urls
end

#tokenObject (readonly)

Returns the value of attribute token.



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

def token
  @token
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26722
26723
26724
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26722

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

#subtype_to_hashObject



26726
26727
26728
26729
26730
26731
26732
26733
26734
26735
26736
26737
26738
26739
26740
26741
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26726

def subtype_to_hash
  {
    :token => token,
    :amount => amount.to_f.to_s,
    :currency => currency,
    :customer => customer.nil? ? nil : customer.to_hash,
    :key => key,
    :cvv => cvv,
    :attributes => attributes.nil? ? nil : attributes,
    :destination => destination.nil? ? nil : destination.to_hash,
    :billing_address => billing_address.nil? ? nil : billing_address.to_hash,
    :ip => ip,
    :options => options.nil? ? nil : options.map { |o| o.value },
    :redirect_urls => redirect_urls.nil? ? nil : redirect_urls.to_hash
  }
end

#to_jsonObject



26718
26719
26720
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26718

def to_json
  JSON.dump(to_hash)
end