import { DocumentDataExtractionResult, DocumentDataExtractorConfiguration, DocumentDataExtractorScreenConfiguration, DocumentDataExtractorUiResult, DocumentVerificationReport, GenericDocument, handleImageInput, ImageInput, mapRTUUIResult, ResultWrapper, withSBErrorHandling, } from '../types'; import { isIOS, ScanbotSDKNativeModule, ScanbotSDKUINativeModule } from './ScanbotSDKModule'; /** * @internal * @hidden */ export const ScanbotDocumentDataExtractorImpl = { async extractFromImage(params: { image: ImageInput; configuration: DocumentDataExtractorConfiguration; }): Promise { return withSBErrorHandling( async () => new DocumentDataExtractionResult( await ScanbotSDKNativeModule.extractDocumentDataFromImage({ configuration: params.configuration, image: handleImageInput(params.image), }) ) ); }, async startExtractorScreen( configuration: DocumentDataExtractorScreenConfiguration ): Promise> { return withSBErrorHandling(async () => mapRTUUIResult( await ScanbotSDKUINativeModule.startDDEScreen( isIOS ? JSON.stringify(configuration) : configuration ), DocumentDataExtractorUiResult ) ); }, async verifyDocument(documentParts: GenericDocument[]): Promise { return withSBErrorHandling( async () => new DocumentVerificationReport( await ScanbotSDKNativeModule.verifyDocument({ documentParts }) ) ); }, };