Class: WhiplashApi::Order
- Inherits:
-
Base
- Object
- ActiveResource::Base
- Base
- WhiplashApi::Order
show all
- Defined in:
- lib/whiplash_api/order.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
connection, headers, reset_headers!, testing!
Class Method Details
.cancel(id, args = {}) ⇒ Object
37
38
39
|
# File 'lib/whiplash_api/order.rb', line 37
def cancel(id, args={})
self.put("#{id}/cancel")
end
|
.count(args = {}) ⇒ Object
11
12
13
|
# File 'lib/whiplash_api/order.rb', line 11
def count(args={})
self.get(:count, args)
end
|
.find_or_create_by_originator_id(id, args = {}) ⇒ Object
19
20
21
|
# File 'lib/whiplash_api/order.rb', line 19
def find_or_create_by_originator_id(id, args={})
originator(id) || create(args.merge(originator_id: id))
end
|
.originator(id, args = {}) ⇒ Object
15
16
17
|
# File 'lib/whiplash_api/order.rb', line 15
def originator(id, args={})
sanitize_as_resource self.get("originator/#{id}", args)
end
|
.pause(id, args = {}) ⇒ Object
29
30
31
|
# File 'lib/whiplash_api/order.rb', line 29
def pause(id, args={})
self.put("#{id}/pause")
end
|
.release(id, args = {}) ⇒ Object
33
34
35
|
# File 'lib/whiplash_api/order.rb', line 33
def release(id, args={})
self.put("#{id}/release")
end
|
.status_code_for(status) ⇒ Object
7
8
9
|
# File 'lib/whiplash_api/order.rb', line 7
def status_code_for(status)
status_mapping.invert[status.to_s.underscore.to_sym]
end
|
.status_for(status) ⇒ Object
4
5
6
|
# File 'lib/whiplash_api/order.rb', line 4
def status_for(status)
status_mapping[status].to_s.titleize
end
|
.uncancel(id, args = {}) ⇒ Object
41
42
43
|
# File 'lib/whiplash_api/order.rb', line 41
def uncancel(id, args={})
self.put("#{id}/uncancel")
end
|
.update(args = {}) ⇒ Object
23
24
25
26
27
|
# File 'lib/whiplash_api/order.rb', line 23
def update(args={})
order = self.originator(args[:originator_id])
raise RecordNotFound, "No order found with given Originator ID." unless order
order.update_attributes(args) ? order : false
end
|
Instance Method Details
#being_processed? ⇒ Boolean
Also known as:
processing?
93
94
95
|
# File 'lib/whiplash_api/order.rb', line 93
def being_processed?
self.status.to_i == 100
end
|
#cancel ⇒ Object
106
107
108
|
# File 'lib/whiplash_api/order.rb', line 106
def cancel
self.put(:cancel)
end
|
#cancelled? ⇒ Boolean
85
86
87
|
# File 'lib/whiplash_api/order.rb', line 85
def cancelled?
self.status.to_i == 40
end
|
#pause ⇒ Object
98
99
100
|
# File 'lib/whiplash_api/order.rb', line 98
def pause
self.put(:pause)
end
|
#paused? ⇒ Boolean
81
82
83
|
# File 'lib/whiplash_api/order.rb', line 81
def paused?
self.status.to_i == 90
end
|
#release ⇒ Object
102
103
104
|
# File 'lib/whiplash_api/order.rb', line 102
def release
self.put(:release)
end
|
#uncancel ⇒ Object
110
111
112
|
# File 'lib/whiplash_api/order.rb', line 110
def uncancel
self.put(:uncancel)
end
|
#unprocessed? ⇒ Boolean
89
90
91
|
# File 'lib/whiplash_api/order.rb', line 89
def unprocessed?
self.status.to_i < 100
end
|
#unshipped? ⇒ Boolean
77
78
79
|
# File 'lib/whiplash_api/order.rb', line 77
def unshipped?
self.status.to_i < 300
end
|