Module: Orderspace::Endpoint::Orders

Includes:
Structs
Included in:
Client::OrdersEndpoint
Defined in:
lib/orderspace/endpoint/orders.rb

Overview

Contains the methods to interact with the orders endpoint.

Instance Method Summary collapse

Methods included from Structs

from, hashify, validate

Instance Method Details

#get_order(order_id) ⇒ Object

Returns an order recognised by its id

Parameters:

  • order_id (String)

    the id of the order we want to get



33
34
35
36
37
# File 'lib/orderspace/endpoint/orders.rb', line 33

def get_order(order_id)
  response = client.get("orders/#{order_id}")

  Orderspace::Structs.from(JSON.parse(response.body)['order'], Order)
end

#list_orders(options = {}) ⇒ Object

Lists all the orders.

You can pass in options like so:

{ query: { limit: 20 } }

Check tho orderspace API documentation to know all the options available.



24
25
26
27
# File 'lib/orderspace/endpoint/orders.rb', line 24

def list_orders(options = {})
  response = client.get('orders', options)
  Orderspace::Structs.from(JSON.parse(response.body), OrderList)
end