From d254b9e20fa95e3a20a574356bbdfbd6799f9060 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Tue, 27 Aug 2024 10:18:12 +0700 Subject: [PATCH] Create autonomous_vehicle.py --- .../iot_devices/autonomous_vehicle.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 iot-integration/iot_devices/autonomous_vehicle.py diff --git a/iot-integration/iot_devices/autonomous_vehicle.py b/iot-integration/iot_devices/autonomous_vehicle.py new file mode 100644 index 000000000..d13a1a790 --- /dev/null +++ b/iot-integration/iot_devices/autonomous_vehicle.py @@ -0,0 +1,16 @@ +import requests + +class AutonomousVehicleDevice: + def __init__(self, device_id, device_token): + self.device_id = device_id + self.device_token = device_token + + def make_payment(self, amount): + # Make a request to the autonomous vehicle API to make a payment + response = requests.post(f'https://autonomous-vehicle-api.com/payments/{self.device_id}', json={'amount': amount}, headers={'Authorization': f'Bearer {self.device_token}'}) + return response.json() + + def get_vehicle_data(self): + # Make a request to the autonomous vehicle API to retrieve vehicle data + response = requests.get(f'https://autonomous-vehicle-api.com/vehicles/{self.device_id}', headers={'Authorization': f'Bearer {self.device_token}'}) + return response.json()