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.



20156
20157
20158
20159
20160
20161
20162
20163
20164
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20156

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))
  @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))
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



20154
20155
20156
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20154

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



20154
20155
20156
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20154

def id
  @id
end

#referenceObject (readonly)

Returns the value of attribute reference.



20154
20155
20156
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20154

def reference
  @reference
end

#totalObject (readonly)

Returns the value of attribute total.



20154
20155
20156
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20154

def total
  @total
end

#typeObject (readonly)

Returns the value of attribute type.



20154
20155
20156
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20154

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



20170
20171
20172
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20170

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

#to_hashObject



20174
20175
20176
20177
20178
20179
20180
20181
20182
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20174

def to_hash
  {
    :id => id,
    :type => type.value,
    :reference => reference,
    :description => description,
    :total => total.to_hash
  }
end

#to_jsonObject



20166
20167
20168
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20166

def to_json
  JSON.dump(to_hash)
end