Class: Jet::Client::Orders

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

Overview

Orders client

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

#check_for_tagged_orders(status, tag, with_tag = true) ⇒ Object



43
44
45
46
47
# File 'lib/jet/client/orders.rb', line 43

def check_for_tagged_orders(status, tag, with_tag = true)
  query_status = STATUSES[status]
  query_with_tag = with_tag ? true : false
  @client.rest_get_with_token("/orders/#{query_status}/#{tag}/#{query_with_tag}")
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, params = {}) ⇒ Object



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

def get_orders(status = :ready, params = {})
  query_status = STATUSES[status]
  @client.rest_get_with_token("/orders/#{query_status}", params)
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

#tag_order(order_id, tag) ⇒ Object



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

def tag_order(order_id, tag)
  body = { tag: tag } if tag
  @client.rest_put_with_token("/orders/#{order_id}/tag", body)
end