-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pay_as_you_drive.go
43 lines (35 loc) · 1.37 KB
/
pay_as_you_drive.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
package merche
import (
"context"
"fmt"
"net/http"
)
// VehicleStatus defines the response from VehicleStatus.
type PayAsYouDriveStatus struct {
Odo *Resource `json:"odo,omitempty"`
}
// PayAsYouDriveService handles communication with vehicle status related
// methods of the Mercedes API.
// The Pay As You Drive Insurance API provide odometer status.
//
// Mercedes API docs: https://developer.mercedes-benz.com/products/vehicle_status/docs
type PayAsYouDriveService service
// GetPayAsYouDriveStatus gets containers resource of the Pay as you drive 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/pay_as_you_drive_insurance/docs#_3_get_all_values_of_the_pay_as_you_drive_insurance_api
func (s *PayAsYouDriveService) GetPayAsYouDriveStatus(ctx context.Context, opts *Options) ([]*PayAsYouDriveStatus, *Response, error) {
path := fmt.Sprintf("%v/%v/containers/payasyoudrive", apiPathPrefix, opts.VehicleID)
req, err := s.client.NewRequest(ctx, http.MethodGet, path, http.NoBody)
if err != nil {
return nil, nil, err
}
var status []*PayAsYouDriveStatus
resp, err := s.client.Do(req, &status)
if err != nil {
return nil, resp, err
}
return status, resp, nil
}