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

#to_hash

Constructor Details

#initialize(incoming = {}) ⇒ DirectAuthorizationForm

Returns a new instance of DirectAuthorizationForm.



11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11919

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::Customer) ? x : ::Io::Flow::V0::Models::Customer.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)))
  @ip = (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String))
end

Instance Attribute Details

#amount ⇒ Object (readonly)

Returns the value of attribute amount.



11917
11918
11919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11917

def amount
  @amount
end

#attributes ⇒ Object (readonly)

Returns the value of attribute attributes.



11917
11918
11919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11917

def attributes
  @attributes
end

#currency ⇒ Object (readonly)

Returns the value of attribute currency.



11917
11918
11919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11917

def currency
  @currency
end

#customer ⇒ Object (readonly)

Returns the value of attribute customer.



11917
11918
11919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11917

def customer
  @customer
end

#cvv ⇒ Object (readonly)

Returns the value of attribute cvv.



11917
11918
11919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11917

def cvv
  @cvv
end

#destination ⇒ Object (readonly)

Returns the value of attribute destination.



11917
11918
11919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11917

def destination
  @destination
end

#ip ⇒ Object (readonly)

Returns the value of attribute ip.



11917
11918
11919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11917

def ip
  @ip
end

#key ⇒ Object (readonly)

Returns the value of attribute key.



11917
11918
11919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11917

def key
  @key
end

#token ⇒ Object (readonly)

Returns the value of attribute token.



11917
11918
11919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11917

def token
  @token
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



11938
11939
11940
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11938

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

#subtype_to_hash ⇒ Object



11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11942

def subtype_to_hash
  {
    :token => token,
    :amount => amount,
    :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,
    :ip => ip
  }
end

#to_json ⇒ Object



11934
11935
11936
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11934

def to_json
  JSON.dump(to_hash)
end