class Io::Flow::V0::Models::ConsumerInvoice

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.

Attributes

attributes[R]
billing_address[R]
center[R]
customer_type[R]
date[R]
destination[R]
documents[R]
entity[R]
estimated_delivery_date[R]
id[R]
key[R]
lines[R]
number[R]
order[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 36393
def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :number, :status, :date, :key, :order, :entity, :payments, :destination, :lines, :documents, :attributes], 'ConsumerInvoice')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), 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)))
  @customer_type = (x = opts.delete(:customer_type); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceCustomerType) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceCustomerType.apply(x)))
  @estimated_delivery_date = (x = opts.delete(:estimated_delivery_date); x.nil? ? nil : HttpClient::Preconditions.assert_class('estimated_delivery_date', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
end

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 36419
def copy(incoming={})
  ConsumerInvoice.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 36423
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,
    :customer_type => customer_type.nil? ? nil : customer_type.value,
    :estimated_delivery_date => estimated_delivery_date
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 36415
def to_json
  JSON.dump(to_hash)
end