mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-14 12:04:41 +00:00
Fix panic in vehicle service (#226)
* fix panic * Commit from GitHub Actions (Publish APIs & Clients) Co-authored-by: domwong <domwong@users.noreply.github.com>
This commit is contained in:
@@ -65,5 +65,5 @@
|
||||
},
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"version": "1.0.542"
|
||||
"version": "1.0.543"
|
||||
}
|
||||
@@ -11,10 +11,10 @@ func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
},
|
||||
Table: "users",
|
||||
})
|
||||
|
||||
@@ -11,9 +11,9 @@ func PublishAmessage() {
|
||||
streamService := stream.NewStreamService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := streamService.Publish(&stream.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
},
|
||||
Topic: "events",
|
||||
})
|
||||
|
||||
@@ -3,9 +3,9 @@ package handler
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/micro/services/pkg/api"
|
||||
"github.com/micro/micro/v3/service/errors"
|
||||
"github.com/micro/micro/v3/service/logger"
|
||||
"github.com/micro/services/pkg/api"
|
||||
pb "github.com/micro/services/vehicle/proto"
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ var (
|
||||
apiURL = "https://driver-vehicle-licensing.api.gov.uk/vehicle-enquiry/v1/vehicles"
|
||||
)
|
||||
|
||||
type Vehicle struct{
|
||||
type Vehicle struct {
|
||||
Key string
|
||||
}
|
||||
|
||||
@@ -39,26 +39,27 @@ func (v *Vehicle) Lookup(ctx context.Context, req *pb.LookupRequest, rsp *pb.Loo
|
||||
return errors.InternalServerError("vehicle.lookup", "Failed to lookup vehicle")
|
||||
}
|
||||
|
||||
rsp.Registration = resp["registrationNumber"].(string)
|
||||
rsp.Make = resp["make"].(string)
|
||||
rsp.Co2Emissions = resp["co2Emissions"].(float64)
|
||||
rsp.Colour = resp["colour"].(string)
|
||||
rsp.YearOfManufacture = int32(resp["yearOfManufacture"].(float64))
|
||||
rsp.EngineCapacity = int32(resp["engineCapacity"].(float64))
|
||||
rsp.FuelType = resp["fuelType"].(string)
|
||||
rsp.MonthOfFirstRegistration = resp["monthOfFirstRegistration"].(string)
|
||||
rsp.MotStatus = resp["motStatus"].(string)
|
||||
rsp.Registration, _ = resp["registrationNumber"].(string)
|
||||
rsp.Make, _ = resp["make"].(string)
|
||||
rsp.Co2Emissions, _ = resp["co2Emissions"].(float64)
|
||||
rsp.Colour, _ = resp["colour"].(string)
|
||||
yom, _ := resp["yearOfManufacture"].(float64)
|
||||
rsp.YearOfManufacture = int32(yom)
|
||||
ec, _ := resp["engineCapacity"].(float64)
|
||||
rsp.EngineCapacity = int32(ec)
|
||||
rsp.FuelType, _ = resp["fuelType"].(string)
|
||||
rsp.MonthOfFirstRegistration, _ = resp["monthOfFirstRegistration"].(string)
|
||||
rsp.MotStatus, _ = resp["motStatus"].(string)
|
||||
|
||||
if v := resp["motExpiryDate"]; v != nil {
|
||||
rsp.MotExpiry = v.(string)
|
||||
rsp.MotExpiry, _ = v.(string)
|
||||
}
|
||||
|
||||
rsp.TaxDueDate = resp["taxDueDate"].(string)
|
||||
rsp.TaxStatus = resp["taxStatus"].(string)
|
||||
rsp.TypeApproval = resp["typeApproval"].(string)
|
||||
rsp.Wheelplan = resp["wheelplan"].(string)
|
||||
rsp.LastV5Issued = resp["dateOfLastV5CIssued"].(string)
|
||||
rsp.TaxDueDate, _ = resp["taxDueDate"].(string)
|
||||
rsp.TaxStatus, _ = resp["taxStatus"].(string)
|
||||
rsp.TypeApproval, _ = resp["typeApproval"].(string)
|
||||
rsp.Wheelplan, _ = resp["wheelplan"].(string)
|
||||
rsp.LastV5Issued, _ = resp["dateOfLastV5CIssued"].(string)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user