-
Notifications
You must be signed in to change notification settings - Fork 0
/
webims.py
25 lines (19 loc) · 949 Bytes
/
webims.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
from datetime import datetime
import requests
import json
requests.packages.urllib3.disable_warnings() # suppress SSL certificate warnings when ssl_verify=False
class WebIMS:
def __init__(self, endpoint, sessionId):
self.endpoint = endpoint
self.sessionId = sessionId
def inventory_import(self, warehouseId, file):
now = datetime.now()
bodyData = json.loads('{}')
bodyData.update({"warehouseId":warehouseId})
bodyData.update({"file":file})
response = requests.put(self.endpoint + '/api/inventory/import.php', json=bodyData, headers={'Auth-Key': self.sessionId}, verify=False)
print (response.content)
if response.status_code == 200:
print (now.strftime("%d/%m/%Y %H:%M:%S") + ": Data Imported " + str(response.content.decode('utf-8')))
else:
print (now.strftime("%d/%m/%Y %H:%M:%S") + ": Error occured!")