mindee
Version:
Mindee Client Library for Node.js
81 lines (80 loc) • 2.59 kB
JavaScript
import { cleanOutString, } from "../../../v1/parsing/common/index.js";
import { DateField, StringField } from "../../../v1/parsing/standard/index.js";
/**
* Driver License API version 1.0 document data.
*/
export class DriverLicenseV1Document {
constructor(rawPrediction, pageId) {
this.category = new StringField({
prediction: rawPrediction["category"],
pageId: pageId,
});
this.countryCode = new StringField({
prediction: rawPrediction["country_code"],
pageId: pageId,
});
this.dateOfBirth = new DateField({
prediction: rawPrediction["date_of_birth"],
pageId: pageId,
});
this.ddNumber = new StringField({
prediction: rawPrediction["dd_number"],
pageId: pageId,
});
this.expiryDate = new DateField({
prediction: rawPrediction["expiry_date"],
pageId: pageId,
});
this.firstName = new StringField({
prediction: rawPrediction["first_name"],
pageId: pageId,
});
this.id = new StringField({
prediction: rawPrediction["id"],
pageId: pageId,
});
this.issuedDate = new DateField({
prediction: rawPrediction["issued_date"],
pageId: pageId,
});
this.issuingAuthority = new StringField({
prediction: rawPrediction["issuing_authority"],
pageId: pageId,
});
this.lastName = new StringField({
prediction: rawPrediction["last_name"],
pageId: pageId,
});
this.mrz = new StringField({
prediction: rawPrediction["mrz"],
pageId: pageId,
});
this.placeOfBirth = new StringField({
prediction: rawPrediction["place_of_birth"],
pageId: pageId,
});
this.state = new StringField({
prediction: rawPrediction["state"],
pageId: pageId,
});
}
/**
* Default string representation.
*/
toString() {
const outStr = `:Country Code: ${this.countryCode}
:State: ${this.state}
:ID: ${this.id}
:Category: ${this.category}
:Last Name: ${this.lastName}
:First Name: ${this.firstName}
:Date of Birth: ${this.dateOfBirth}
:Place of Birth: ${this.placeOfBirth}
:Expiry Date: ${this.expiryDate}
:Issued Date: ${this.issuedDate}
:Issuing Authority: ${this.issuingAuthority}
:MRZ: ${this.mrz}
:DD Number: ${this.ddNumber}`.trimEnd();
return cleanOutString(outStr);
}
}