-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathelectric_vehicle_status.go
41 lines (34 loc) · 1.36 KB
/
electric_vehicle_status.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
package merche
import (
"context"
"fmt"
"net/http"
)
type ElectricVehicleStatus struct {
Soc *Resource `json:"soc,omitempty"`
RangeElectric *Resource `json:"rangeelectric,omitempty"`
}
// ElectricVehicleStatusService handles communication with electric vehicle status related
// methods of the Mercedes API.
//
// Mercedes API docs: https://developer.mercedes-benz.com/products/electric_vehicle_status/docs
type ElectricVehicleStatusService service
// GetElectricVehicleStatus gets containers resource of the Electric Vehicle Status API
// to get the values of all resources that are available for readout.
// The response contains the available resource values and the corresponding
// readout timestamp for the corresponding car.
//
// Mercedes API docs: https://developer.mercedes-benz.com/products/electric_vehicle_status/specifications/electric_vehicle_status_api
func (s *ElectricVehicleStatusService) GetElectricVehicleStatus(ctx context.Context, opts *Options) ([]*ElectricVehicleStatus, *Response, error) {
path := fmt.Sprintf("%v/%v/containers/electricvehicle", apiPathPrefix, opts.VehicleID)
req, err := s.client.NewRequest(ctx, http.MethodGet, path, http.NoBody)
if err != nil {
return nil, nil, err
}
var status []*ElectricVehicleStatus
resp, err := s.client.Do(req, &status)
if err != nil {
return nil, resp, err
}
return status, resp, nil
}