UNPKG

mindee

Version:

Mindee Client Library for Node.js

86 lines (85 loc) 3.65 kB
"use strict"; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _PayslipV2Employment_instances, _PayslipV2Employment_printableValues; Object.defineProperty(exports, "__esModule", { value: true }); exports.PayslipV2Employment = void 0; const common_1 = require("../../../parsing/common"); /** * Information about the employment. */ class PayslipV2Employment { constructor({ prediction = {} }) { _PayslipV2Employment_instances.add(this); /** Confidence score */ this.confidence = 0.0; /** * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ this.polygon = []; this.category = prediction["category"]; if (prediction["coefficient"] !== undefined && prediction["coefficient"] !== null && !isNaN(prediction["coefficient"])) { this.coefficient = +parseFloat(prediction["coefficient"]); } else { this.coefficient = null; } this.collectiveAgreement = prediction["collective_agreement"]; this.jobTitle = prediction["job_title"]; this.positionLevel = prediction["position_level"]; this.startDate = prediction["start_date"]; this.pageId = prediction["page_id"]; this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; if (prediction["polygon"]) { this.polygon = prediction.polygon; } } /** * Default string representation. */ toString() { const printable = __classPrivateFieldGet(this, _PayslipV2Employment_instances, "m", _PayslipV2Employment_printableValues).call(this); return ("Category: " + printable.category + ", Coefficient: " + printable.coefficient + ", Collective Agreement: " + printable.collectiveAgreement + ", Job Title: " + printable.jobTitle + ", Position Level: " + printable.positionLevel + ", Start Date: " + printable.startDate); } /** * Output in a format suitable for inclusion in a field list. */ toFieldList() { const printable = __classPrivateFieldGet(this, _PayslipV2Employment_instances, "m", _PayslipV2Employment_printableValues).call(this); return ` :Category: ${printable.category} :Coefficient: ${printable.coefficient} :Collective Agreement: ${printable.collectiveAgreement} :Job Title: ${printable.jobTitle} :Position Level: ${printable.positionLevel} :Start Date: ${printable.startDate}`.trimEnd(); } } exports.PayslipV2Employment = PayslipV2Employment; _PayslipV2Employment_instances = new WeakSet(), _PayslipV2Employment_printableValues = function _PayslipV2Employment_printableValues() { return { category: this.category ?? "", coefficient: this.coefficient !== undefined ? (0, common_1.floatToString)(this.coefficient) : "", collectiveAgreement: this.collectiveAgreement ?? "", jobTitle: this.jobTitle ?? "", positionLevel: this.positionLevel ?? "", startDate: this.startDate ?? "", }; };