-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrashtechApi.py
More file actions
24 lines (19 loc) · 810 Bytes
/
TrashtechApi.py
File metadata and controls
24 lines (19 loc) · 810 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
import requests
import json
class TrashtechApi:
api_base = 'http://staging.trashtech.co/api'
def create_status(self, device_reference,encoded_image, image_created_at):
request_json = {
"device_status": {
"image_created_at": image_created_at,
"image_base": "data:image/jpg;base64,%s" % encoded_image.decode('utf-8'),
"device_reference": device_reference,
"container_identifier_number": device_reference,
}
}
url = "%s/device_statuses/" % (self.api_base)
requestBody = json.dumps(request_json)
headers = {'content-type': 'application/json'}
response = requests.post(url, data=requestBody, headers=headers)
jsonResult = response
return jsonResult