mindee
Version:
Mindee Client Library for Node.js
130 lines (129 loc) • 5.52 kB
JavaScript
"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 _UsMailV3RecipientAddress_instances, _UsMailV3RecipientAddress_printableValues;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UsMailV3RecipientAddress = void 0;
const common_1 = require("../../../parsing/common");
const geometry_1 = require("../../../geometry");
/**
* The addresses of the recipients.
*/
class UsMailV3RecipientAddress {
constructor({ prediction = {} }) {
_UsMailV3RecipientAddress_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 = new geometry_1.Polygon();
this.city = prediction["city"];
this.complete = prediction["complete"];
this.isAddressChange = prediction["is_address_change"];
this.postalCode = prediction["postal_code"];
this.privateMailboxNumber = prediction["private_mailbox_number"];
this.state = prediction["state"];
this.street = prediction["street"];
this.unit = prediction["unit"];
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, _UsMailV3RecipientAddress_instances, "m", _UsMailV3RecipientAddress_printableValues).call(this);
return ("City: " +
printable.city +
", Complete Address: " +
printable.complete +
", Is Address Change: " +
printable.isAddressChange +
", Postal Code: " +
printable.postalCode +
", Private Mailbox Number: " +
printable.privateMailboxNumber +
", State: " +
printable.state +
", Street: " +
printable.street +
", Unit: " +
printable.unit);
}
/**
* Output in a format suitable for inclusion in an rST table.
*/
toTableLine() {
const printable = __classPrivateFieldGet(this, _UsMailV3RecipientAddress_instances, "m", _UsMailV3RecipientAddress_printableValues).call(this);
return ("| " +
printable.city.padEnd(15) +
" | " +
printable.complete.padEnd(35) +
" | " +
printable.isAddressChange.padEnd(17) +
" | " +
printable.postalCode.padEnd(11) +
" | " +
printable.privateMailboxNumber.padEnd(22) +
" | " +
printable.state.padEnd(5) +
" | " +
printable.street.padEnd(25) +
" | " +
printable.unit.padEnd(15) +
" |");
}
}
exports.UsMailV3RecipientAddress = UsMailV3RecipientAddress;
_UsMailV3RecipientAddress_instances = new WeakSet(), _UsMailV3RecipientAddress_printableValues = function _UsMailV3RecipientAddress_printableValues() {
return {
city: this.city ?
this.city.length <= 15 ?
(0, common_1.cleanSpecialChars)(this.city) :
(0, common_1.cleanSpecialChars)(this.city).slice(0, 12) + "..." :
"",
complete: this.complete ?
this.complete.length <= 35 ?
(0, common_1.cleanSpecialChars)(this.complete) :
(0, common_1.cleanSpecialChars)(this.complete).slice(0, 32) + "..." :
"",
isAddressChange: this.isAddressChange === true ?
"True" :
this.isAddressChange === false ?
"False" :
"",
postalCode: this.postalCode ?
this.postalCode.length <= 11 ?
(0, common_1.cleanSpecialChars)(this.postalCode) :
(0, common_1.cleanSpecialChars)(this.postalCode).slice(0, 8) + "..." :
"",
privateMailboxNumber: this.privateMailboxNumber ?
this.privateMailboxNumber.length <= 22 ?
(0, common_1.cleanSpecialChars)(this.privateMailboxNumber) :
(0, common_1.cleanSpecialChars)(this.privateMailboxNumber).slice(0, 19) + "..." :
"",
state: this.state ?
this.state.length <= 5 ?
(0, common_1.cleanSpecialChars)(this.state) :
(0, common_1.cleanSpecialChars)(this.state).slice(0, 2) + "..." :
"",
street: this.street ?
this.street.length <= 25 ?
(0, common_1.cleanSpecialChars)(this.street) :
(0, common_1.cleanSpecialChars)(this.street).slice(0, 22) + "..." :
"",
unit: this.unit ?
this.unit.length <= 15 ?
(0, common_1.cleanSpecialChars)(this.unit) :
(0, common_1.cleanSpecialChars)(this.unit).slice(0, 12) + "..." :
"",
};
};