Skip to content

Commit 29004ad

Browse files
committed
feat: add VehicleCompatibility proto
1 parent 7dd9b39 commit 29004ad

5 files changed

Lines changed: 443 additions & 23 deletions

File tree

cli/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func newGetVehicleCompatibilityCommand(cfg *config) *cobra.Command {
308308
if err != nil {
309309
return err
310310
}
311-
printJSON(response)
311+
fmt.Println(protojson.Format(response))
312312
return nil
313313
}
314314
return cmd

client_vehicles_compatibility.go

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"net/url"
1111

1212
"github.com/way-platform/mbz-go/api/vehiclesv1"
13+
mbzv1 "github.com/way-platform/mbz-go/proto/gen/go/wayplatform/connect/mbz/v1"
1314
)
1415

1516
// GetVehicleCompatibilityRequest is the request for [Client.GetVehicleCompatibility].
@@ -18,27 +19,12 @@ type GetVehicleCompatibilityRequest struct {
1819
VIN string `json:"vin"`
1920
}
2021

21-
// GetVehicleCompatibilityResponse is the response for [Client.GetVehicleCompatibility].
22-
type GetVehicleCompatibilityResponse struct {
23-
// VIN of the requested vehicle.
24-
VIN string `json:"vin"`
25-
26-
// VehicleType is the type of the requested vehicle.
27-
VehicleType string `json:"vehicleType,omitempty"`
28-
29-
// VehicleProvidesConnectivity indicates the base compatibility to data-services for the requested vehicle.
30-
VehicleProvidesConnectivity bool `json:"vehicleProvidesConnectivity"`
31-
32-
// Services with the service availability.
33-
Services []vehiclesv1.CompatibilityGenericService `json:"services"`
34-
}
35-
3622
// GetVehicleCompatibility gets the compatibility of a vehicle.
3723
func (c *Client) GetVehicleCompatibility(
3824
ctx context.Context,
3925
request *GetVehicleCompatibilityRequest,
4026
opts ...ClientOption,
41-
) (_ *GetVehicleCompatibilityResponse, err error) {
27+
) (_ *mbzv1.VehicleCompatibility, err error) {
4228
defer func() {
4329
if err != nil {
4430
err = fmt.Errorf("mbz: get vehicle compatibility: %w", err)
@@ -79,10 +65,5 @@ func (c *Client) GetVehicleCompatibility(
7965
if err := json.Unmarshal(data, &responseBody); err != nil {
8066
return nil, err
8167
}
82-
return &GetVehicleCompatibilityResponse{
83-
VIN: responseBody.VIN,
84-
VehicleType: responseBody.VehicleType,
85-
VehicleProvidesConnectivity: responseBody.VehicleProvidesConnectivity,
86-
Services: responseBody.Services,
87-
}, nil
68+
return compatibilityResponseToProto(request.VIN, &responseBody), nil
8869
}

0 commit comments

Comments
 (0)