tesla-fleet-api 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,11 +16,11 @@ interface FleetTelemetryConfig {
16
16
 
17
17
  export default class VehicleSpecific {
18
18
  parent: Vehicle;
19
- vin: String;
20
- model: String;
21
- pre2021: Boolean;
19
+ vin: string;
20
+ model: string;
21
+ pre2021: boolean;
22
22
 
23
- constructor(parent: Vehicle, vin: String) {
23
+ constructor(parent: Vehicle, vin: string) {
24
24
  this.parent = parent;
25
25
  this.vin = vin;
26
26
  this.model = this.parent.model(this.vin);
@@ -34,7 +34,7 @@ export default class VehicleSpecific {
34
34
  * @param which_trunk "front" or "rear"
35
35
  */
36
36
  async actuate_truck(which_trunk: Trunk): Promise<CommandResponse> {
37
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/actuate_trunk`, null, { which_trunk });
37
+ return this.parent.actuate_truck(this.vin, which_trunk);
38
38
  }
39
39
 
40
40
  /**
@@ -42,105 +42,105 @@ export default class VehicleSpecific {
42
42
  * @param volume A floating point number from 0.0 to 11.0.
43
43
  */
44
44
  async adjust_volume(volume: number): Promise<CommandResponse> {
45
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/adjust_volume`, null, { volume });
45
+ return this.parent.adjust_volume(this.vin, volume);
46
46
  }
47
47
 
48
48
  /**
49
49
  * Starts climate preconditioning.
50
50
  */
51
51
  async auto_conditioning_start(): Promise<CommandResponse> {
52
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/auto_conditioning_start`);
52
+ return this.parent.auto_conditioning_start(this.vin);
53
53
  }
54
54
 
55
55
  /**
56
56
  * Stops climate preconditioning.
57
57
  */
58
58
  async auto_conditioning_stop(): Promise<CommandResponse> {
59
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/auto_conditioning_stop`);
59
+ return this.parent.auto_conditioning_stop(this.vin);
60
60
  }
61
61
 
62
62
  /**
63
63
  * Cancels the countdown to install the vehicle software update.
64
64
  */
65
65
  async cancel_software_update(): Promise<CommandResponse> {
66
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/cancel_software_update`);
66
+ return this.parent.cancel_software_update(this.vin);
67
67
  }
68
68
 
69
69
  /**
70
70
  * Charges in max range mode -- we recommend limiting the use of this mode to long trips.
71
71
  */
72
72
  async charge_max_range(): Promise<CommandResponse> {
73
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/charge_max_range`);
73
+ return this.parent.charge_max_range(this.vin);
74
74
  }
75
75
 
76
76
  /**
77
77
  * Closes the charge port door.
78
78
  */
79
79
  async charge_port_door_close(): Promise<CommandResponse> {
80
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/charge_port_door_close`);
80
+ return this.parent.charge_port_door_close(this.vin);
81
81
  }
82
82
 
83
83
  /**
84
84
  * Opens the charge port door.
85
85
  */
86
86
  async charge_port_door_open(): Promise<CommandResponse> {
87
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/charge_port_door_open`);
87
+ return this.parent.charge_port_door_open(this.vin);
88
88
  }
89
89
 
90
90
  /**
91
91
  * Charges in Standard mode.
92
92
  */
93
93
  async charge_standard(): Promise<CommandResponse> {
94
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/charge_standard`);
94
+ return this.parent.charge_standard(this.vin);
95
95
  }
96
96
 
97
97
  /**
98
98
  * Starts charging the vehicle.
99
99
  */
100
100
  async charge_start(): Promise<CommandResponse> {
101
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/charge_start`);
101
+ return this.parent.charge_start(this.vin);
102
102
  }
103
103
 
104
104
  /**
105
105
  * Stops charging the vehicle.
106
106
  */
107
107
  async charge_stop(): Promise<CommandResponse> {
108
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/charge_stop`);
108
+ return this.parent.charge_stop(this.vin);
109
109
  }
110
110
 
111
111
  /**
112
112
  * Deactivates PIN to Drive and resets the associated PIN for vehicles running firmware versions 2023.44+. This command is only accessible to fleet managers or owners.
113
113
  */
114
114
  async clear_pin_to_drive_admin(): Promise<CommandResponse> {
115
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/clear_pin_to_drive_admin`);
115
+ return this.parent.clear_pin_to_drive_admin(this.vin);
116
116
  }
117
117
 
118
118
  /**
119
119
  * Locks the vehicle.
120
120
  */
