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.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def description
  @description
end

#dutyObject

Returns the value of attribute duty.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def duty
  @duty
end

#duty_descriptionObject

Returns the value of attribute duty_description.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def duty_description
  @duty_description
end

#duty_nameObject

Returns the value of attribute duty_name.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def duty_name
  @duty_name
end

#freightObject

Returns the value of attribute freight.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def freight
  @freight
end

#freight_descriptionObject

Returns the value of attribute freight_description.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def freight_description
  @freight_description
end

#freight_nameObject

Returns the value of attribute freight_name.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def freight_name
  @freight_name
end

#invoice_numObject

Returns the value of attribute invoice_num.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def invoice_num
  @invoice_num
end

#line_itemsObject

Returns the value of attribute line_items.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def line_items
  @line_items
end

#po_numObject

Returns the value of attribute po_num.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def po_num
  @po_num
end

#taxObject

Returns the value of attribute tax.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def tax
  @tax
end

#tax_descriptionObject

Returns the value of attribute tax_description.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def tax_description
  @tax_description
end

#tax_exemptObject

Returns the value of attribute tax_exempt.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

def tax_exempt
  @tax_exempt
end

#tax_nameObject

Returns the value of attribute tax_name.



6
7
8
# File 'lib/authorize_net/order.rb', line 6

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



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

def add_line_item(id = nil, name = nil, description = nil, quantity = nil, price = nil, taxable = nil)
  if id.is_a?(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



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

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