Class: Io::Flow::V0::Models::ConsumerInvoiceLineItem

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

Instance Attribute Summary collapse

Attributes inherited from ConsumerInvoiceLine

#discriminator

Instance Method Summary collapse

Methods inherited from ConsumerInvoiceLine

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ ConsumerInvoiceLineItem

Returns a new instance of ConsumerInvoiceLineItem.



19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19805

def initialize(incoming={})
  super(:discriminator => ConsumerInvoiceLine::Types::CONSUMER_INVOICE_LINE_ITEM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:item, :description, :quantity, :unit_price], 'ConsumerInvoiceLineItem')
  @item = (x = opts.delete(:item); x.is_a?(::Io::Flow::V0::Models::ItemReference) ? x : ::Io::Flow::V0::Models::ItemReference.new(x))
  @description = HttpClient::Preconditions.assert_class('description', opts.delete(:description), String)
  @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer)
  @unit_price = (x = opts.delete(:unit_price); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))
  @unit_tax = (x = opts.delete(:unit_tax); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceLevy) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceLevy.new(x)))
  @unit_duty = (x = opts.delete(:unit_duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceLevy) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceLevy.new(x)))
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



19803
19804
19805
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19803

def description
  @description
end

#itemObject (readonly)

Returns the value of attribute item.



19803
19804
19805
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19803

def item
  @item
end

#quantityObject (readonly)

Returns the value of attribute quantity.



19803
19804
19805
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19803

def quantity
  @quantity
end

#unit_dutyObject (readonly)

Returns the value of attribute unit_duty.



19803
19804
19805
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19803

def unit_duty
  @unit_duty
end

#unit_priceObject (readonly)

Returns the value of attribute unit_price.



19803
19804
19805
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19803

def unit_price
  @unit_price
end

#unit_taxObject (readonly)

Returns the value of attribute unit_tax.



19803
19804
19805
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19803

def unit_tax
  @unit_tax
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



19821
19822
19823
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19821

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

#subtype_to_hashObject



19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19825

def subtype_to_hash
  {
    :item => item.to_hash,
    :description => description,
    :quantity => quantity,
    :unit_price => unit_price.to_hash,
    :unit_tax => unit_tax.nil? ? nil : unit_tax.to_hash,
    :unit_duty => unit_duty.nil? ? nil : unit_duty.to_hash
  }
end

#to_jsonObject



19817
19818
19819
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19817

def to_json
  JSON.dump(to_hash)
end