121
121
  async door_lock(): Promise<CommandResponse> {
122
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/door_lock`);
122
+ return this.parent.door_lock(this.vin);
123
123
  }
124
124
 
125
125
  /**
126
126
  * Unlocks the vehicle.
127
127
  */
128
128
  async door_unlock(): Promise<CommandResponse> {
129
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/door_unlock`);
129
+ return this.parent.door_unlock(this.vin);
130
130
  }
131
131
 
132
132
  /**
133
133
  * Erases user's data from the user interface. Requires the vehicle to be in park.
134
134
  */
135
135
  async erase_user_data(): Promise<CommandResponse> {
136
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/erase_user_data`);
136
+ return this.parent.erase_user_data(this.vin);
137
137
  }
138
138
 
139
139
  /**
140
140
  * Briefly flashes the vehicle headlights. Requires the vehicle to be in park.
141
141
  */
142
142
  async flash_lights(): Promise<CommandResponse> {
143
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/flash_lights`);
143
+ return this.parent.flash_lights(this.vin);
144
144
  }
145
145
 
146
146
  /**
@@ -148,56 +148,56 @@ export default class VehicleSpecific {
148
148
  * @param enable `true` or `false`
149
149
  */
150
150
  async guest_mode(enable: boolean): Promise<CommandResponse> {
151
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/guest_mode`, null, { enable });
151
+ return this.parent.guest_mode(this.vin, enable);
152
152
  }
153
153
 
154
154
  /**
155
155
  * Honks the vehicle horn. Requires the vehicle to be in park.
156
156
  */
157
157
  async honk_horn(): Promise<CommandResponse> {
158
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/honk_horn`);
158
+ return this.parent.honk_horn(this.vin);
159
159
  }
160
160
 
161
161
  /**
162
162
  * Advances media player to next favorite track.
163
163
  */
164
164
  async media_next_fav(): Promise<CommandResponse> {
165
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/media_next_fav`);
165
+ return this.parent.media_next_fav(this.vin);
166
166
  }
167
167
 
168
168
  /**
169
169
  * Advances media player to next track.
170
170
  */
171
171
  async media_next_track(): Promise<CommandResponse> {
172
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/media_next_track`);
172
+ return this.parent.media_next_track(this.vin);
173
173
  }
174
174
 
175
175
  /**
176
176
  * Advances media player to previous favorite track.
177
177
  */
178
178
  async media_prev_fav(): Promise<CommandResponse> {
179
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/media_prev_fav`);
179
+ return this.parent.media_prev_fav(this.vin);
180
180
  }
181
181
 
182
182
  /**
183
183
  * Advances media player to previous track.
184
184
  */
185
185
  async media_prev_track(): Promise<CommandResponse> {
186
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/media_prev_track`);
186
+ return this.parent.media_prev_track(this.vin);
187
187
  }
188
188
 
189
189
  /**
190
190
  * Toggles current play/pause state.
191
191
  */
192
192
  async media_toggle_playback(): Promise<CommandResponse> {
193
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/media_toggle_playback`);
193
+ return this.parent.media_toggle_playback(this.vin);
194
194
  }
195
195
 
196
196
  /**
197
197
  * Turns the volume down by one.
198
198
  */
199
199
  async media_volume_down(): Promise<CommandResponse> {
200
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/media_volume_down`);
200
+ return this.parent.media_volume_down(this.vin);
201
201
  }
202
202
 
203
203
  /**
@@ -207,7 +207,7 @@ export default class VehicleSpecific {
207
207
  * @param order Order of multiple stops
208
208
  */
209
209
  async navigation_gps_request(lat: number, lon: number, order?: number): Promise<CommandResponse> {
210
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/navigation_gps_request`, null, { lat, lon, order });
210
+ return this.parent.navigation_gps_request(this.vin, lat, lon, order);
211
211
  }
212
212
 
213
213
  /**
@@ -217,14 +217,7 @@ export default class VehicleSpecific {
217
217
  * @param timestamp_ms
218
218
  */
219
219
  async navigation_request(value: string, locale: string, type: string = "share_ext_content_raw"): Promise<CommandResponse> {
220
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/navigation_request`, null, {
221
- type,
222
- locale,
223
- timestamp_ms: String(Date.now()),
224
- value: {
225
- "android.intent.extra.TEXT": value,
226
- },
227
- });
220
+ return this.parent.navigation_request(this.vin, value, locale, type);
228
221
  }
229
222
 
