Class: Celery::Order
- Inherits:
-
Object
- Object
- Celery::Order
- Defined in:
- lib/celery/resources/order.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
Instance Method Summary collapse
-
#all(params = {}) ⇒ JSON
Returns a list of orders you have.
-
#cancel(order_id) ⇒ JSON
TODO: There is no way that this is a get request! TODO: Is “cancelled” and order status? Cancels an order.
-
#charge_balance(order_id) ⇒ JSON
Charges balance.
-
#charge_deposit(order_id) ⇒ JSON
Charges deposit.
-
#destroy(order_id) ⇒ JSON
Deletes an existing order object.
-
#find(order_id) ⇒ JSON
Retrieves an order that has previously been created.
-
#initialize(api) ⇒ Order
constructor
A new instance of Order.
-
#new(order) ⇒ JSON
Creates a new order object.
-
#paid(params = {}) ⇒ Object
Returns a list of ‘paid` orders.
-
#paid_balance(params = {}) ⇒ Object
Returns a list of ‘paid_balance` orders.
-
#paid_deposit(params = {}) ⇒ Object
Returns a list of ‘paid_deposit` orders.
-
#refund_balance(order_id) ⇒ JSON
Refunds balance.
-
#refund_deposit(order_id) ⇒ JSON
Refunds deposit.
-
#refunded(params = {}) ⇒ Object
Returns a list of ‘refunded` orders.
-
#ship(order_id) ⇒ JSON
TODO: There is no way that this is a get request! TODO: Is “cancelled” and order status? Changes order status to ‘shipped `.
-
#shipped(params = {}) ⇒ Object
Returns a list of ‘shipped` orders.
-
#update(order_id, order) ⇒ JSON
Updates an existing order object.
Constructor Details
#initialize(api) ⇒ Order
Returns a new instance of Order.
5 6 7 |
# File 'lib/celery/resources/order.rb', line 5 def initialize(api) @api = api end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
3 4 5 |
# File 'lib/celery/resources/order.rb', line 3 def api @api end |
Instance Method Details
#all(params = {}) ⇒ JSON
Returns a list of orders you have. The orders are returned in sorted order, with the most recent orders appearing first.
36 37 38 |
# File 'lib/celery/resources/order.rb', line 36 def all(params = {}) @api.get("orders", query: params) end |
#cancel(order_id) ⇒ JSON
TODO: There is no way that this is a get request! TODO: Is “cancelled” and order status? Cancels an order.
211 212 213 |
# File 'lib/celery/resources/order.rb', line 211 def cancel(order_id) @api.get("orders/#{order_id}/cancel") end |
#charge_balance(order_id) ⇒ JSON
Charges balance.
243 244 245 |
# File 'lib/celery/resources/order.rb', line 243 def charge_balance(order_id) @api.post("orders/#{order_id}/charge_balance") end |
#charge_deposit(order_id) ⇒ JSON
Charges deposit.
227 228 229 |
# File 'lib/celery/resources/order.rb', line 227 def charge_deposit(order_id) @api.post("orders/#{order_id}/charge_deposit") end |
#destroy(order_id) ⇒ JSON
Deletes an existing order object.
191 192 193 |
# File 'lib/celery/resources/order.rb', line 191 def destroy(order_id) @api.delete("orders/#{order_id}") end |
#find(order_id) ⇒ JSON
Retrieves an order that has previously been created.
124 125 126 |
# File 'lib/celery/resources/order.rb', line 124 def find(order_id) @api.get("orders/#{order_id}") end |
#new(order) ⇒ JSON
Creates a new order object.
150 151 152 |
# File 'lib/celery/resources/order.rb', line 150 def new(order) @api.post("orders", body: {order: order}) end |
#paid(params = {}) ⇒ Object
Returns a list of ‘paid` orders.
49 50 51 52 |
# File 'lib/celery/resources/order.rb', line 49 def paid(params = {}) params[:status] = 'paid' all(params) end |
#paid_balance(params = {}) ⇒ Object
Returns a list of ‘paid_balance` orders.
63 64 65 66 |
# File 'lib/celery/resources/order.rb', line 63 def paid_balance(params = {}) params[:status] = 'paid_balance' all(params) end |
#paid_deposit(params = {}) ⇒ Object
Returns a list of ‘paid_deposit` orders.
77 78 79 80 |
# File 'lib/celery/resources/order.rb', line 77 def paid_deposit(params = {}) params[:status] = 'paid_deposit' all(params) end |
#refund_balance(order_id) ⇒ JSON
Refunds balance.
275 276 277 |
# File 'lib/celery/resources/order.rb', line 275 def refund_balance(order_id) @api.post("orders/#{order_id}/refund_balance") end |
#refund_deposit(order_id) ⇒ JSON
Refunds deposit.
259 260 261 |
# File 'lib/celery/resources/order.rb', line 259 def refund_deposit(order_id) @api.post("orders/#{order_id}/refund_deposit") end |
#refunded(params = {}) ⇒ Object
Returns a list of ‘refunded` orders.
91 92 93 94 |
# File 'lib/celery/resources/order.rb', line 91 def refunded(params = {}) params[:status] = 'refunded' all(params) end |
#ship(order_id) ⇒ JSON
TODO: There is no way that this is a get request! TODO: Is “cancelled” and order status? Changes order status to ‘shipped `.
293 294 295 |
# File 'lib/celery/resources/order.rb', line 293 def ship(order_id) @api.get("orders/#{order_id}/ship") end |
#shipped(params = {}) ⇒ Object
Returns a list of ‘shipped` orders.
105 106 107 108 |
# File 'lib/celery/resources/order.rb', line 105 def shipped(params = {}) params[:status] = 'shipped' all(params) end |
#update(order_id, order) ⇒ JSON
Updates an existing order object.
172 173 174 |
# File 'lib/celery/resources/order.rb', line 172 def update(order_id, order) @api.put("orders/#{order_id}", body: {order: order}) end |