@@ 68-107 (lines=40) @@ | ||
65 | return -1 |
|
66 | ||
67 | ||
68 | def update_scooter(self) -> None: |
|
69 | """ Update api with all scooters data. """ |
|
70 | mutation = ''' mutation updateScooterById( |
|
71 | $id: String!, |
|
72 | $battery: String!, |
|
73 | $status_id: String!, |
|
74 | $longitude: String!, |
|
75 | $latitude: String!, |
|
76 | $price_id: String!, |
|
77 | $speed: String!, |
|
78 | $station_id: String!) { |
|
79 | updateScooterById( |
|
80 | id: $id, |
|
81 | battery: $battery, |
|
82 | status_id: $status_id, |
|
83 | longitude: $longitude, |
|
84 | latitude: $latitude, |
|
85 | price_id: $price_id, |
|
86 | speed: $speed, |
|
87 | station_id: $station_id) { id } |
|
88 | } ''' |
|
89 | ||
90 | payload = { |
|
91 | 'query': mutation, |
|
92 | 'variables': { |
|
93 | 'id': self.data["id"], |
|
94 | 'status_id': str(self.data["status"]), |
|
95 | 'latitude': str(self.data["lat"]), |
|
96 | 'longitude': str(self.data["lon"]), |
|
97 | 'speed': str(self.data["speed"]), |
|
98 | 'battery': str(self.data["battery"]), |
|
99 | 'station_id': str(self.data["station"]), |
|
100 | 'price_id': "1" |
|
101 | } |
|
102 | } |
|
103 | ||
104 | try: |
|
105 | requests.post(self._URL, json=payload, headers=self._HEADERS) |
|
106 | except (Exception, ConnectionError) as error: |
|
107 | print(error) |
|
108 | ||
109 | ||
110 | def update_rented_scooter(self) -> None: |
|
@@ 110-146 (lines=37) @@ | ||
107 | print(error) |
|
108 | ||
109 | ||
110 | def update_rented_scooter(self) -> None: |
|
111 | """ Update api with scooter's new position, speed, status and battery level. """ |
|
112 | mutation = ''' mutation updateRentedScooterById( |
|
113 | $id: String!, |
|
114 | $battery: String!, |
|
115 | $status_id: String!, |
|
116 | $longitude: String!, |
|
117 | $latitude: String!, |
|
118 | $speed: String!) { |
|
119 | updateRentedScooterById( |
|
120 | id: $id, |
|
121 | battery: $battery, |
|
122 | status_id: $status_id, |
|
123 | longitude: $longitude, |
|
124 | latitude: $latitude, |
|
125 | speed: $speed) |
|
126 | { |
|
127 | id |
|
128 | } |
|
129 | } ''' |
|
130 | ||
131 | payload = { |
|
132 | 'query': mutation, |
|
133 | 'variables': { |
|
134 | 'id': self.data["id"], |
|
135 | 'status_id': str(self.data["status"]), |
|
136 | 'latitude': str(self.data["lat"]), |
|
137 | 'longitude': str(self.data["lon"]), |
|
138 | 'speed': str(self.data["speed"]), |
|
139 | 'battery': str(self.data["battery"]), |
|
140 | } |
|
141 | } |
|
142 | ||
143 | try: |
|
144 | requests.post(self._URL, json=payload, headers=self._HEADERS) |
|
145 | except (Exception, ConnectionError) as error: |
|
146 | print(error) |
|
147 | ||
148 | ||
149 | def rent_scooter(self) -> None: |