230
223
  /**
@@ -234,7 +227,7 @@ export default class VehicleSpecific {
234
227
  * @returns
235
228
  */
236
229
  async navigation_sc_request(id: number, order?: number): Promise<CommandResponse> {
237
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/navigation_sc_request`, null, { id, order });
230
+ return this.parent.navigation_sc_request(this.vin, id, order);
238
231
  }
239
232
 
240
233
  /**
@@ -243,13 +236,7 @@ export default class VehicleSpecific {
243
236
  * @param auto_climate_on `true` or `false`
244
237
  */
245
238
  async remote_auto_seat_climate_request(auto_seat_position: Seat | number, auto_climate_on: boolean): Promise<CommandResponse> {
246
- if (typeof auto_seat_position === "string") {
247
- auto_seat_position = Seats[auto_seat_position];
248
- }
249
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/remote_auto_seat_climate_request`, null, {
250
- auto_seat_position,
251
- auto_climate_on,
252
- });
239
+ return this.parent.remote_auto_seat_climate_request(this.vin, auto_seat_position, auto_climate_on);
253
240
  }
254
241
 
255
242
  /**
@@ -257,7 +244,7 @@ export default class VehicleSpecific {
257
244
  * @param on `true` or `false`
258
245
  */
259
246
  async remote_auto_steering_wheel_heat_climate_request(on: boolean): Promise<CommandResponse> {
260
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/remote_auto_steering_wheel_heat_climate_request`, null, { on });
247
+ return this.parent.remote_auto_steering_wheel_heat_climate_request(this.vin, on);
261
248
  }
262
249
 
263
250
  /**
@@ -265,7 +252,7 @@ export default class VehicleSpecific {
265
252
  * @param sound Fart is `0`, Locate ping is `2000`
266
253
  */
267
254
  async remote_boombox(sound: number = 0): Promise<CommandResponse> {
268
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/remote_boombox`, null, { sound });
255
+ return this.parent.remote_boombox(this.vin, sound);
269
256
  }
270
257
 
271
258
  /**
@@ -274,13 +261,7 @@ export default class VehicleSpecific {
274
261
  * @param seat_cooler_level Cooling level
275
262
  */
276
263
  async remote_seat_cooler_request(seat_position: Seat | number, seat_cooler_level: Level): Promise<CommandResponse> {
277
- if (typeof seat_position === "string") {
278
- seat_position = Seats[seat_position];
279
- }
280
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/remote_seat_cooler_request`, null, {
281
- seat_position,
282
- seat_cooler_level,
283
- });
264
+ return this.parent.remote_seat_cooler_request(this.vin, seat_position, seat_cooler_level);
284
265
  }
285
266
 
286
267
  /**
@@ -289,20 +270,14 @@ export default class VehicleSpecific {
289
270
  * @param seat_heater_level Heating level
290
271
  */
291
272
  async remote_seat_heater_request(seat_position: Seat | number, seat_heater_level: Level): Promise<CommandResponse> {
292
- if (typeof seat_position === "string") {
293
- seat_position = Seats[seat_position];
294
- }
295
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/remote_seat_heater_request`, null, {
296
- seat_position,
297
- seat_heater_level,
298
- });
273
+ return this.parent.remote_seat_heater_request(this.vin, seat_position, seat_heater_level);
299
274
  }
300
275
 
301
276
  /**
302
277
  * Starts the vehicle remotely. Requires keyless driving to be enabled.
303
278
  */
304
279
  async remote_start_drive(): Promise<CommandResponse> {
305
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/remote_start_drive`);
280
+ return this.parent.remote_start_drive(this.vin);
306
281
  }
307
282
 
308
283
  /**
@@ -310,7 +285,7 @@ export default class VehicleSpecific {
310
285
  * @param level Heating level
311
286
  */
312
287
  async remote_steering_wheel_heat_level_request(level: Level): Promise<CommandResponse> {
313
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/remote_steering_wheel_heat_level_request`, null, { level });
288
+ return this.parent.remote_steering_wheel_heat_level_request(this.vin, level);
314
289
  }
315
290
 
316
291
  /**
@@ -318,21 +293,21 @@ export default class VehicleSpecific {
318
293
  * @param on `true` or `false`
319
294
  */
