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.
37400 37401 37402 37403 37404 37405 37406 37407 37408 37409 37410 37411 37412 37413 37414 37415 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37400 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.
37398 37399 37400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37398 def attributes @attributes end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
37398 37399 37400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37398 def date @date end |
#documents ⇒ Object (readonly)
Returns the value of attribute documents.
37398 37399 37400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37398 def documents @documents end |
#entity ⇒ Object (readonly)
Returns the value of attribute entity.
37398 37399 37400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37398 def entity @entity end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
37398 37399 37400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37398 def id @id end |
#invoice ⇒ Object (readonly)
Returns the value of attribute invoice.
37398 37399 37400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37398 def invoice @invoice end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
37398 37399 37400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37398 def key @key end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
37398 37399 37400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37398 def lines @lines end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
37398 37399 37400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37398 def number @number end |
#payments ⇒ Object (readonly)
Returns the value of attribute payments.
37398 37399 37400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37398 def payments @payments end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
37398 37399 37400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37398 def status @status end |
#tax_registration ⇒ Object (readonly)
Returns the value of attribute tax_registration.
37398 37399 37400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37398 def tax_registration @tax_registration end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
37421 37422 37423 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37421 def copy(incoming={}) CreditMemo.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
37425 37426 37427 37428 37429 37430 37431 37432 37433 37434 37435 37436 37437 37438 37439 37440 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37425 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
37417 37418 37419 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37417 def to_json JSON.dump(to_hash) end |