UNPKG

react-native-scanbot-sdk

Version:

Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS

198 lines (179 loc) 6.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CreditCardScanningStatusValues = exports.CreditCardScanningResult = exports.CreditCardScanningModeValues = exports.CreditCardScannerConfiguration = void 0; var _GenericDocument = require("../documents/GenericDocument"); var _FrameAccumulationTypes = require("../frame_accumulation/FrameAccumulationTypes"); var _JsonSerializationTypes = require("../utils/json/JsonSerializationTypes"); var _utils = require("../utils/utils"); /// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten. /// Generated from core/schemas/CreditCardTypes.yaml /** The status of the scanning process. - `SUCCESS`: The credit card was scanned successfully. - `ERROR_NOTHING_FOUND`: No credit card was detected. - `INCOMPLETE`: Not all required fields were found or confirmed. */ const CreditCardScanningStatusValues = exports.CreditCardScanningStatusValues = ['SUCCESS', 'ERROR_NOTHING_FOUND', 'INCOMPLETE']; /** Contains the result of running the credit card scanner. */ class CreditCardScanningResult extends _utils.PartiallyConstructible { /** The status of the credit card detection step. */ /** The status of the credit card scanning step. */ /** Generic document containing credit card data. Not present, if status is FAIL. */ /** Coordinates of the detected credit card in the input image (clockwise from top-left). */ /** Coordinates of the detected credit card in the input image (clockwise from top-left), normalized to the range [0, 1]. */ /** @param source {@displayType `DeepPartial<CreditCardScanningResult>`} */ constructor(source = {}) { super(); if (source.detectionStatus !== undefined) { this.detectionStatus = source.detectionStatus; } else { throw new Error('detectionStatus must be present in constructor argument'); } if (source.scanningStatus !== undefined) { this.scanningStatus = source.scanningStatus; } else { throw new Error('scanningStatus must be present in constructor argument'); } if (source.creditCard !== undefined) { this.creditCard = source.creditCard != null ? new _GenericDocument.GenericDocument(source.creditCard) : null; } else { throw new Error('creditCard must be present in constructor argument'); } if (source.quad !== undefined) { this.quad = source.quad.map(it => { return { x: it.x, y: it.y }; }); } else { throw new Error('quad must be present in constructor argument'); } if (source.quadNormalized !== undefined) { this.quadNormalized = source.quadNormalized.map(it => { return { x: it.x, y: it.y }; }); } else { throw new Error('quadNormalized must be present in constructor argument'); } } async serialize(config = new _JsonSerializationTypes.ToJsonConfiguration()) { return { detectionStatus: this.detectionStatus, scanningStatus: this.scanningStatus, creditCard: this.creditCard != null ? await this.creditCard.serialize(config) : null, quad: this.quad.map(it => { return it; }), quadNormalized: this.quadNormalized.map(it => { return it; }) }; } _released = false; release() { if (this._released) { return; } { if (this.creditCard != null) { this.creditCard.release(); } } this._released = true; } async encodeImages() { if (this.creditCard != null) { await this.creditCard.encodeImages(); } } } /** The scanning mode. - `LIVE`: The scanner will merge all information from multiple frames to provide the best possible result. Use this mode when the input is a video or camera stream. - `SINGLE_SHOT`: The scanner will only use the current frame and will spend additional time to ensure the best possible result. Use this mode when scanning single images, e.g. imported from the gallery. */ exports.CreditCardScanningResult = CreditCardScanningResult; const CreditCardScanningModeValues = exports.CreditCardScanningModeValues = ['LIVE', 'SINGLE_SHOT']; /** Configuration for the credit card scanner. */ class CreditCardScannerConfiguration extends _utils.PartiallyConstructible { /** If true, the document detector will be used to find where the credit card is in the input image. If false, the scanner will assume that the credit card has been pre-cropped and takes the entirety of the input image. Default is true */ useDocumentDetector = true; /** The scanning mode. Default is LIVE */ scanningMode = 'LIVE'; /** Whether the expiry date is required for a successful scan. Default is true */ requireExpiryDate = true; /** Whether the cardholder name is required for a successful scan. Default is true */ requireCardholderName = true; /** Configuration for how to accumulate results. */ resultAccumulationConfig = new _FrameAccumulationTypes.ResultAccumulationConfiguration({}); /** If true, the credit card image will be returned in creditCard field of CreditCardScanningResult. Default is false */ returnCreditCardImage = false; /** @param source {@displayType `DeepPartial<CreditCardScannerConfiguration>`} */ constructor(source = {}) { super(); if (source.useDocumentDetector !== undefined) { this.useDocumentDetector = source.useDocumentDetector; } if (source.scanningMode !== undefined) { this.scanningMode = source.scanningMode; } if (source.requireExpiryDate !== undefined) { this.requireExpiryDate = source.requireExpiryDate; } if (source.requireCardholderName !== undefined) { this.requireCardholderName = source.requireCardholderName; } if (source.resultAccumulationConfig !== undefined) { this.resultAccumulationConfig = new _FrameAccumulationTypes.ResultAccumulationConfiguration(source.resultAccumulationConfig); } if (source.returnCreditCardImage !== undefined) { this.returnCreditCardImage = source.returnCreditCardImage; } } } exports.CreditCardScannerConfiguration = CreditCardScannerConfiguration; //# sourceMappingURL=CreditCardTypes.js.map