plaid/model/document_analysis.rs
1use serde::{Serialize, Deserialize};
2use super::{
3 DocumentAuthenticityMatchCode, ImageQuality, PhysicalDocumentExtractedDataAnalysis,
4};
5///High level descriptions of how the associated document was processed. If a document fails verification, the details in the `analysis` object should help clarify why the document was rejected.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct DocumentAnalysis {
8 /**High level summary of whether the document in the provided image matches the formatting rules and security checks for the associated jurisdiction.
9
10For example, most identity documents have formatting rules like the following:
11
12
13The image of the person's face must have a certain contrast in order to highlight skin tone
14
15
16The subject in the document's image must remove eye glasses and pose in a certain way
17
18
19The informational fields (name, date of birth, ID number, etc.) must be colored and aligned according to specific rules
20
21
22Security features like watermarks and background patterns must be present
23
24So a `match` status for this field indicates that the document in the provided image seems to conform to the various formatting and security rules associated with the detected document.*/
25 pub authenticity: DocumentAuthenticityMatchCode,
26 ///Analysis of the data extracted from the submitted document.
27 #[serde(default, skip_serializing_if = "Option::is_none")]
28 pub extracted_data: Option<PhysicalDocumentExtractedDataAnalysis>,
29 /**A high level description of the quality of the image the user submitted.
30
31For example, an image that is blurry, distorted by glare from a nearby light source, or improperly framed might be marked as low or medium quality. Poor quality images are more likely to fail OCR and/or template conformity checks.
32
33Note: By default, Plaid will let a user recapture document images twice before failing the entire session if we attribute the failure to low image quality.*/
34 pub image_quality: ImageQuality,
35}
36impl std::fmt::Display for DocumentAnalysis {
37 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
38 write!(f, "{}", serde_json::to_string(self).unwrap())
39 }
40}