Class: Io::Flow::V0::Models::CreditPayment
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::CreditPayment
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
A Credit Payment records a ‘non cash’ payment against an order (e.g. a store credit, gift card, etc.), recording the amount of that credit and additional details to reconcile payments. The primary purpose of the credit payment is to record that a payment has been made against an order so the remaining balance can be correctly computed.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#original ⇒ Object
readonly
Returns the value of attribute original.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ CreditPayment
constructor
A new instance of CreditPayment.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ CreditPayment
Returns a new instance of CreditPayment.
28277 28278 28279 28280 28281 28282 28283 28284 28285 28286 28287 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28277 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :order, :key, :description, :value, :original, :attributes], 'CreditPayment') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @order = (x = opts.delete(:order); x.is_a?(::Io::Flow::V0::Models::ExpandableOrder) ? x : ::Io::Flow::V0::Models::ExpandableOrder.from_json(x)) @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String) @description = HttpClient::Preconditions.assert_class('description', opts.delete(:description), String) @value = (x = opts.delete(:value); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)) @original = (x = opts.delete(:original); x.is_a?(::Io::Flow::V0::Models::OriginalPrices) ? x : ::Io::Flow::V0::Models::OriginalPrices.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 } end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
28275 28276 28277 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28275 def attributes @attributes end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
28275 28276 28277 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28275 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28275 28276 28277 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28275 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
28275 28276 28277 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28275 def key @key end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
28275 28276 28277 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28275 def order @order end |
#original ⇒ Object (readonly)
Returns the value of attribute original.
28275 28276 28277 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28275 def original @original end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
28275 28276 28277 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28275 def value @value end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
28293 28294 28295 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28293 def copy(incoming={}) CreditPayment.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
28297 28298 28299 28300 28301 28302 28303 28304 28305 28306 28307 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28297 def to_hash { :id => id, :order => order.to_hash, :key => key, :description => description, :value => value.to_hash, :original => original.to_hash, :attributes => attributes } end |
#to_json ⇒ Object
28289 28290 28291 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28289 def to_json JSON.dump(to_hash) end |