-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.py
43 lines (29 loc) · 1021 Bytes
/
api.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
import http.client
def connect_api(payload):
conn = http.client.HTTPSConnection("api.aceservices.com")
headers = {
'X-IBM-Client-Id': "REPLACE_CLIENT_ID",
'X-IBM-Client-Secret': "REPLACE_THIS_SECRET_TOKEN",
'content-type': "application/json",
'accept': "application/json"
}
conn.request("POST", "/qa/ShipEstimate", payload, headers)
res = conn.getresponse()
data = res.read()
return data.decode("utf-8")
def connect_api_capsule(payload, sku, qty):
conn = http.client.HTTPSConnection("api.aceservices.com")
headers = {
'X-IBM-Client-Id': "REPLACE_CLIENT_ID",
'X-IBM-Client-Secret': "REPLACE_THIS_SECRET_TOKEN",
'content-type': "application/json",
'accept': "application/json"
}
conn.request("POST", "/qa/ShipEstimate", payload, headers)
res = conn.getresponse()
data = res.read()
return {
"data": data.decode('utf-8'),
"qty": qty,
"sku": sku
}