UNPKG

mindee

Version:

Mindee Client Library for Node.js

79 lines (78 loc) 2.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PassportV1Document = void 0; const common_1 = require("../../parsing/common"); const standard_1 = require("../../parsing/standard"); /** * Passport API version 1.1 document data. */ class PassportV1Document { constructor(rawPrediction, pageId) { /** The given name(s) of the passport holder. */ this.givenNames = []; 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.country = new standard_1.StringField({ prediction: rawPrediction["country"], 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.issuanceDate = new standard_1.DateField({ prediction: rawPrediction["issuance_date"], 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 = `:Country Code: ${this.country} :ID Number: ${this.idNumber} :Given Name(s): ${givenNames} :Surname: ${this.surname} :Date of Birth: ${this.birthDate} :Place of Birth: ${this.birthPlace} :Gender: ${this.gender} :Date of Issue: ${this.issuanceDate} :Expiry Date: ${this.expiryDate} :MRZ Line 1: ${this.mrz1} :MRZ Line 2: ${this.mrz2}`.trimEnd(); return (0, common_1.cleanOutString)(outStr); } } exports.PassportV1Document = PassportV1Document;