Class: Io::Flow::V0::Models::OnlineAuthorization

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

Instance Attribute Summary collapse

Attributes inherited from Authorization

#discriminator

Instance Method Summary collapse

Methods inherited from Authorization

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ OnlineAuthorization

Returns a new instance of OnlineAuthorization.



19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19887

def initialize(incoming={})
  super(:discriminator => Authorization::Types::ONLINE_AUTHORIZATION)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :key, :payment, :amount, :currency, :customer, :attributes, :result, :created_at], 'OnlineAuthorization')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @payment = (x = opts.delete(:payment); x.is_a?(::Io::Flow::V0::Models::ExpandablePayment) ? x : ::Io::Flow::V0::Models::ExpandablePayment.from_json(x))
  @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.is_a?(::Io::Flow::V0::Models::Customer) ? x : ::Io::Flow::V0::Models::Customer.new(x))
  @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), 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)))
  @order = (x = opts.delete(:order); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::AuthorizationOrderReference) ? x : ::Io::Flow::V0::Models::AuthorizationOrderReference.new(x)))
  @ip = (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String))
  @result = (x = opts.delete(:result); x.is_a?(::Io::Flow::V0::Models::AuthorizationResult) ? x : ::Io::Flow::V0::Models::AuthorizationResult.new(x))
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



19885
19886
19887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19885

def amount
  @amount
end

#attributesObject (readonly)

Returns the value of attribute attributes.



19885
19886
19887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19885

def attributes
  @attributes
end

#created_atObject (readonly)

Returns the value of attribute created_at.



19885
19886
19887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19885

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



19885
19886
19887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19885

def currency
  @currency
end

#customerObject (readonly)

Returns the value of attribute customer.



19885
19886
19887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19885

def customer
  @customer
end

#destinationObject (readonly)

Returns the value of attribute destination.



19885
19886
19887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19885

def destination
  @destination
end

#idObject (readonly)

Returns the value of attribute id.



19885
19886
19887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19885

def id
  @id
end

#ipObject (readonly)

Returns the value of attribute ip.



19885
19886
19887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19885

def ip
  @ip
end

#keyObject (readonly)

Returns the value of attribute key.



19885
19886
19887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19885

def key
  @key
end

#orderObject (readonly)

Returns the value of attribute order.



19885
19886
19887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19885

def order
  @order
end

#paymentObject (readonly)

Returns the value of attribute payment.



19885
19886
19887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19885

def payment
  @payment
end

#resultObject (readonly)

Returns the value of attribute result.



19885
19886
19887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19885

def result
  @result
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



19909
19910
19911
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19909

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

#subtype_to_hashObject



19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19913

def subtype_to_hash
  {
    :id => id,
    :key => key,
    :payment => payment.to_hash,
    :amount => amount,
    :currency => currency,
    :customer => customer.to_hash,
    :attributes => attributes,
    :destination => destination.nil? ? nil : destination.to_hash,
    :order => order.nil? ? nil : order.to_hash,
    :ip => ip,
    :result => result.to_hash,
    :created_at => created_at
  }
end

#to_jsonObject



19905
19906
19907
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19905

def to_json
  JSON.dump(to_hash)
end