Class: Io::Flow::V0::Models::OrderPayment

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

Overview

An Order Payment represents an individual payment applied to an order. The type of the payment can be used to further lookup transaction level detail

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderPayment

Returns a new instance of OrderPayment.



32412
32413
32414
32415
32416
32417
32418
32419
32420
32421
32422
32423
32424
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32412

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :type, :reference, :description, :total], 'OrderPayment')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::OrderPaymentType) ? x : ::Io::Flow::V0::Models::OrderPaymentType.apply(x))
  @merchant_of_record = (x = (x = opts.delete(:merchant_of_record); x.nil? ? "flow" : x); x.is_a?(::Io::Flow::V0::Models::MerchantOfRecord) ? x : ::Io::Flow::V0::Models::MerchantOfRecord.apply(x))
  @reference = HttpClient::Preconditions.assert_class('reference', opts.delete(:reference), String)
  @description = HttpClient::Preconditions.assert_class('description', opts.delete(:description), String)
  @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @address = (x = opts.delete(:address); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::BillingAddress) ? x : ::Io::Flow::V0::Models::BillingAddress.new(x)))
  @date = (x = opts.delete(:date); x.nil? ? nil : HttpClient::Preconditions.assert_class('date', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? {} : x), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



32410
32411
32412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32410

def address
  @address
end

#attributesObject (readonly)

Returns the value of attribute attributes.



32410
32411
32412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32410

def attributes
  @attributes
end

#dateObject (readonly)

Returns the value of attribute date.



32410
32411
32412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32410

def date
  @date
end

#descriptionObject (readonly)

Returns the value of attribute description.



32410
32411
32412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32410

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



32410
32411
32412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32410

def id
  @id
end

#merchant_of_recordObject (readonly)

Returns the value of attribute merchant_of_record.



32410
32411
32412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32410

def merchant_of_record
  @merchant_of_record
end

#referenceObject (readonly)

Returns the value of attribute reference.



32410
32411
32412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32410

def reference
  @reference
end

#totalObject (readonly)

Returns the value of attribute total.



32410
32411
32412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32410

def total
  @total
end

#typeObject (readonly)

Returns the value of attribute type.



32410
32411
32412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32410

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



32430
32431
32432
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32430

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

#to_hashObject



32434
32435
32436
32437
32438
32439
32440
32441
32442
32443
32444
32445
32446
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32434

def to_hash
  {
    :id => id,
    :type => type.value,
    :merchant_of_record => merchant_of_record.value,
    :reference => reference,
    :description => description,
    :total => total.to_hash,
    :address => address.nil? ? nil : address.to_hash,
    :date => date,
    :attributes => attributes
  }
end

#to_jsonObject



32426
32427
32428
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32426

def to_json
  JSON.dump(to_hash)
end