Class: AuthorizeNet::Order

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/authorize_net/order.rb

Overview

Models an order.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Model

#initialize, #to_a

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def description
  @description
end

#dutyObject

Returns the value of attribute duty.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def duty
  @duty
end

#duty_descriptionObject

Returns the value of attribute duty_description.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def duty_description
  @duty_description
end

#duty_nameObject

Returns the value of attribute duty_name.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def duty_name
  @duty_name
end

#freightObject

Returns the value of attribute freight.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def freight
  @freight
end

#freight_descriptionObject

Returns the value of attribute freight_description.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def freight_description
  @freight_description
end

#freight_nameObject

Returns the value of attribute freight_name.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def freight_name
  @freight_name
end

#invoice_numObject

Returns the value of attribute invoice_num.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def invoice_num
  @invoice_num
end

#line_itemsObject

Returns the value of attribute line_items.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def line_items
  @line_items
end

#po_numObject

Returns the value of attribute po_num.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def po_num
  @po_num
end

#taxObject

Returns the value of attribute tax.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def tax
  @tax
end

#tax_descriptionObject

Returns the value of attribute tax_description.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def tax_description
  @tax_description
end

#tax_exemptObject

Returns the value of attribute tax_exempt.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def tax_exempt
  @tax_exempt
end

#tax_nameObject

Returns the value of attribute tax_name.



8
9
10
# File 'lib/authorize_net/order.rb', line 8

def tax_name
  @tax_name
end

Instance Method Details

#add_line_item(id = nil, name = nil, description = nil, quantity = nil, price = nil, taxable = nil) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/authorize_net/order.rb', line 10

def add_line_item(id = nil, name = nil, description = nil, quantity = nil, price = nil, taxable = nil)
  if id.kind_of?(AuthorizeNet::LineItem)
    line_item = id
  else
    line_item = AuthorizeNet::LineItem.new({:id => id, :name => name, :description => description, :quantity => quantity, :price => price, :taxable => taxable})
  end
  @line_items = @line_items.to_a << line_item
end

#to_hashObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/authorize_net/order.rb', line 19

def to_hash
  hash = {
    :invoice_num => @invoice_num,
    :description => @description,
    :tax => @tax,
    :tax_name => @tax_name,
    :tax_description => @tax_description,
    :freight => @freight,
    :freight_name => @freight_name,
    :freight_description => @freight_description,
    :duty => @duty,
    :duty_name => @duty_name,
    :duty_description => @duty_description,
    :tax_exempt => @tax_exempt,
    :po_num => @po_num,
    :line_items => handle_multivalue_hashing(@line_items)
  }
  hash.delete_if {|k, v| v.nil?}
  hash
end