320
295
  async remote_steering_wheel_heater_request(on: boolean): Promise<CommandResponse> {
321
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/remote_steering_wheel_heater_request`, null, { on });
296
+ return this.parent.remote_steering_wheel_heater_request(this.vin, on);
322
297
  }
323
298
 
324
299
  /**
325
300
  * Removes PIN to Drive. Requires the car to be in Pin to Drive mode and not in Valet mode. Note that this only works if PIN to Drive is not active. This command also requires the Tesla Vehicle Command Protocol - for more information, please see refer to the documentation here.
326
301
  */
327
302
  async reset_pin_to_drive_pin(): Promise<CommandResponse> {
328
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/reset_pin_to_drive_pin`);
303
+ return this.parent.reset_pin_to_drive_pin(this.vin);
329
304
  }
330
305
 
331
306
  /**
332
307
  * Removes PIN for Valet Mode.
333
308
  */
334
309
  async reset_valet_pin(): Promise<CommandResponse> {
335
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/reset_valet_pin`);
310
+ return this.parent.reset_valet_pin(this.vin);
336
311
  }
337
312
 
338
313
  /**
@@ -340,7 +315,7 @@ export default class VehicleSpecific {
340
315
  * @param offset_sec Offset in seconds
341
316
  */
342
317
  async schedule_software_update(offset_sec: number): Promise<CommandResponse> {
343
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/schedule_software_update`, null, { offset_sec });
318
+ return this.parent.schedule_software_update(this.vin, offset_sec);
344
319
  }
345
320
 
346
321
  /**
@@ -349,7 +324,7 @@ export default class VehicleSpecific {
349
324
  * @param manual_override `true` or `false`
350
325
  */
351
326
  async set_bioweapon_mode(on: boolean, manual_override: boolean): Promise<CommandResponse> {
352
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_bioweapon_mode`, null, { on, manual_override });
327
+ return this.parent.set_bioweapon_mode(this.vin, on, manual_override);
353
328
  }
354
329
 
355
330
  /**
@@ -358,7 +333,7 @@ export default class VehicleSpecific {
358
333
  * @param fan_only `true` or `false`
359
334
  */
360
335
  async set_cabin_overheat_protection(on: boolean, fan_only: boolean): Promise<CommandResponse> {
361
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_cabin_overheat_protection`, null, { on, fan_only });
336
+ return this.parent.set_cabin_overheat_protection(this.vin, on, fan_only);
362
337
  }
363
338
 
364
339
  /**
@@ -366,7 +341,7 @@ export default class VehicleSpecific {
366
341
  * @param percent Charge limit percentage typically between 50-100
367
342
  */
368
343
  async set_charge_limit(percent: number): Promise<CommandResponse> {
369
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_charge_limit`, null, { percent });
344
+ return this.parent.set_charge_limit(this.vin, percent);
370
345
  }
371
346
 
372
347
  /**
@@ -374,7 +349,7 @@ export default class VehicleSpecific {
374
349
  * @param percent Current limit in Amps typically between 5-32
375
350
  */
376
351
  async set_charging_amps(charging_amps: number): Promise<CommandResponse> {
377
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_charging_amps`, null, { charging_amps });
352
+ return this.parent.set_charging_amps(this.vin, charging_amps);
378
353
  }
379
354
 
380
355
  /**
@@ -382,10 +357,7 @@ export default class VehicleSpecific {
382
357
  * @param climate_keeper_mode `0` is Off, `1` is Keep, `2` is Dog, `3` is Camp
383
358
  */
384
359
  async set_climate_keeper_mode(climate_keeper_mode: number | ClimateMode): Promise<CommandResponse> {
385
- if (typeof climate_keeper_mode === "string") {
386
- climate_keeper_mode = ClimateModes[climate_keeper_mode];
387
- }
388
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_climate_keeper_mode`, null, { climate_keeper_mode });
360
+ return this.parent.set_climate_keeper_mode(this.vin, climate_keeper_mode);
389
361
  }
390
362
 
391
363
  /**
@@ -393,13 +365,7 @@ export default class VehicleSpecific {
393
365
  * @param cop_temp Integer representing Low (0/30C/90F), Medium (1/35C/95F), or High (2/40C/100F)
394
366
  */
395
367
  async set_cop_temp(cop_temp: 0 | 1 | 2 | 30 | 35 | 40 | 90 | 95 | 100): Promise<CommandResponse> {
396
- if (cop_temp >= 90) {
397
- cop_temp = (cop_temp - 90) / 5;
398
- } else if (cop_temp >= 30) {
399
- cop_temp = (cop_temp - 30) / 5;
400
- }
401
-
402
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_cop_temp`, null, { cop_temp });
368
+ return this.parent.set_cop_temp(this.vin, cop_temp);
403
369
  }
404
370
 
