react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
192 lines (172 loc) • 5.84 kB
JavaScript
/// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten.
/// Generated from core/schemas/CreditCardTypes.yaml
import { GenericDocument } from '../documents/GenericDocument';
import { ResultAccumulationConfiguration } from '../frame_accumulation/FrameAccumulationTypes';
import { ToJsonConfiguration } from '../utils/json/JsonSerializationTypes';
import { PartiallyConstructible } from '../utils/utils';
/**
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.
*/
export const CreditCardScanningStatusValues = ['SUCCESS', 'ERROR_NOTHING_FOUND', 'INCOMPLETE'];
/**
Contains the result of running the credit card scanner.
*/
export class CreditCardScanningResult extends 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(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 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.
*/
export const CreditCardScanningModeValues = ['LIVE', 'SINGLE_SHOT'];
/**
Configuration for the credit card scanner.
*/
export class CreditCardScannerConfiguration extends 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 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 ResultAccumulationConfiguration(source.resultAccumulationConfig);
}
if (source.returnCreditCardImage !== undefined) {
this.returnCreditCardImage = source.returnCreditCardImage;
}
}
}
//# sourceMappingURL=CreditCardTypes.js.map