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.



36709
36710
36711
36712
36713
36714
36715
36716
36717
36718
36719
36720
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36709

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_discount = (x = opts.delete(:unit_discount); x.nil? ? nil : (x = x; 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.



36707
36708
36709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36707

def description
  @description
end

#itemObject (readonly)

Returns the value of attribute item.



36707
36708
36709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36707

def item
  @item
end

#quantityObject (readonly)

Returns the value of attribute quantity.



36707
36708
36709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36707

def quantity
  @quantity
end

#unit_discountObject (readonly)

Returns the value of attribute unit_discount.



36707
36708
36709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36707

def unit_discount
  @unit_discount
end

#unit_dutyObject (readonly)

Returns the value of attribute unit_duty.



36707
36708
36709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36707

def unit_duty
  @unit_duty
end

#unit_priceObject (readonly)

Returns the value of attribute unit_price.



36707
36708
36709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36707

def unit_price
  @unit_price
end

#unit_taxObject (readonly)

Returns the value of attribute unit_tax.



36707
36708
36709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36707

def unit_tax
  @unit_tax
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



36726
36727
36728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36726

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

#subtype_to_hashObject



36730
36731
36732
36733
36734
36735
36736
36737
36738
36739
36740
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36730

def subtype_to_hash
  {
    :item => item.to_hash,
    :description => description,
    :quantity => quantity,
    :unit_price => unit_price.to_hash,
    :unit_discount => unit_discount.nil? ? nil : unit_discount.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



36722
36723
36724
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36722

def to_json
  JSON.dump(to_hash)
end