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.



21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21275

def initialize(incoming={})
  super(:discriminator => Authorization::Types::ONLINE_AUTHORIZATION)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :key, :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)
  @method = (x = opts.delete(:method); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PaymentMethod) ? x : ::Io::Flow::V0::Models::PaymentMethod.new(x)))
  @details = (x = opts.delete(:details); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OnlineAuthorizationDetails) ? x : ::Io::Flow::V0::Models::OnlineAuthorizationDetails.from_json(x)))
  @payment = (x = opts.delete(:payment); x.nil? ? nil : HttpClient::Preconditions.assert_class('payment', HttpClient::Helper.to_object(x), Hash))
  @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)
  @requested = (x = opts.delete(:requested); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x)))
  @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)
  @expires_at = (x = opts.delete(:expires_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('expires_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def amount
  @amount
end

#attributesObject (readonly)

Returns the value of attribute attributes.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def attributes
  @attributes
end

#created_atObject (readonly)

Returns the value of attribute created_at.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def currency
  @currency
end

#customerObject (readonly)

Returns the value of attribute customer.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def customer
  @customer
end

#destinationObject (readonly)

Returns the value of attribute destination.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def destination
  @destination
end

#detailsObject (readonly)

Returns the value of attribute details.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def details
  @details
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def expires_at
  @expires_at
end

#idObject (readonly)

Returns the value of attribute id.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def id
  @id
end

#ipObject (readonly)

Returns the value of attribute ip.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def ip
  @ip
end

#keyObject (readonly)

Returns the value of attribute key.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def key
  @key
end

#methodObject (readonly)

Returns the value of attribute method.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def method
  @method
end

#orderObject (readonly)

Returns the value of attribute order.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def order
  @order
end

#paymentObject (readonly)

Returns the value of attribute payment.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def payment
  @payment
end

#requestedObject (readonly)

Returns the value of attribute requested.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def requested
  @requested
end

#resultObject (readonly)

Returns the value of attribute result.



21273
21274
21275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21273

def result
  @result
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21301
21302
21303
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21301

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

#subtype_to_hashObject



21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21305

def subtype_to_hash
  {
    :id => id,
    :key => key,
    :method => method.nil? ? nil : method.to_hash,
    :details => details.nil? ? nil : details.to_hash,
    :payment => payment,
    :amount => amount,
    :currency => currency,
    :requested => requested.nil? ? nil : requested.to_hash,
    :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,
    :expires_at => expires_at
  }
end

#to_jsonObject



21297
21298
21299
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21297

def to_json
  JSON.dump(to_hash)
end