405
371
  /**
@@ -408,7 +374,7 @@ export default class VehicleSpecific {
408
374
  * @param password Four-digit passcode
409
375
  */
410
376
  async set_pin_to_drive(on: boolean, password: string | number): Promise<CommandResponse> {
411
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_pin_to_drive`, null, { on, password: String(password) });
377
+ return this.parent.set_pin_to_drive(this.vin, on, password);
412
378
  }
413
379
 
414
380
  /**
@@ -418,7 +384,7 @@ export default class VehicleSpecific {
418
384
  * @param manual_override `true` or `false`
419
385
  */
420
386
  async set_preconditioning_max(on: boolean, manual_override: boolean): Promise<CommandResponse> {
421
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_preconditioning_max`, null, { on, manual_override });
387
+ return this.parent.set_preconditioning_max(this.vin, on, manual_override);
422
388
  }
423
389
 
424
390
  /**
@@ -427,7 +393,7 @@ export default class VehicleSpecific {
427
393
  * @param time Minutes after midnight
428
394
  */
429
395
  async set_scheduled_charging(enable: boolean, time: number): Promise<CommandResponse> {
430
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_scheduled_charging`, null, { enable, time });
396
+ return this.parent.set_scheduled_charging(this.vin, enable, time);
431
397
  }
432
398
 
433
399
  /**
@@ -449,15 +415,16 @@ export default class VehicleSpecific {
449
415
  off_peak_charging_weekdays_only: boolean = false,
450
416
  end_off_peak_time: number = 0
451
417
  ): Promise<CommandResponse> {
452
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_scheduled_departure`, null, {
418
+ return this.parent.set_scheduled_departure(
419
+ this.vin,
453
420
  enable,
454
421
  preconditioning_enabled,
455
422
  preconditioning_weekdays_only,
456
423
  departure_time,
457
424
  off_peak_charging_enabled,
458
425
  off_peak_charging_weekdays_only,
459
- end_off_peak_time,
460
- });
426
+ end_off_peak_time
427
+ );
461
428
  }
462
429
 
463
430
  /**
@@ -465,7 +432,7 @@ export default class VehicleSpecific {
465
432
  * @param on `true` or `false`
466
433
  */
467
434
  async set_sentry_mode(on: boolean): Promise<CommandResponse> {
468
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_sentry_mode`, null, { on });
435
+ return this.parent.set_sentry_mode(this.vin, on);
469
436
  }
470
437
 
471
438
  /**
@@ -474,7 +441,7 @@ export default class VehicleSpecific {
474
441
  * @param passenger_temp Passenger temperature
475
442
  */
476
443
  async set_temps(driver_temp: number, passenger_temp: number): Promise<CommandResponse> {
477
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_temps`, null, { driver_temp, passenger_temp });
444
+ return this.parent.set_temps(this.vin, driver_temp, passenger_temp);
478
445
  }
479
446
 
480
447
  /**
@@ -483,7 +450,7 @@ export default class VehicleSpecific {
483
450
  * @param password Four-digit passcode
484
451
  */
485
452
  async set_valet_mode(on: boolean, password: string | number): Promise<CommandResponse> {
486
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_valet_mode`, null, { on, password: String(password) });
453
+ return this.parent.set_valet_mode(this.vin, on, password);
487
454
  }
488
455
 
489
456
  /**
@@ -491,7 +458,7 @@ export default class VehicleSpecific {
491
458
  * @param vehicle_name New name
492
459
  */
493
460
  async set_vehicle_name(vehicle_name: string): Promise<CommandResponse> {
494
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/set_vehicle_name`, null, { vehicle_name });
461
+ return this.parent.set_vehicle_name(this.vin, vehicle_name);
495
462
  }
496
463
 
497
464
  /**
@@ -499,7 +466,7 @@ export default class VehicleSpecific {
499
466
  * @param pin Four-digit PIN
500
467
  */
501
468
  async speed_limit_activate(pin: string | number): Promise<CommandResponse> {
502
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/speed_limit_activate`, null, { pin: String(pin) });
469
+ return this.parent.speed_limit_activate(this.vin, pin);
503
470
  }
504
471
 
505
472
  /**
@@ -507,14 +474,14 @@ export default class VehicleSpecific {
507
474
  * @param pin Four-digit PIN
508
475
  */
509
476
  async speed_limit_clear_pin(pin: string | number): Promise<CommandResponse> {
510
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/speed_limit_clear_pin`, null, { pin: String(pin) });
477
+ return this.parent.speed_limit_clear_pin(this.vin, pin);
511
478
  }
