Class: FetchAPI::Order
- Inherits:
-
Object
show all
- Includes:
- HTTParty
- Defined in:
- lib/fetchapi/order.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ Order
Returns a new instance of Order.
9
10
11
12
13
14
15
16
|
# File 'lib/fetchapi/order.rb', line 9
def initialize(data)
case data
when Integer, String
@id = data
when Hash
@id, @data = data['id'], data
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/fetchapi/order.rb', line 52
def method_missing(method)
if (data.has_key? method.to_s)
data[method.to_s]
else
super
end
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
8
9
10
|
# File 'lib/fetchapi/order.rb', line 8
def id
@id
end
|
Class Method Details
.create(options) ⇒ Object
43
44
45
|
# File 'lib/fetchapi/order.rb', line 43
def self.create(options)
self.post("/orders/create", options)
end
|
.find(selector) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/fetchapi/order.rb', line 34
def self.find(selector)
case selector
when :all
self.get('/orders')['orders'].map { |data| self.new(data) }
when Integer, String
self.new(selector)
end
end
|
Instance Method Details
#destroy ⇒ Object
18
19
20
|
# File 'lib/fetchapi/order.rb', line 18
def destroy
self.delete("/orders/#{id}/delete")
end
|
#expire ⇒ Object
22
23
24
|
# File 'lib/fetchapi/order.rb', line 22
def expire
self.post("/orders/#{id}/expire")
end
|
#send_email(options) ⇒ Object
26
27
28
|
# File 'lib/fetchapi/order.rb', line 26
def send_email(options)
self.post("/orders/#{id}/send_email", options)
end
|
#update(options) ⇒ Object
30
31
32
|
# File 'lib/fetchapi/order.rb', line 30
def update(options)
self.post("/orders/#{id}/update", options)
end
|