class Io::Flow::V0::Models::CreditMemo
The credit memo represents the details of a refund and the reasons for the issuance of the refund.
Attributes
attributes[R]
date[R]
documents[R]
entity[R]
id[R]
invoice[R]
key[R]
lines[R]
number[R]
payments[R]
status[R]
tax_registration[R]
Public Class Methods
new(incoming={})
click to toggle source
# 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
Public Instance Methods
copy(incoming={})
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 37417 def to_json JSON.dump(to_hash) end