512
479
 
513
480
  /**
514
481
  * Deactivates Speed Limit Mode and resets the associated PIN for vehicles running firmware versions 2023.38+. This command is only accessible to fleet managers or owners.
515
482
  */
516
483
  async speed_limit_clear_pin_admin(): Promise<CommandResponse> {
517
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/speed_limit_clear_pin_admin`);
484
+ return this.parent.speed_limit_clear_pin_admin(this.vin);
518
485
  }
519
486
 
520
487
  /**
@@ -522,7 +489,7 @@ export default class VehicleSpecific {
522
489
  * @param pin Four-digit PIN
523
490
  */
524
491
  async speed_limit_deactivate(pin: string | number): Promise<CommandResponse> {
525
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/speed_limit_deactivate`, null, { pin: String(pin) });
492
+ return this.parent.speed_limit_deactivate(this.vin, pin);
526
493
  }
527
494
 
528
495
  /**
@@ -530,7 +497,7 @@ export default class VehicleSpecific {
530
497
  * @param limit_mph Maximum speed in MPH
531
498
  */
532
499
  async speed_limit_set_limit(limit_mph: number): Promise<CommandResponse> {
533
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/speed_limit_set_limit`, null, { limit_mph });
500
+ return this.parent.speed_limit_set_limit(this.vin, limit_mph);
534
501
  }
535
502
 
536
503
  /**
@@ -538,7 +505,7 @@ export default class VehicleSpecific {
538
505
  * @param state "stop", "close" or "vent"
539
506
  */
540
507
  async sun_roof_control(state: "stop" | "close" | "vent"): Promise<CommandResponse> {
541
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/sun_roof_control`, null, { state });
508
+ return this.parent.sun_roof_control(this.vin, state);
542
509
  }
543
510
 
544
511
  /**
@@ -546,7 +513,7 @@ export default class VehicleSpecific {
546
513
  * @param note Drive note
547
514
  */
548
515
  async take_drivenote(note: string): Promise<CommandResponse> {
549
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/take_drivenote`, null, { note });
516
+ return this.parent.take_drivenote(this.vin, note);
550
517
  }
551
518
 
552
519
  /**
@@ -556,7 +523,7 @@ export default class VehicleSpecific {
556
523
  * @param lon Longitude
557
524
  */
558
525
  async trigger_homelink(lat: number, lon: number, token?: string): Promise<CommandResponse> {
559
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/trigger_homelink`, null, { token, lat, lon });
526
+ return this.parent.trigger_homelink(this.vin, lat, lon, token);
560
527
  }
561
528
 
562
529
  /**
@@ -564,7 +531,7 @@ export default class VehicleSpecific {
564
531
  * @param calendar_data Calendar data
565
532
  */
566
533
  async upcoming_calendar_entries(calendar_data: string): Promise<CommandResponse> {
567
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/upcoming_calendar_entries`, null, { calendar_data });
534
+ return this.parent.upcoming_calendar_entries(this.vin, calendar_data);
568
535
  }
569
536
 
570
537
  /**
@@ -574,7 +541,7 @@ export default class VehicleSpecific {
574
541
  * @param lon Longitude
575
542
  */
576
543
  async window_control(command: "vent" | "close", lat: number, lon: number): Promise<CommandResponse> {
577
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/command/window_control`, null, { command, lat, lon });
544
+ return this.parent.window_control(this.vin, command, lat, lon);
578
545
  }
579
546
 
580
547
  // Vehicle Endpoints
