-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathguisettings.go
37 lines (30 loc) · 1 KB
/
guisettings.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
package tesla
import (
"fmt"
"net/http"
)
// GUISettings represents the configured settings in the vehicle GUI.
type GUISettings struct {
GUI24HourTime bool `json:"gui_24_hour_time"`
GUIChargeRateUnits string `json:"gui_charge_rate_units"`
GUIDistanceUnits string `json:"gui_distance_units"`
GUIRangeDisplay string `json:"gui_range_display"`
GUITemperatureUnits string `json:"gui_temperature_units"`
ShowRangeUnits bool `json:"show_range_units"`
Timestamp int64 `json:"timestamp"`
}
// GetGUISettings retrieves the current GUI settings for the vehicle.
func (c *Conn) GetGUISettings(id int) (*GUISettings, error) {
if c.accessToken == "" {
return nil, fmt.Errorf("%w", ErrMissingAccessToken)
}
type response struct {
Response GUISettings `json:"response"`
}
var respBody response
err := c.doRequest(http.MethodGet, fmt.Sprintf("/api/1/vehicles/%d/data_request/gui_settings", id), nil, &respBody)
if err != nil {
return nil, err
}
return &respBody.Response, nil
}