Class: Io::Flow::V0::Models::CreditMemo
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::CreditMemo
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
The credit memo represents the details of a refund and the reasons for the issuance of the refund.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#documents ⇒ Object
readonly
Returns the value of attribute documents.
-
#entity ⇒ Object
readonly
Returns the value of attribute entity.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#invoice ⇒ Object
readonly
Returns the value of attribute invoice.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#payments ⇒ Object
readonly
Returns the value of attribute payments.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#tax_registration ⇒ Object
readonly
Returns the value of attribute tax_registration.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ CreditMemo
constructor
A new instance of CreditMemo.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ CreditMemo
Returns a new instance of CreditMemo.
28121 28122 28123 28124 28125 28126 28127 28128 28129 28130 28131 28132 28133 28134 28135 28136 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28121 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :status, :date, :key, :invoice, :entity, :payments, :lines, :documents, :attributes], 'CreditMemo') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @number = (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, String)) @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceStatus) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceStatus.apply(x)) @date = HttpClient::Preconditions.assert_class('date', HttpClient::Helper.to_date_time_iso8601(opts.delete(:date)), DateTime) @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String) @invoice = (x = opts.delete(:invoice); x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceReference) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceReference.new(x)) @entity = (x = opts.delete(:entity); x.is_a?(::Io::Flow::V0::Models::MerchantOfRecordEntity) ? x : ::Io::Flow::V0::Models::MerchantOfRecordEntity.new(x)) @payments = HttpClient::Preconditions.assert_class('payments', opts.delete(:payments), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoicePayment) ? x : ::Io::Flow::V0::Models::ConsumerInvoicePayment.new(x)) } @lines = HttpClient::Preconditions.assert_class('lines', opts.delete(:lines), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceLine) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceLine.from_json(x)) } @documents = HttpClient::Preconditions.assert_class('documents', opts.delete(:documents), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceDocument) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceDocument.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 } @tax_registration = (x = opts.delete(:tax_registration); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::TaxRegistration) ? x : ::Io::Flow::V0::Models::TaxRegistration.new(x))) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
28119 28120 28121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28119 def attributes @attributes end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
28119 28120 28121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28119 def date @date end |
#documents ⇒ Object (readonly)
Returns the value of attribute documents.
28119 28120 28121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28119 def documents @documents end |
#entity ⇒ Object (readonly)
Returns the value of attribute entity.
28119 28120 28121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28119 def entity @entity end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28119 28120 28121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28119 def id @id end |
#invoice ⇒ Object (readonly)
Returns the value of attribute invoice.
28119 28120 28121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28119 def invoice @invoice end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
28119 28120 28121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28119 def key @key end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
28119 28120 28121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28119 def lines @lines end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
28119 28120 28121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28119 def number @number end |
#payments ⇒ Object (readonly)
Returns the value of attribute payments.
28119 28120 28121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28119 def payments @payments end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
28119 28120 28121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28119 def status @status end |
#tax_registration ⇒ Object (readonly)
Returns the value of attribute tax_registration.
28119 28120 28121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28119 def tax_registration @tax_registration end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
28142 28143 28144 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28142 def copy(incoming={}) CreditMemo.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
28146 28147 28148 28149 28150 28151 28152 28153 28154 28155 28156 28157 28158 28159 28160 28161 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28146 def to_hash { :id => id, :number => number, :status => status.value, :date => date, :key => key, :invoice => invoice.to_hash, :entity => entity.to_hash, :payments => payments.map { |o| o.to_hash }, :lines => lines.map { |o| o.to_hash }, :documents => documents.map { |o| o.to_hash }, :attributes => attributes, :tax_registration => tax_registration.nil? ? nil : tax_registration.to_hash } end |
#to_json ⇒ Object
28138 28139 28140 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28138 def to_json JSON.dump(to_hash) end |