-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvehicleconfig.go
54 lines (47 loc) · 2.01 KB
/
vehicleconfig.go
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package tesla
import (
"fmt"
"net/http"
)
// VehicleConfig represents the current capabilities of the vehicle.
type VehicleConfig struct {
CanAcceptNavigationRequests bool `json:"can_accept_navigation_requests"`
CanActuateTrunks bool `json:"can_actuate_trunks"`
CarSpecialType string `json:"car_special_type"`
CarType string `json:"car_type"`
ChargePortType string `json:"charge_port_type"`
EuVehicle bool `json:"eu_vehicle"`
ExteriorColor string `json:"exterior_color"`
HasAirSuspension bool `json:"has_air_suspension"`
HasLudicrousMode bool `json:"has_ludicrous_mode"`
KeyVersion int `json:"key_version"`
MotorizedChargePort bool `json:"motorized_charge_port"`
PerfConfig string `json:"perf_config"`
Plg bool `json:"plg"`
RearSeatHeaters int `json:"rear_seat_heaters"`
RearSeatType int `json:"rear_seat_type"`
Rhd bool `json:"rhd"`
RoofColor string `json:"roof_color"`
SeatType int `json:"seat_type"`
SpoilerType string `json:"spoiler_type"`
SunRoofInstalled int `json:"sun_roof_installed"`
ThirdRowSeats string `json:"third_row_seats"`
Timestamp int64 `json:"timestamp"`
TrimBadging string `json:"trim_badging"`
WheelType string `json:"wheel_type"`
}
// GetVehicleConfig retrieves the vehicles config.
func (c *Conn) GetVehicleConfig(id int) (*VehicleConfig, error) {
if c.accessToken == "" {
return nil, fmt.Errorf("%w", ErrMissingAccessToken)
}
type response struct {
Response VehicleConfig `json:"response"`
}
var respBody response
err := c.doRequest(http.MethodGet, fmt.Sprintf("/api/1/vehicles/%d/data_request/vehicle_config", id), nil, &respBody)
if err != nil {
return nil, err
}
return &respBody.Response, nil
}