Class: Lce::Order
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- Lce::Order
- Includes:
- Hashie::Extensions::Coercion
- Defined in:
- lib/lce/order.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.all(page = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lce/order.rb', line 16 def all(page = nil) if page page = 1 if page <= 0 = {page: page} end response = Lce.client.get('orders', nil, nil, nil , ) response.map! do |q| new(q) end end |
.find(id) ⇒ Object
27 28 29 30 |
# File 'lib/lce/order.rb', line 27 def find(id) response = Lce.client.get('orders', id) new(response) end |
.place(params) ⇒ Object
11 12 13 14 |
# File 'lib/lce/order.rb', line 11 def place(params) response = Lce.client.post('orders', {order: params}) new(response) end |
Instance Method Details
#labels ⇒ Object
34 35 36 |
# File 'lib/lce/order.rb', line 34 def labels @labels ||= Lce.client.get('orders', id, 'labels', 'pdf') end |
#tracking ⇒ Object
45 46 47 48 49 |
# File 'lib/lce/order.rb', line 45 def tracking Lce.client.get('orders', id, 'tracking').map! do |t| Hashie::Mash.new(t) end end |
#write_labels(name = nil) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/lce/order.rb', line 38 def write_labels(name = nil) name = (name.is_a?(String)) ? name : "labels-#{id}.pdf" File.open(name, "wb") do |f| f.write(labels) end end |