UNPKG

mindee

Version:

Mindee Client Library for Node.js

112 lines (111 loc) 4.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InternationalIdV2Document = void 0; const common_1 = require("../../parsing/common"); const standard_1 = require("../../parsing/standard"); /** * International ID API version 2.2 document data. */ class InternationalIdV2Document { constructor(rawPrediction, pageId) { /** The list of the document holder's given names. */ this.givenNames = []; /** The list of the document holder's family names. */ this.surnames = []; this.address = new standard_1.StringField({ prediction: rawPrediction["address"], 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.countryOfIssue = new standard_1.StringField({ prediction: rawPrediction["country_of_issue"], pageId: pageId, }); this.documentNumber = new standard_1.StringField({ prediction: rawPrediction["document_number"], pageId: pageId, }); this.documentType = new standard_1.ClassificationField({ prediction: rawPrediction["document_type"], }); this.expiryDate = new standard_1.DateField({ prediction: rawPrediction["expiry_date"], pageId: pageId, }); rawPrediction["given_names"] && rawPrediction["given_names"].map((itemPrediction) => this.givenNames.push(new standard_1.StringField({ prediction: itemPrediction, pageId: pageId, }))); this.issueDate = new standard_1.DateField({ prediction: rawPrediction["issue_date"], pageId: pageId, }); this.mrzLine1 = new standard_1.StringField({ prediction: rawPrediction["mrz_line1"], pageId: pageId, }); this.mrzLine2 = new standard_1.StringField({ prediction: rawPrediction["mrz_line2"], pageId: pageId, }); this.mrzLine3 = new standard_1.StringField({ prediction: rawPrediction["mrz_line3"], pageId: pageId, }); this.nationality = new standard_1.StringField({ prediction: rawPrediction["nationality"], pageId: pageId, }); this.personalNumber = new standard_1.StringField({ prediction: rawPrediction["personal_number"], pageId: pageId, }); this.sex = new standard_1.StringField({ prediction: rawPrediction["sex"], pageId: pageId, }); this.stateOfIssue = new standard_1.StringField({ prediction: rawPrediction["state_of_issue"], pageId: pageId, }); rawPrediction["surnames"] && rawPrediction["surnames"].map((itemPrediction) => this.surnames.push(new standard_1.StringField({ prediction: itemPrediction, pageId: pageId, }))); } /** * Default string representation. */ toString() { const surnames = this.surnames.join("\n "); const givenNames = this.givenNames.join("\n "); const outStr = `:Document Type: ${this.documentType} :Document Number: ${this.documentNumber} :Surnames: ${surnames} :Given Names: ${givenNames} :Sex: ${this.sex} :Birth Date: ${this.birthDate} :Birth Place: ${this.birthPlace} :Nationality: ${this.nationality} :Personal Number: ${this.personalNumber} :Country of Issue: ${this.countryOfIssue} :State of Issue: ${this.stateOfIssue} :Issue Date: ${this.issueDate} :Expiration Date: ${this.expiryDate} :Address: ${this.address} :MRZ Line 1: ${this.mrzLine1} :MRZ Line 2: ${this.mrzLine2} :MRZ Line 3: ${this.mrzLine3}`.trimEnd(); return (0, common_1.cleanOutString)(outStr); } } exports.InternationalIdV2Document = InternationalIdV2Document;