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.



25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25164

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))
  @address = (x = opts.delete(:address); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x)))
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



25162
25163
25164
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25162

def address
  @address
end

#descriptionObject (readonly)

Returns the value of attribute description.



25162
25163
25164
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25162

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



25162
25163
25164
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25162

def id
  @id
end

#referenceObject (readonly)

Returns the value of attribute reference.



25162
25163
25164
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25162

def reference
  @reference
end

#totalObject (readonly)

Returns the value of attribute total.



25162
25163
25164
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25162

def total
  @total
end

#typeObject (readonly)

Returns the value of attribute type.



25162
25163
25164
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25162

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



25179
25180
25181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25179

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

#to_hashObject



25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25183

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

#to_jsonObject



25175
25176
25177
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25175

def to_json
  JSON.dump(to_hash)
end