Class: FastSpring::Order

Inherits:
PrivateApiBase show all
Defined in:
lib/fastspring-saasy/order.rb

Instance Attribute Summary

Attributes inherited from PrivateApiBase

#customer

Instance Method Summary collapse

Methods inherited from PrivateApiBase

find, #initialize, #referrer, #source_campaign, #source_key, #source_name, #status, #status_changed

Constructor Details

This class inherits a constructor from FastSpring::PrivateApiBase

Instance Method Details

#addressObject



64
65
66
# File 'lib/fastspring-saasy/order.rb', line 64

def address
  @address ||= Address.new(value_for('address'))
end

#base_order_pathObject



9
10
11
# File 'lib/fastspring-saasy/order.rb', line 9

def base_order_path
  "/company/#{@company}/order/#{@reference}"
end

#currencyObject



40
41
42
# File 'lib/fastspring-saasy/order.rb', line 40

def currency
  value_for('currency')
end

#dueObject

Returns a DateTime object



36
37
38
# File 'lib/fastspring-saasy/order.rb', line 36

def due
  DateTime.parse(value_for('due'))
end

#findObject

Get the order from Saasy



4
5
6
7
# File 'lib/fastspring-saasy/order.rb', line 4

def find
  @response = self.class.get(base_order_path, :basic_auth => @auth, :ssl_ca_file => @ssl_ca_file)
  self
end

#itemsObject



13
14
15
# File 'lib/fastspring-saasy/order.rb', line 13

def items
  @items ||= [Item.new(parsed_response['orderItems']['orderItem'])]
end

#origin_ipObject



44
45
46
# File 'lib/fastspring-saasy/order.rb', line 44

def origin_ip
  value_for('originIp')
end

#paymentObject



21
22
23
# File 'lib/fastspring-saasy/order.rb', line 21

def payment
  payments[0]
end

#paymentsObject



17
18
19
# File 'lib/fastspring-saasy/order.rb', line 17

def payments
  @payments ||= [Payment.new(parsed_response['payments']['payment'])]
end

#purchaserObject



48
49
50
# File 'lib/fastspring-saasy/order.rb', line 48

def purchaser
  @purchaser ||= Customer.new(value_for('customer'))
end

#referenceObject

Return the order reference



26
27
28
# File 'lib/fastspring-saasy/order.rb', line 26

def reference
  value_for('reference')
end

#shippingObject



60
61
62
# File 'lib/fastspring-saasy/order.rb', line 60

def shipping
  value_for('shipping').to_f
end

#taxObject



56
57
58
# File 'lib/fastspring-saasy/order.rb', line 56

def tax
  value_for('tax').to_f
end

#test?Boolean

Was the order a test?

Returns:

  • (Boolean)


31
32
33
# File 'lib/fastspring-saasy/order.rb', line 31

def test?
  value_for('test') == 'true'
end

#totalObject



52
53
54
# File 'lib/fastspring-saasy/order.rb', line 52

def total
  value_for('total').to_f
end