@@ -583,7 +550,7 @@ export default class VehicleSpecific {
583
550
  * Returns all allowed drivers for a vehicle. This endpoint is only available for the vehicle owner.
584
551
  */
585
552
  async drivers(): Promise<Record<string, any>> {
586
- return this.parent.parent._request("GET", `api/1/vehicles/${this.vin}/drivers`);
553
+ return this.parent.drivers(this.vin);
587
554
  }
588
555
 
589
556
  /**
@@ -591,23 +558,23 @@ export default class VehicleSpecific {
591
558
  * @param share_user_id
592
559
  */
593
560
  async drivers_remove(share_user_id?: number): Promise<Record<string, any>> {
594
- return this.parent.parent._request("DELETE", `api/1/vehicles/${this.vin}/drivers`, null, { share_user_id });
561
+ return this.parent.drivers_remove(this.vin, share_user_id);
595
562
  }
596
563
 
597
564
  /**
598
565
  * Returns eligible vehicle subscriptions.
599
566
  * @param vin Vehicle Identification Number
600
567
  */
601
- async eligible_subscriptions(vin: string): Promise<Record<string, any>> {
602
- return this.parent.parent._request("GET", "/api/1/dx/vehicles/subscriptions/eligibility", { vin });
568
+ async eligible_subscriptions(): Promise<Record<string, any>> {
569
+ return this.parent.eligible_subscriptions(this.vin);
603
570
  }
604
571
 
605
572
  /**
606
573
  * Returns eligibile vehicle upgrades.
607
574
  * @param vin Vehicle Identification Number
608
575
  */
609
- async eligible_upgrades(vin: string): Promise<Record<string, any>> {
610
- return this.parent.parent._request("GET", "/api/1/dx/vehicles/upgrades/eligibility", { vin });
576
+ async eligible_upgrades(): Promise<Record<string, any>> {
577
+ return this.parent.eligible_upgrades(this.vin);
611
578
  }
612
579
 
613
580
  /**
@@ -615,8 +582,8 @@ export default class VehicleSpecific {
615
582
  * @param vins list of Vehicle Identification Number
616
583
  * @returns
617
584
  */
618
- async fleet_status(vins: Array<String>): Promise<Record<string, any>> {
619
- return this.parent.parent._request("POST", "api/1/vehicles/fleet_status", null, { vins });
585
+ async fleet_status(): Promise<Record<string, any>> {
586
+ return this.parent.fleet_status([this.vin]);
620
587
  }
621
588
 
622
589
  /**
@@ -625,7 +592,10 @@ export default class VehicleSpecific {
625
592
  * @returns
626
593
  */
627
594
  async fleet_telemetry_config(config: FleetTelemetryConfig): Promise<Record<string, any>> {
628
- return this.parent.parent._request("POST", "api/1/vehicles/fleet_telemetry_config", null, { vins: [this.vin], config });
595
+ return this.parent.fleet_telemetry_config({
596
+ vins: [this.vin],
597
+ config,
598
+ });
629
599
  }
630
600
 
631
601
  /**
@@ -633,7 +603,7 @@ export default class VehicleSpecific {
633
603
  * @returns
634
604
  */
635
605
  async fleet_telemetry_config_delete(): Promise<Record<string, any>> {
636
- return this.parent.parent._request("DELETE", `api/1/vehicles/${this.vin}/fleet_telemetry_config`);
606
+ return this.parent.fleet_telemetry_config_delete(this.vin);
637
607
  }
638
608
 
639
609
  /**
@@ -641,23 +611,14 @@ export default class VehicleSpecific {
641
611
  * @returns
642
612
  */
643
613
  async fleet_telemetry_config_get(): Promise<Record<string, any>> {
644
- return this.parent.parent._request("GET", `api/1/vehicles/${this.vin}/fleet_telemetry_config`);
645
- }
646
-
647
- /**
648
- * Create a Vehicle class for a specific vehicle.
649
- * @param page Page number
650
- * @param per_page Number of items per page
651
- */
652
- async list(page?: number, per_page?: number): Promise<Record<string, any>> {
653
- return this.parent.parent._request("GET", "api/1/vehicles", { page, per_page });
614
+ return this.parent.fleet_telemetry_config_get(this.vin);
654
615
  }
655
616
 
656
617
  /**
657
618
  * Returns whether or not mobile access is enabled for the vehicle.
658
619
  */
659
620
  async mobile_enabled(): Promise<Record<string, any>> {
660
- return this.parent.parent._request("GET", `api/1/vehicles/${this.vin}/mobile_enabled`);
621
+ return this.parent.mobile_enabled(this.vin);
661
622
  }
662
623
 
663
624
  /**
@@ -667,7 +628,7 @@ export default class VehicleSpecific {
667
628
  * @param detail
668
629
  */
669
630
  async nearby_charging_sites(count?: number, radius?: number, detail?: boolean): Promise<Record<string, any>> {
670
- return this.parent.parent._request("GET", `api/1/vehicles/${this.vin}/nearby_charging_sites`, { count, radius, detail });
631
+ return this.parent.nearby_charging_sites(this.vin, count, radius, detail);
671
632
  }
672
633
 
673
634
  /**
@@ -675,14 +636,14 @@ export default class VehicleSpecific {
675
636
  * @param vin Vehicle Identification Number
676
637
  */
677
638
  async options(vin: string): Promise<Record<string, any>> {
678
- return this.parent.parent._request("GET", "api/1/dx/vehicles/options", { vin });
639
+ return this.parent.options(this.vin);
679
640
  }
680
641
 
681
642
  /**
682
643
  * List of recent alerts
683
644
  */
684
645
  async recent_alerts(): Promise<Record<string, any>> {
685
- return this.parent.parent._request("GET", `api/1/vehicles/${this.vin}/recent_alerts`);
646
+ return this.parent.recent_alerts(this.vin);
686
647
  }
687
648
 
688
649
  /**
@@ -692,36 +653,28 @@ export default class VehicleSpecific {
692
653
  */
693
654
 
694
655
  async release_notes(staged?: boolean, language?: string): Promise<Record<string, any>> {
695
- return this.parent.parent._request("GET", `api/1/vehicles/${this.vin}/release_notes`, { staged, language });
656
+ return this.parent.release_notes(this.vin, staged, language);
696
657
  }
697
658
 
698
659
  /**
699
660
  * Returns service data.
700
661
  */
701
662
  async service_data(): Promise<Record<string, any>> {
702
- return this.parent.parent._request("GET", `api/1/vehicles/${this.vin}/service_data`);
663
+ return this.parent.service_data(this.vin);
703
664
  }
704
665
 
705
666
  /**
706
667
  * Returns the share invites for a vehicle.
707
668
  */
708
669
  async share_invites(): Promise<Record<string, any>> {
709
- return this.parent.parent._request("GET", `api/1/vehicles/${this.vin}/invitations`);
670
+ return this.parent.share_invites(this.vin);
710
671
  }
711
672
 
712
673
  /**
713
674
  * Creates a share invite for a vehicle.
714
675
  */
715
676
  async share_invites_create(): Promise<Record<string, any>> {
716
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/invitations`);
717
- }
718
-
719
- /**
720
- * Redeems a share invite.
721
- * @param code
722
- */
723
- async share_invites_redeem(code: string): Promise<Record<string, any>> {
724
- return this.parent.parent._request("POST", "api/1/invitations/redeem", { code });
677
+ return this.parent.share_invites_create(this.vin);
725
678
  }
726
679
 
727
680
  /**
@@ -729,7 +682,7 @@ export default class VehicleSpecific {
729
682
  * @param id
730
683
  */
731
684
  async share_invites_revoke(id: string): Promise<Record<string, any>> {
732
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/invitations/${id}/revoke`);
685
+ return this.parent.share_invites_revoke(this.vin, id);
733
686
  }
734
687
 
735
688
  /**
@@ -737,14 +690,14 @@ export default class VehicleSpecific {
737
690
  * @param routable_message
738
691
  */
739
692
  async signed_command(routable_message: string): Promise<Record<string, any>> {
740
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/signed_command`, null, { routable_message });
693
+ return this.parent.signed_command(this.vin, routable_message);
741
694
  }
742
695
 
743
696
  /**
744
697
  * Returns information about a vehicle.
745
698
  */
746
699
  async vehicle(): Promise<Record<string, any>> {
747
- return this.parent.parent._request("GET", `api/1/vehicles/${this.vin}`);
700
+ return this.parent.vehicle(this.vin);
748
701
  }
749
702
 
750
703
  /**
@@ -752,22 +705,21 @@ export default class VehicleSpecific {
752
705
  * @param endpoints
753
706
  */
754
707
  async vehicle_data(endpoints?: VehicleDataEndpoint[] | string): Promise<Record<string, any>> {
755
- if (typeof endpoints === "object") endpoints = endpoints.join(";");
756
- return this.parent.parent._request("GET", `api/1/vehicles/${this.vin}/vehicle_data`, null, { endpoints });
708
+ return this.parent.vehicle_data(this.vin, endpoints);
757
709
  }
758
710
 
759
711
  /**
760
712
  * Wakes the vehicle from sleep, which is a state to minimize idle energy consumption.
761
713
  */
762
714
  async wake_up(): Promise<Record<string, any>> {
763
- return this.parent.parent._request("POST", `api/1/vehicles/${this.vin}/wake_up`);
715
+ return this.parent.wake_up(this.vin);
764
716
  }
765
717
 
766
718
  /**
767
719
  * Returns warranty details.
768
720
  * @param vin
769
721
  */
770
- async warranty_details(vin: string): Promise<Record<string, any>> {
771
- return this.parent.parent._request("GET", "api/1/dx/warranty/details", { vin });
722
+ async warranty_details(): Promise<Record<string, any>> {
723
+ return this.parent.warranty_details(this.vin);
772
724
  }
773
725
  }