Class: Io::Flow::V0::Models::CreditMemo

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ CreditMemo

Returns a new instance of CreditMemo.



21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21692

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)
  @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

#attributesObject (readonly)

Returns the value of attribute attributes.



21690
21691
21692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21690

def attributes
  @attributes
end

#dateObject (readonly)

Returns the value of attribute date.



21690
21691
21692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21690

def date
  @date
end

#documentsObject (readonly)

Returns the value of attribute documents.



21690
21691
21692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21690

def documents
  @documents
end

#entityObject (readonly)

Returns the value of attribute entity.



21690
21691
21692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21690

def entity
  @entity
end

#idObject (readonly)

Returns the value of attribute id.



21690
21691
21692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21690

def id
  @id
end

#invoiceObject (readonly)

Returns the value of attribute invoice.



21690
21691
21692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21690

def invoice
  @invoice
end

#keyObject (readonly)

Returns the value of attribute key.



21690
21691
21692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21690

def key
  @key
end

#linesObject (readonly)

Returns the value of attribute lines.



21690
21691
21692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21690

def lines
  @lines
end

#paymentsObject (readonly)

Returns the value of attribute payments.



21690
21691
21692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21690

def payments
  @payments
end

#statusObject (readonly)

Returns the value of attribute status.



21690
21691
21692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21690

def status
  @status
end

#tax_registrationObject (readonly)

Returns the value of attribute tax_registration.



21690
21691
21692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21690

def tax_registration
  @tax_registration
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21712
21713
21714
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21712

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

#to_hashObject



21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21716

def to_hash
  {
    :id => id,
    :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_jsonObject



21708
21709
21710
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21708

def to_json
  JSON.dump(to_hash)
end