Class: Jet::Client::Orders

Inherits:
Object
  • Object
show all
Defined in:
lib/jet/client/orders.rb

Constant Summary collapse

STATUSES =
{
  created: 'created',
  ready: 'ready',
  acknowledged: 'acknowledged',
  inprogress: 'inprogress',
  complete: 'complete',
}

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Orders

Returns a new instance of Orders.



13
14
15
# File 'lib/jet/client/orders.rb', line 13

def initialize(client)
  @client = client
end

Instance Method Details

#acknowledge_order(order_id, body = {}) ⇒ Object



30
31
32
# File 'lib/jet/client/orders.rb', line 30

def acknowledge_order(order_id, body = {})
  @client.rest_put_with_token("/orders/#{order_id}/acknowledge", body)
end

#get_directed_cancelObject



38
39
40
# File 'lib/jet/client/orders.rb', line 38

def get_directed_cancel
  @client.rest_get_with_token('/orders/directedCancel')
end

#get_order(order_url) ⇒ Object



22
23
24
# File 'lib/jet/client/orders.rb', line 22

def get_order(order_url)
  @client.rest_get_with_token(order_url)
end

#get_order_by_id(order_id) ⇒ Object



26
27
28
# File 'lib/jet/client/orders.rb', line 26

def get_order_by_id(order_id)
  @client.rest_get_with_token("/orders/withoutShipmentDetail/#{order_id}")
end

#get_orders(status = :ready) ⇒ Object



17
18
19
20
# File 'lib/jet/client/orders.rb', line 17

def get_orders(status = :ready)
  query_status = STATUSES[status]
  @client.rest_get_with_token("/orders/#{query_status}")
end

#ship_order(order_id, body = {}) ⇒ Object



34
35
36
# File 'lib/jet/client/orders.rb', line 34

def ship_order(order_id, body = {})
  @client.rest_put_with_token("/orders/#{order_id}/shipped", body)
end