-
Notifications
You must be signed in to change notification settings - Fork 1
/
vehicle.go
60 lines (49 loc) · 1.94 KB
/
vehicle.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
55
56
57
58
59
60
package mercedes
import "context"
type ConnectedVehicle struct {
VehicleID string
client *ConnectedVehicleClient
}
func (v *ConnectedVehicle) GetVehicleDetail(ctx context.Context) (VehicleDetail, error) {
var detail VehicleDetail
ret := v.client.getJson(ctx, "/vehicles/"+v.VehicleID, &detail)
return detail, ret
}
func (v *ConnectedVehicle) GetTirePressure(ctx context.Context) (Tires, error) {
var tires Tires
ret := v.client.getJson(ctx, "/vehicles/"+v.VehicleID+"/tires", &tires)
return tires, ret
}
func (v *ConnectedVehicle) GetDoorStatus(ctx context.Context) (Doors, error) {
var doors Doors
ret := v.client.getJson(ctx, "/vehicles/"+v.VehicleID+"/doors", &doors)
return doors, ret
}
func (v *ConnectedVehicle) LockDoors(ctx context.Context) error {
cmd := DoorLockChangeRequestBody{Command: Lock}
return v.client.postJson(ctx, "/vehicles/"+v.VehicleID+"/doors", &cmd)
}
func (v *ConnectedVehicle) UnlockDoors(ctx context.Context) error {
cmd := DoorLockChangeRequestBody{Command: Unlock}
return v.client.postJson(ctx, "/vehicles/"+v.VehicleID+"/doors", &cmd)
}
func (v *ConnectedVehicle) GetLocation(ctx context.Context) (Location, error) {
var location Location
ret := v.client.getJson(ctx, "/vehicles/"+v.VehicleID+"/location", &location)
return location, ret
}
func (v *ConnectedVehicle) GetDistanceDriven(ctx context.Context) (DistanceDrivenResponse, error) {
var response DistanceDrivenResponse
ret := v.client.getJson(ctx, "/vehicles/"+v.VehicleID+"/odometer", &response)
return response, ret
}
func (v *ConnectedVehicle) GetFuelLevel(ctx context.Context) (FuelLevelResponse, error) {
var level FuelLevelResponse
ret := v.client.getJson(ctx, "/vehicles/"+v.VehicleID+"/fuel", &level)
return level, ret
}
func (v *ConnectedVehicle) GetStateOfCharge(ctx context.Context) (StateOfChargeResponse, error) {
var state StateOfChargeResponse
ret := v.client.getJson(ctx, "/vehicles/"+v.VehicleID+"/stateofcharge", &state)
return state, ret
}