@@ -32,19 +32,21 @@ type VINDecodingService interface {
3232}
3333
3434type vinDecodingService struct {
35+ logger * zerolog.Logger
3536 drivlyAPISvc gateways.DrivlyAPIService
3637 vincarioAPISvc gateways.VincarioAPIService
37- logger * zerolog.Logger
3838 autoIsoAPIService gateways.AutoIsoAPIService
3939 DATGroupAPIService gateways.DATGroupAPIService
40+ japan17VINAPI gateways.Japan17VINAPI
4041 onChainSvc gateways.DeviceDefinitionOnChainService
4142 dbs func () * db.ReaderWriter
4243}
4344
4445func NewVINDecodingService (drivlyAPISvc gateways.DrivlyAPIService , vincarioAPISvc gateways.VincarioAPIService , autoIso gateways.AutoIsoAPIService , logger * zerolog.Logger ,
45- onChainSvc gateways.DeviceDefinitionOnChainService , datGroupAPIService gateways.DATGroupAPIService , dbs func () * db.ReaderWriter ) VINDecodingService {
46- return & vinDecodingService {drivlyAPISvc : drivlyAPISvc , vincarioAPISvc : vincarioAPISvc , autoIsoAPIService : autoIso , logger : logger ,
47- onChainSvc : onChainSvc , DATGroupAPIService : datGroupAPIService , dbs : dbs }
46+ onChainSvc gateways.DeviceDefinitionOnChainService , datGroupAPIService gateways.DATGroupAPIService , dbs func () * db.ReaderWriter ,
47+ japan17VINAPI gateways.Japan17VINAPI ) VINDecodingService {
48+ return & vinDecodingService {drivlyAPISvc : drivlyAPISvc , vincarioAPISvc : vincarioAPISvc , autoIsoAPIService : autoIso ,
49+ japan17VINAPI : japan17VINAPI , logger : logger , onChainSvc : onChainSvc , DATGroupAPIService : datGroupAPIService , dbs : dbs }
4850}
4951
5052func (c vinDecodingService ) GetVIN (ctx context.Context , vin string , dt * repoModel.DeviceType , provider coremodels.DecodeProviderEnum , country string ) (* coremodels.VINDecodingInfoData , error ) {
@@ -53,7 +55,10 @@ func (c vinDecodingService) GetVIN(ctx context.Context, vin string, dt *repoMode
5355
5456 result := & coremodels.VINDecodingInfoData {}
5557 vin = strings .ToUpper (strings .TrimSpace (vin ))
56- if ! ValidateVIN (vin ) {
58+ // check for japan chasis
59+ if (len (vin ) < 17 && len (vin ) > 10 ) || country == "JPN" {
60+ provider = coremodels .Japan17VIN
61+ } else if ! ValidateVIN (vin ) {
5762 return nil , fmt .Errorf ("invalid vin: %s" , vin )
5863 }
5964
@@ -105,6 +110,20 @@ func (c vinDecodingService) GetVIN(ctx context.Context, vin string, dt *repoMode
105110 if err != nil {
106111 return nil , err
107112 }
113+ case coremodels .Japan17VIN :
114+ mmy , raw , err := c .japan17VINAPI .GetVINInfo (vin )
115+ if err != nil {
116+ return nil , errors .Wrapf (err , "unable to decode vin: %s with japan17vin" , vin )
117+ }
118+ result = & coremodels.VINDecodingInfoData {
119+ VIN : vin ,
120+ Make : mmy .ManufacturerName ,
121+ Model : mmy .ModelName ,
122+ Year : int32 (mmy .Year ),
123+ Source : coremodels .Japan17VIN ,
124+ MetaData : null .JSONFrom (raw ),
125+ Raw : raw ,
126+ }
108127 case coremodels .AutoIsoProvider :
109128 vinAutoIsoInfo , err := c .autoIsoAPIService .GetVIN (vin )
110129 if err != nil {
0 commit comments