Get VIN from tg bot
This commit is contained in:
parent
e79f6a398b
commit
9f4ab0f1cd
@ -56,8 +56,22 @@ class TGProvider {
|
||||
await this.tgClient.viewMessage(id, this.chat.id);
|
||||
let report = this.parseReport(text);
|
||||
|
||||
if(vin01token && report.generalInfo.vin) {
|
||||
console.log('Found vin: ', report.generalInfo.vin);
|
||||
let vin = report.generalInfo?.vin;
|
||||
if(!vin && report.insurance?.plateNumber == number && report.insurance?.vin) {
|
||||
vin = report.insurance?.vin;
|
||||
|
||||
if(report.generalInfo) {
|
||||
report.generalInfo.vin = vin;
|
||||
} else {
|
||||
report.generalInfo = {
|
||||
plateNumber: number,
|
||||
vin: vin
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if(vin01token && vin) {
|
||||
console.log('Found vin: ', vin);
|
||||
let vin01report = await Vin01Provider.getReportVin(report.generalInfo.vin, null, vin01token);
|
||||
if(vin01report.ownershipPeriods?.length > 0) {
|
||||
report.ownershipPeriods = vin01report.ownershipPeriods;
|
||||
@ -96,7 +110,7 @@ class TGProvider {
|
||||
|
||||
let generalInfo = null;
|
||||
let insurance = null;
|
||||
|
||||
|
||||
for(let item of result) {
|
||||
let block = Utils.removeNullFields(this.parseBlock(item));
|
||||
if(block.sts) {
|
||||
|
||||
@ -341,11 +341,17 @@ router.post('/checkGbTg', async (req, res) => {
|
||||
if (report?.generalInfo?.vin?.match(vinRegex)) {
|
||||
let updatedFields = {
|
||||
vin1: report.generalInfo.vin,
|
||||
color: report.generalInfo.color,
|
||||
sts: report.generalInfo.sts,
|
||||
updatedDate: Date.now(),
|
||||
};
|
||||
|
||||
if(report.generalInfo.color) {
|
||||
updatedFields.color = report.generalInfo.color;
|
||||
}
|
||||
|
||||
if(report.generalInfo.sts) {
|
||||
updatedFields.sts = report.generalInfo.sts;
|
||||
}
|
||||
|
||||
if (report.insurance) {
|
||||
let osagoFound =
|
||||
vehicle.osagoContracts?.some((elem) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user