UNPKG

react-native-scanbot-sdk

Version:

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

89 lines (81 loc) 2.94 kB
/// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten. /// Generated from rtu-ui-v2/schemas/check/CheckScannerUIResult.yaml import { CheckMagneticInkStripScanningStatus } from '../../check/CheckScannerTypes'; import { GenericDocument } from '../../documents/GenericDocument'; import { ImageRef } from '../../imageRef/image'; import { ToJsonConfiguration } from '../../utils/json/JsonSerializationTypes'; import { DeepPartial, PartiallyConstructible } from '../../utils/utils'; /** Configuration of the check scanner RTU UI result. */ export class CheckScannerUiResult extends PartiallyConstructible { /** The status of the check recognition step. */ public readonly recognitionStatus: CheckMagneticInkStripScanningStatus; /** 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; /** Generic document containing check data. Not present, if status is FAIL. */ public readonly check: GenericDocument | null; /** @param source {@displayType `DeepPartial<CheckScannerUiResult>`} */ public constructor(source: DeepPartial<CheckScannerUiResult> = {}) { super(); if (source.recognitionStatus !== undefined) { this.recognitionStatus = source.recognitionStatus; } else { throw new Error('recognitionStatus must be present in constructor argument'); } if (source.croppedImage !== undefined) { this.croppedImage = source.croppedImage != null ? ImageRef.From(source.croppedImage) : null; } else { throw new Error('croppedImage must be present in constructor argument'); } 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'); } } public async serialize( config: ToJsonConfiguration = new ToJsonConfiguration() ): Promise<DeepPartial<CheckScannerUiResult>> { return { recognitionStatus: this.recognitionStatus, croppedImage: config.serializeImages ? this.croppedImage != null ? await this.croppedImage.serialize(config.imageSerializationMode) : null : undefined, check: this.check != null ? await this.check.serialize(config) : null, }; } private _released: Boolean = false; public release() { if (this._released) { return; } { if (this.croppedImage != null) { this.croppedImage.release(); } } { if (this.check != null) { this.check.release(); } } this._released = true; } public async encodeImages(): Promise<void> { if (this.croppedImage != null) { await this.croppedImage.encodeInPlace(); } if (this.check != null) { await this.check.encodeImages(); } } }