mercedes-byocar-exporter/internal/mercedes/fuel_status.go
2022-11-20 00:47:49 +01:00

27 lines
582 B
Go

package mercedes
import (
"fmt"
"github.com/pkg/errors"
)
type (
FuelStatus struct {
RangeLiquid TimedInt `apiField:"rangeliquid"` // Liquid fuel tank range 0..2046 km
TanklevelPercent TimedInt `apiField:"tanklevelpercent"` // Liquid fuel tank level 0…100 %
}
)
func (a APIClient) GetFuelStatus(vehicleID string) (FuelStatus, error) {
var (
path = fmt.Sprintf("/vehicles/%s/containers/fuelstatus", vehicleID)
out FuelStatus
)
if err := a.request(path, &out); err != nil {
return out, errors.Wrap(err, "getting fuel status")
}
return out, nil
}