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.



20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20129

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.



20127
20128
20129
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20127

def description
  @description
end

#itemObject (readonly)

Returns the value of attribute item.



20127
20128
20129
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20127

def item
  @item
end

#quantityObject (readonly)

Returns the value of attribute quantity.



20127
20128
20129
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20127

def quantity
  @quantity
end

#unit_dutyObject (readonly)

Returns the value of attribute unit_duty.



20127
20128
20129
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20127

def unit_duty
  @unit_duty
end

#unit_priceObject (readonly)

Returns the value of attribute unit_price.



20127
20128
20129
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20127

def unit_price
  @unit_price
end

#unit_taxObject (readonly)

Returns the value of attribute unit_tax.



20127
20128
20129
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20127

def unit_tax
  @unit_tax
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



20145
20146
20147
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20145

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

#subtype_to_hashObject



20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20149

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



20141
20142
20143
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20141

def to_json
  JSON.dump(to_hash)
end