@@ -72,87 +72,5 @@ func (c *Client) GetVehicleSpecification(
7272 if err := json .Unmarshal (responseData , & openAPIResp ); err != nil {
7373 return nil , err
7474 }
75- return vehicleSpecificationToProto (& openAPIResp ), nil
76- }
77-
78- func vehicleSpecificationToProto (
79- openAPIResp * vehiclespecificationfleetv1.VehicleSpecificationResponse ,
80- ) * mbzv1.VehicleSpecification {
81- if openAPIResp == nil || openAPIResp .VehicleData == nil {
82- return & mbzv1.VehicleSpecification {}
83- }
84- vehicleData := openAPIResp .VehicleData
85- protoSpec := & mbzv1.VehicleSpecification {}
86- // Use Model field first (contains "Sprinter" in example), fall back to ModelName if Model is empty
87- if vehicleData .Model != "" {
88- protoSpec .SetModelName (vehicleData .Model )
89- } else if vehicleData .ModelName != "" {
90- protoSpec .SetModelName (vehicleData .ModelName )
91- }
92- if vehicleData .ModelYear != "" {
93- protoSpec .SetModelYear (vehicleData .ModelYear )
94- }
95- if vehicleData .Brand != nil && vehicleData .Brand .Text != "" {
96- protoSpec .SetBrand (vehicleData .Brand .Text )
97- }
98- if vehicleData .Fuel != nil && vehicleData .Fuel .Text != "" {
99- protoSpec .SetFuelType (vehicleData .Fuel .Text )
100- }
101- if vehicleData .Emissionstandard != nil && vehicleData .Emissionstandard .Text != "" {
102- protoSpec .SetEmissionStandard (vehicleData .Emissionstandard .Text )
103- }
104- if vehicleData .Weight != nil && vehicleData .Weight .VehicleMassKg != nil && * vehicleData .Weight .VehicleMassKg > 0 {
105- protoSpec .SetVehicleMassKg (* vehicleData .Weight .VehicleMassKg )
106- }
107- if vehicleData .LongType != "" {
108- protoSpec .SetLongType (vehicleData .LongType )
109- }
110- if vehicleData .Body != nil {
111- if vehicleData .Body .Code != "" {
112- protoSpec .SetBodyCode (vehicleData .Body .Code )
113- }
114- if vehicleData .Body .Text != "" {
115- protoSpec .SetBodyText (vehicleData .Body .Text )
116- }
117- }
118- if vehicleData .Numberofdoors != nil && * vehicleData .Numberofdoors > 0 {
119- protoSpec .SetDoorCount (* vehicleData .Numberofdoors )
120- }
121- if vehicleData .Numberofseats != nil && * vehicleData .Numberofseats > 0 {
122- protoSpec .SetSeatCount (* vehicleData .Numberofseats )
123- }
124- if vehicleData .Wheelbase != nil && * vehicleData .Wheelbase > 0 {
125- protoSpec .SetWheelbaseMm (* vehicleData .Wheelbase )
126- }
127- if vehicleData .Wheelform != "" {
128- protoSpec .SetWheelForm (vehicleData .Wheelform )
129- }
130- if vehicleData .PrimaryEngine != nil {
131- if engine := parseEngine (vehicleData .PrimaryEngine ); engine != nil {
132- protoSpec .SetPrimaryEngine (engine )
133- }
134- }
135- if vehicleData .SecondaryEngine != nil {
136- if engine := parseEngine (vehicleData .SecondaryEngine ); engine != nil {
137- protoSpec .SetSecondaryEngine (engine )
138- }
139- }
140- return protoSpec
141- }
142-
143- func parseEngine (openAPIEngine * vehiclespecificationfleetv1.Engine ) * mbzv1.VehicleSpecification_Engine {
144- if openAPIEngine == nil {
145- return nil
146- }
147- protoEngine := & mbzv1.VehicleSpecification_Engine {}
148- if openAPIEngine .Battery != nil && openAPIEngine .Battery .Capacity != nil && * openAPIEngine .Battery .Capacity > 0 {
149- protoEngine .SetBatteryCapacityKwh (* openAPIEngine .Battery .Capacity )
150- }
151- if openAPIEngine .FuelTankCapacity != nil && * openAPIEngine .FuelTankCapacity > 0 {
152- protoEngine .SetFuelTankCapacityL (* openAPIEngine .FuelTankCapacity )
153- }
154- if openAPIEngine .FuelType != nil && openAPIEngine .FuelType .Text != "" {
155- protoEngine .SetFuelType (openAPIEngine .FuelType .Text )
156- }
157- return protoEngine
75+ return vehicleDataToProto (openAPIResp .VehicleData ), nil
15876}
0 commit comments