react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
95 lines (92 loc) • 3.3 kB
text/typescript
import { ParametricFilter } from '../document/ParametricFilters';
import { DeepPartial, PartiallyConstructible, Point } from '../utils';
import { DocumentDetectionStatus } from '../document/DocumentDetectionStatus';
import { DocumentQuality } from '../document/DocumentQuality';
import { PageImageSource } from '../document/PageImageSource';
/**
The result of the health insurance card recognition
*/
export class PageData extends PartiallyConstructible {
/**
The unique identifier of the page
*/
public readonly uuid: string;
/**
The list of filters applied to the page
*/
public readonly filters: ParametricFilter[] | null = null;
/**
The polygon of the page
*/
public readonly polygon: Point[] = [];
/**
The detection status of the page
*/
public readonly documentDetectionStatus: DocumentDetectionStatus | null = null;
/**
The quality score of the page
*/
public readonly documentQuality: DocumentQuality | null = null;
/**
The source of the page image
*/
public readonly source: PageImageSource | null = null;
/**
The URI of the original image
*/
public readonly originalImageURI: string;
/**
The URI of the document image
*/
public readonly documentImageURI: string | null = null;
/**
The URI of the unfiltered document image
*/
public readonly unfilteredDocumentImageURI: string | null = null;
/**
The URI of the document image preview
*/
public readonly documentImagePreviewURI: string | null = null;
/** @param source {@displayType `DeepPartial<PageData>`} */
public constructor(source: DeepPartial<PageData> = {}) {
super();
if (source.uuid !== undefined) {
this.uuid = source.uuid;
} else {
throw new Error('uuid must be present in constructor argument');
}
if (source.filters !== undefined) {
this.filters =
source.filters != null ? source.filters.map((it) => ParametricFilter.From(it)) : null;
}
if (source.polygon !== undefined) {
this.polygon = source.polygon.map((it) => new Point(it.x, it.y));
}
if (source.documentDetectionStatus !== undefined) {
this.documentDetectionStatus =
source.documentDetectionStatus != null ? source.documentDetectionStatus : null;
}
if (source.documentQuality !== undefined) {
this.documentQuality = source.documentQuality != null ? source.documentQuality : null;
}
if (source.source !== undefined) {
this.source = source.source != null ? source.source : null;
}
if (source.originalImageURI !== undefined) {
this.originalImageURI = source.originalImageURI;
} else {
throw new Error('originalImageURI must be present in constructor argument');
}
if (source.documentImageURI !== undefined) {
this.documentImageURI = source.documentImageURI != null ? source.documentImageURI : null;
}
if (source.unfilteredDocumentImageURI !== undefined) {
this.unfilteredDocumentImageURI =
source.unfilteredDocumentImageURI != null ? source.unfilteredDocumentImageURI : null;
}
if (source.documentImagePreviewURI !== undefined) {
this.documentImagePreviewURI =
source.documentImagePreviewURI != null ? source.documentImagePreviewURI : null;
}
}
}