Class: TaxCloud::CartItem

Inherits:
Object
  • Object
show all
Defined in:
lib/tax_cloud/cart_item.rb

Overview

A CartItem defines a single line item for the purchase. Used to calculate the tax amount.

Attributes

  • index - The unique index number for the line item. Must be unique for the scope of the cart.

  • item_id - The stock keeping unit (SKU) number

  • tic - The taxable information code. See TaxCloud::TaxCodes.

  • price - The price of the item. All prices are USD. Do not include currency symbol.

  • quantity - The total number of items.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ CartItem

Returns a new instance of CartItem.



15
16
17
18
19
20
# File 'lib/tax_cloud/cart_item.rb', line 15

def initialize(attrs = {})
  attrs.each do |sym, val|
    self.send "#{sym}=", val
  end
  super
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



13
14
15
# File 'lib/tax_cloud/cart_item.rb', line 13

def index
  @index
end

#item_idObject

Returns the value of attribute item_id.



13
14
15
# File 'lib/tax_cloud/cart_item.rb', line 13

def item_id
  @item_id
end

#priceObject

Returns the value of attribute price.



13
14
15
# File 'lib/tax_cloud/cart_item.rb', line 13

def price
  @price
end

#quantityObject

Returns the value of attribute quantity.



13
14
15
# File 'lib/tax_cloud/cart_item.rb', line 13

def quantity
  @quantity
end

#ticObject

Returns the value of attribute tic.



13
14
15
# File 'lib/tax_cloud/cart_item.rb', line 13

def tic
  @tic
end

Instance Method Details

#to_hashObject

Convert the object to a usable hash for SOAP requests



23
24
25
26
27
28
29
30
31
# File 'lib/tax_cloud/cart_item.rb', line 23

def to_hash
  {
    'Index' => index,
    'ItemID' => item_id,
    'TIC' => tic,
    'Price' => price,
    'Qty' => quantity
  }
end