mindee
Version:
Mindee Client Library for Node.js
74 lines (73 loc) • 2.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.IdCardV1Document = void 0;
const common_1 = require("../../../parsing/common");
const standard_1 = require("../../../parsing/standard");
/**
* Carte Nationale d'Identité API version 1.1 document data.
*/
class IdCardV1Document {
constructor(rawPrediction, pageId) {
/** The given name(s) of the card holder. */
this.givenNames = [];
this.authority = new standard_1.StringField({
prediction: rawPrediction["authority"],
pageId: pageId,
});
this.birthDate = new standard_1.DateField({
prediction: rawPrediction["birth_date"],
pageId: pageId,
});
this.birthPlace = new standard_1.StringField({
prediction: rawPrediction["birth_place"],
pageId: pageId,
});
this.expiryDate = new standard_1.DateField({
prediction: rawPrediction["expiry_date"],
pageId: pageId,
});
this.gender = new standard_1.StringField({
prediction: rawPrediction["gender"],
pageId: pageId,
});
rawPrediction["given_names"] &&
rawPrediction["given_names"].map((itemPrediction) => this.givenNames.push(new standard_1.StringField({
prediction: itemPrediction,
pageId: pageId,
})));
this.idNumber = new standard_1.StringField({
prediction: rawPrediction["id_number"],
pageId: pageId,
});
this.mrz1 = new standard_1.StringField({
prediction: rawPrediction["mrz1"],
pageId: pageId,
});
this.mrz2 = new standard_1.StringField({
prediction: rawPrediction["mrz2"],
pageId: pageId,
});
this.surname = new standard_1.StringField({
prediction: rawPrediction["surname"],
pageId: pageId,
});
}
/**
* Default string representation.
*/
toString() {
const givenNames = this.givenNames.join("\n ");
const outStr = `:Identity Number: ${this.idNumber}
:Given Name(s): ${givenNames}
:Surname: ${this.surname}
:Date of Birth: ${this.birthDate}
:Place of Birth: ${this.birthPlace}
:Expiry Date: ${this.expiryDate}
:Issuing Authority: ${this.authority}
:Gender: ${this.gender}
:MRZ Line 1: ${this.mrz1}
:MRZ Line 2: ${this.mrz2}`.trimEnd();
return (0, common_1.cleanOutString)(outStr);
}
}
exports.IdCardV1Document = IdCardV1Document;