Skip to content

way-platform/mbz-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mercedes-Benz Go

PkgGoDev GoReportCard CI

A Go SDK and CLI tool for the Mercedes-Benz Connect Your Fleet APIs, and Vehicle Specification APIs.

SDK

Features

Installing

$ go get github.com/way-platform/mbz-go

Using

ctx := context.Background()
// Create a Mercedes-Benz API client.
client, err := mbz.NewClient(
    ctx,
    mbz.WithRegion(mbz.RegionECE),
    mbz.WithClientID(os.Getenv("MBZ_CLIENT_ID")),
    mbz.WithClientSecret(os.Getenv("MBZ_CLIENT_SECRET")),
)
if err != nil {
    panic(err)
}
// List vehicles in the account.
response, err := client.ListVehicles(ctx, &mbz.ListVehiclesRequest{})
if err != nil {
    panic(err)
}
for _, vehicle := range response.Vehicles {
    fmt.Println(vehicle.VIN)
}
// For all available methods, see the API documentation.

Developing

Building

The project is built using Mage, see tools/magefile.go and the tools/mage helper script.

$ ./tools/mage build

For all available build tasks, see:

$ ./tools/mage -l

CLI tool

The mbz CLI tool enables interaction with the APIs from the command line.

Installing

go install github.com/way-platform/mbz-go/cmd/mbz@latest

Prebuilt binaries for Linux, Windows, and Mac are available from the Releases.

Kafka Consumer

The CLI tool has a simple Kafka consumer that can read from a Push API Kafka topic.

$ mbz consume-vehicle-signals --consumer-group $MBZ_CONSUMER_GROUP --topic $MBZ_TOPIC
{
  "messageId": "54979700-c5c3-44ff-9ffa-5e961d7da84b",
  "vin": "S0FTCARMB00000001",
  "timestamp": 1753362541271,
  "messageType": "vehiclesignal",
  "version": "1.0",
  "serviceId": "1003",
  "sendingBehaviour": "ON_CHANGE",
  "data": {
    "signals": [
      {
        "name": "Driving.Range.Fuel.Warning",
        "timestamp": 1753362541025,
        "value": "false",
        "type": "boolean"
      },
      {
        "name": "Tank.Fuel.Level.Absolute",
        "timestamp": 1753362541025,
        "value": "36",
        "type": "integer"
      },
      {
        "name": "Tank.Fuel.Level.Warning",
        "timestamp": 1753362541025,
        "value": "false",
        "type": "boolean"
      }
    ]
  }
}

License

This SDK is published under the MIT License.

Security

Security researchers, see the Security Policy.

Code of Conduct

Be nice. For more info, see the Code of Conduct.