UNPKG

react-native-scanbot-sdk

Version:

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

224 lines (200 loc) 7.71 kB
/// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten. /// Generated from core/schemas/CheckScannerTypes.yaml import { DocumentDetectionResult } from '../document_scanner/DocumentScannerTypes'; import { GenericDocument } from '../documents/GenericDocument'; import { ImageRef } from '../imageRef/image'; import { ToJsonConfiguration } from '../utils/json/JsonSerializationTypes'; import { DeepPartial, PartiallyConstructible } from '../utils/utils'; /** Check document detection and extraction mode. - `DISABLED`: Document detection is not performed. Successful check scans will only contain the machine-readable check data without a full crop of the check. - `DETECT_DOCUMENT`: Document scanner will be used to locate the complete check in the input image. The documentDetectionResult result field will contain the result of document detection. - `DETECT_AND_CROP_DOCUMENT`: Document scanner will be used to locate the complete check in the input image. The documentDetectionResult result field will contain the result of document detection. The croppedImage result field will contain a crop of the entire check. */ export type CheckDocumentDetectionMode = | 'DISABLED' | 'DETECT_DOCUMENT' | 'DETECT_AND_CROP_DOCUMENT'; export const CheckDocumentDetectionModeValues: CheckDocumentDetectionMode[] = [ 'DISABLED', 'DETECT_DOCUMENT', 'DETECT_AND_CROP_DOCUMENT', ]; /** Check magnetic ink (MICR) strip scanning status. - `SUCCESS`: Scanning successful. - `INCOMPLETE_VALIDATION`: Magnetic ink strip was found, but validation failed, because of a format violation, an unsupported format, or an OCR error. - `ERROR_NOTHING_FOUND`: Magnetic ink strip was not found. */ export type CheckMagneticInkStripScanningStatus = | 'SUCCESS' | 'INCOMPLETE_VALIDATION' | 'ERROR_NOTHING_FOUND'; export const CheckMagneticInkStripScanningStatusValues: CheckMagneticInkStripScanningStatus[] = [ 'SUCCESS', 'INCOMPLETE_VALIDATION', 'ERROR_NOTHING_FOUND', ]; /** The result of check scanning. */ export class CheckScanningResult extends PartiallyConstructible { /** Magnetic ink strip scanning status. Default is ERROR_NOTHING_FOUND */ public readonly status: CheckMagneticInkStripScanningStatus = 'ERROR_NOTHING_FOUND'; /** Generic document containing check data. Not present, if status is FAIL. */ public readonly check: GenericDocument | null; /** The result of document detection. Will be set only if detectDocument in the configuration is set to true. Check scanning may still succeed even if the whole document is not visible in the input image and the complete document could not be located. */ public readonly documentDetectionResult: DocumentDetectionResult | null; /** Crop of the check if documentDetectionMode is set to DETECT_AND_CROP_DOCUMENT. Will be non-empty, only if check recognition succeeded. */ public readonly croppedImage: ImageRef | null = null; /** @param source {@displayType `DeepPartial<CheckScanningResult>`} */ public constructor(source: DeepPartial<CheckScanningResult> = {}) { super(); if (source.status !== undefined) { this.status = source.status; } if (source.check !== undefined) { this.check = source.check != null ? new GenericDocument(source.check) : null; } else { throw new Error('check must be present in constructor argument'); } if (source.documentDetectionResult !== undefined) { this.documentDetectionResult = source.documentDetectionResult != null ? new DocumentDetectionResult(source.documentDetectionResult) : null; } else { throw new Error('documentDetectionResult must be present in constructor argument'); } if (source.croppedImage !== undefined) { this.croppedImage = source.croppedImage != null ? ImageRef.From(source.croppedImage) : null; } } public async serialize( config: ToJsonConfiguration = new ToJsonConfiguration() ): Promise<DeepPartial<CheckScanningResult>> { return { status: this.status, check: this.check != null ? await this.check.serialize(config) : null, documentDetectionResult: this.documentDetectionResult != null ? this.documentDetectionResult.serialize(config) : null, croppedImage: config.serializeImages ? this.croppedImage != null ? await this.croppedImage.serialize(config.imageSerializationMode) : null : undefined, }; } private _released: Boolean = false; public release() { if (this._released) { return; } { if (this.check != null) { this.check.release(); } } { if (this.croppedImage != null) { this.croppedImage.release(); } } this._released = true; } public async encodeImages(): Promise<void> { if (this.check != null) { await this.check.encodeImages(); } if (this.croppedImage != null) { await this.croppedImage.encodeInPlace(); } } } /** Supported check standards. - `USA`: A check compatible with the ASC X9 standard used in the USA. - `FRA`: A check format commonly used in France. - `KWT`: A check format commonly used in Kuwait. - `AUS`: A check compatible with the Australian Paper Clearing System cheque standard. - `IND`: A check compatible with the CTS-2010 standard issued by the Reserve Bank of India in 2012. - `ISR`: A check format commonly used in Israel. - `UAE`: A check format commonly used in the United Arab Emirates. - `CAN`: A check format commonly used in Canada. */ export type CheckStandard = 'USA' | 'FRA' | 'KWT' | 'AUS' | 'IND' | 'ISR' | 'UAE' | 'CAN'; export const CheckStandardValues: CheckStandard[] = [ 'USA', 'FRA', 'KWT', 'AUS', 'IND', 'ISR', 'UAE', 'CAN', ]; /** Configuration of the check scanner. */ export class CheckScannerConfiguration extends PartiallyConstructible { /** Document detection to be performed in addition to scanning the machine-readable data in the check. By default only the machine-readable data is extracted during check scanning. Optionally, the coordinates and a crop of the entire check document can be returned, in addition to the check data. A check scan result may still be successful even if the whole document is not visible in the input image and the complete document could not be located. If cropping is enabled, check recognition will be performed on the cropped image of the check, which may improve recognition results. Default is DISABLED */ public documentDetectionMode: CheckDocumentDetectionMode = 'DISABLED'; /** Accepted check standards. Optional, by default - all checks are accepted. With an empty list no filter is applied and all checks are accepted. */ public acceptedCheckStandards: CheckStandard[] = []; /** @param source {@displayType `DeepPartial<CheckScannerConfiguration>`} */ public constructor(source: DeepPartial<CheckScannerConfiguration> = {}) { super(); if (source.documentDetectionMode !== undefined) { this.documentDetectionMode = source.documentDetectionMode; } if (source.acceptedCheckStandards !== undefined) { this.acceptedCheckStandards = source.acceptedCheckStandards.map((it: any) => { return it; }); } } public serialize( config: ToJsonConfiguration = new ToJsonConfiguration() ): DeepPartial<CheckScannerConfiguration> { return { documentDetectionMode: this.documentDetectionMode, acceptedCheckStandards: this.acceptedCheckStandards.map((it: any) => { return it; }), }; } }