forked from cosmicpython/code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_client.py
More file actions
30 lines (24 loc) · 712 Bytes
/
api_client.py
File metadata and controls
30 lines (24 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests
from allocation import config
def post_to_add_batch(ref, sku, qty, eta):
url = config.get_api_url()
r = requests.post(
f"{url}/add_batch", json={"ref": ref, "sku": sku, "qty": qty, "eta": eta}
)
assert r.status_code == 201
def post_to_allocate(orderid, sku, qty, expect_success=True):
url = config.get_api_url()
r = requests.post(
f"{url}/allocate",
json={
"orderid": orderid,
"sku": sku,
"qty": qty,
},
)
if expect_success:
assert r.status_code == 202
return r
def get_allocation(orderid):
url = config.get_api_url()
return requests.get(f"{url}/allocations/{orderid}")