Class: Io::Flow::V0::Models::ConsumerInvoice

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

The consumer invoice represents the details of a set of items from a given order. This may represent either the full order or a partial fulfillment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ConsumerInvoice

Returns a new instance of ConsumerInvoice.



21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21546

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :status, :date, :key, :order, :entity, :payments, :destination, :lines, :documents, :attributes], 'ConsumerInvoice')
  @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)
  @order = (x = opts.delete(:order); x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceOrderSummary) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceOrderSummary.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)) }
  @center = (x = opts.delete(:center); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceCenterReference) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceCenterReference.new(x)))
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::OrderAddress) ? x : ::Io::Flow::V0::Models::OrderAddress.new(x))
  @billing_address = (x = opts.delete(:billing_address); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::BillingAddress) ? x : ::Io::Flow::V0::Models::BillingAddress.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.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def attributes
  @attributes
end

#billing_addressObject (readonly)

Returns the value of attribute billing_address.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def billing_address
  @billing_address
end

#centerObject (readonly)

Returns the value of attribute center.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def center
  @center
end

#dateObject (readonly)

Returns the value of attribute date.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def date
  @date
end

#destinationObject (readonly)

Returns the value of attribute destination.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def destination
  @destination
end

#documentsObject (readonly)

Returns the value of attribute documents.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def documents
  @documents
end

#entityObject (readonly)

Returns the value of attribute entity.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def entity
  @entity
end

#idObject (readonly)

Returns the value of attribute id.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def key
  @key
end

#linesObject (readonly)

Returns the value of attribute lines.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def lines
  @lines
end

#numberObject (readonly)

Returns the value of attribute number.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def number
  @number
end

#orderObject (readonly)

Returns the value of attribute order.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def order
  @order
end

#paymentsObject (readonly)

Returns the value of attribute payments.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def payments
  @payments
end

#statusObject (readonly)

Returns the value of attribute status.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def status
  @status
end

#tax_registrationObject (readonly)

Returns the value of attribute tax_registration.



21544
21545
21546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21544

def tax_registration
  @tax_registration
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21570
21571
21572
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21570

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

#to_hashObject



21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21574

def to_hash
  {
    :id => id,
    :number => number,
    :status => status.value,
    :date => date,
    :key => key,
    :order => order.to_hash,
    :entity => entity.to_hash,
    :payments => payments.map { |o| o.to_hash },
    :center => center.nil? ? nil : center.to_hash,
    :destination => destination.to_hash,
    :billing_address => billing_address.nil? ? nil : billing_address.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



21566
21567
21568
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21566

def to_json
  JSON.dump(to_hash)
end