UNPKG

mindee

Version:

Mindee Client Library for Node.js

99 lines (98 loc) 3.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IdCardV2Document = void 0; const common_1 = require("../../../parsing/common"); const standard_1 = require("../../../parsing/standard"); /** * Carte Nationale d'Identité API version 2.0 document data. */ class IdCardV2Document { constructor(rawPrediction, pageId) { /** The given name(s) of the card holder. */ this.givenNames = []; this.alternateName = new standard_1.StringField({ prediction: rawPrediction["alternate_name"], pageId: pageId, }); 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.cardAccessNumber = new standard_1.StringField({ prediction: rawPrediction["card_access_number"], pageId: pageId, }); this.documentNumber = new standard_1.StringField({ prediction: rawPrediction["document_number"], 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.issueDate = new standard_1.DateField({ prediction: rawPrediction["issue_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.mrz3 = new standard_1.StringField({ prediction: rawPrediction["mrz3"], pageId: pageId, }); this.nationality = new standard_1.StringField({ prediction: rawPrediction["nationality"], 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 = `:Nationality: ${this.nationality} :Card Access Number: ${this.cardAccessNumber} :Document Number: ${this.documentNumber} :Given Name(s): ${givenNames} :Surname: ${this.surname} :Alternate Name: ${this.alternateName} :Date of Birth: ${this.birthDate} :Place of Birth: ${this.birthPlace} :Gender: ${this.gender} :Expiry Date: ${this.expiryDate} :Mrz Line 1: ${this.mrz1} :Mrz Line 2: ${this.mrz2} :Mrz Line 3: ${this.mrz3} :Date of Issue: ${this.issueDate} :Issuing Authority: ${this.authority}`.trimEnd(); return (0, common_1.cleanOutString)(outStr); } } exports.IdCardV2Document = IdCardV2Document;