mindee
Version:
Mindee Client Library for Node.js
79 lines (78 loc) • 2.77 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BusinessCardV1Document = void 0;
const common_1 = require("../../parsing/common");
const standard_1 = require("../../parsing/standard");
/**
* Business Card API version 1.0 document data.
*/
class BusinessCardV1Document {
constructor(rawPrediction, pageId) {
/** The social media profiles of the person or company. */
this.socialMedia = [];
this.address = new standard_1.StringField({
prediction: rawPrediction["address"],
pageId: pageId,
});
this.company = new standard_1.StringField({
prediction: rawPrediction["company"],
pageId: pageId,
});
this.email = new standard_1.StringField({
prediction: rawPrediction["email"],
pageId: pageId,
});
this.faxNumber = new standard_1.StringField({
prediction: rawPrediction["fax_number"],
pageId: pageId,
});
this.firstname = new standard_1.StringField({
prediction: rawPrediction["firstname"],
pageId: pageId,
});
this.jobTitle = new standard_1.StringField({
prediction: rawPrediction["job_title"],
pageId: pageId,
});
this.lastname = new standard_1.StringField({
prediction: rawPrediction["lastname"],
pageId: pageId,
});
this.mobileNumber = new standard_1.StringField({
prediction: rawPrediction["mobile_number"],
pageId: pageId,
});
this.phoneNumber = new standard_1.StringField({
prediction: rawPrediction["phone_number"],
pageId: pageId,
});
rawPrediction["social_media"] &&
rawPrediction["social_media"].map((itemPrediction) => this.socialMedia.push(new standard_1.StringField({
prediction: itemPrediction,
pageId: pageId,
})));
this.website = new standard_1.StringField({
prediction: rawPrediction["website"],
pageId: pageId,
});
}
/**
* Default string representation.
*/
toString() {
const socialMedia = this.socialMedia.join("\n ");
const outStr = `:Firstname: ${this.firstname}
:Lastname: ${this.lastname}
:Job Title: ${this.jobTitle}
:Company: ${this.company}
:Email: ${this.email}
:Phone Number: ${this.phoneNumber}
:Mobile Number: ${this.mobileNumber}
:Fax Number: ${this.faxNumber}
:Address: ${this.address}
:Website: ${this.website}
:Social Media: ${socialMedia}`.trimEnd();
return (0, common_1.cleanOutString)(outStr);
}
}
exports.BusinessCardV1Document = BusinessCardV1Document;