Class: ThePlaidApi::DocumentAnalysis

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/document_analysis.rb

Overview

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.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(authenticity:, image_quality:, extracted_data:, aamva_verification:, fraud_analysis_details: SKIP, image_quality_details: SKIP, human_review: SKIP, additional_properties: nil) ⇒ DocumentAnalysis

Returns a new instance of DocumentAnalysis.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/the_plaid_api/models/document_analysis.rb', line 98

def initialize(authenticity:, image_quality:, extracted_data:,
               aamva_verification:, fraud_analysis_details: SKIP,
               image_quality_details: SKIP, human_review: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @authenticity = authenticity
  @image_quality = image_quality
  @extracted_data = extracted_data
  @fraud_analysis_details = fraud_analysis_details unless fraud_analysis_details == SKIP
  @image_quality_details = image_quality_details unless image_quality_details == SKIP
  @human_review = human_review unless human_review == SKIP
  @aamva_verification = aamva_verification
  @additional_properties = additional_properties
end

Instance Attribute Details

#aamva_verificationAamvaAnalysis

Analyzed AAMVA data for the associated hit. Note: This field is only available for U.S. driver’s licenses issued by participating states.

Returns:



63
64
65
# File 'lib/the_plaid_api/models/document_analysis.rb', line 63

def aamva_verification
  @aamva_verification
end

#authenticityDocumentAuthenticityMatchCode

High level summary of whether the document in the provided image matches the formatting rules and security checks for the associated jurisdiction. For example, most identity documents have formatting rules like the following: The image of the person’s face must have a certain contrast in order to highlight skin tone The subject in the document’s image must remove eye glasses and pose in a certain way The informational fields (name, date of birth, ID number, etc.) must be colored and aligned according to specific rules Security features like watermarks and background patterns must be present So 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.



29
30
31
# File 'lib/the_plaid_api/models/document_analysis.rb', line 29

def authenticity
  @authenticity
end

#extracted_dataPhysicalDocumentExtractedDataAnalysis

Analysis of the data extracted from the submitted document.



44
45
46
# File 'lib/the_plaid_api/models/document_analysis.rb', line 44

def extracted_data
  @extracted_data
end

#fraud_analysis_detailsFraudAnalysisDetails

Details about the fraud analysis performed on the document.



48
49
50
# File 'lib/the_plaid_api/models/document_analysis.rb', line 48

def fraud_analysis_details
  @fraud_analysis_details
end

#human_reviewHumanReview

Details about the human review check, which refers to a check that is performed by a document specialist.

Returns:



57
58
59
# File 'lib/the_plaid_api/models/document_analysis.rb', line 57

def human_review
  @human_review
end

#image_qualityImageQuality

A high level description of the quality of the image the user submitted. For 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. Note: 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.

Returns:



40
41
42
# File 'lib/the_plaid_api/models/document_analysis.rb', line 40

def image_quality
  @image_quality
end

#image_quality_detailsImageQualityDetails

Details about the image quality of the document.

Returns:



52
53
54
# File 'lib/the_plaid_api/models/document_analysis.rb', line 52

def image_quality_details
  @image_quality_details
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/the_plaid_api/models/document_analysis.rb', line 116

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  authenticity = hash.key?('authenticity') ? hash['authenticity'] : nil
  image_quality = hash.key?('image_quality') ? hash['image_quality'] : nil
  extracted_data = PhysicalDocumentExtractedDataAnalysis.from_hash(hash['extracted_data']) if
    hash['extracted_data']
  aamva_verification = AamvaAnalysis.from_hash(hash['aamva_verification']) if
    hash['aamva_verification']
  fraud_analysis_details = FraudAnalysisDetails.from_hash(hash['fraud_analysis_details']) if
    hash['fraud_analysis_details']
  image_quality_details = ImageQualityDetails.from_hash(hash['image_quality_details']) if
    hash['image_quality_details']
  human_review = HumanReview.from_hash(hash['human_review']) if hash['human_review']

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  DocumentAnalysis.new(authenticity: authenticity,
                       image_quality: image_quality,
                       extracted_data: extracted_data,
                       aamva_verification: aamva_verification,
                       fraud_analysis_details: fraud_analysis_details,
                       image_quality_details: image_quality_details,
                       human_review: human_review,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/the_plaid_api/models/document_analysis.rb', line 66

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['authenticity'] = 'authenticity'
  @_hash['image_quality'] = 'image_quality'
  @_hash['extracted_data'] = 'extracted_data'
  @_hash['fraud_analysis_details'] = 'fraud_analysis_details'
  @_hash['image_quality_details'] = 'image_quality_details'
  @_hash['human_review'] = 'human_review'
  @_hash['aamva_verification'] = 'aamva_verification'
  @_hash
end

.nullablesObject

An array for nullable fields



88
89
90
91
92
93
94
95
96
# File 'lib/the_plaid_api/models/document_analysis.rb', line 88

def self.nullables
  %w[
    extracted_data
    fraud_analysis_details
    image_quality_details
    human_review
    aamva_verification
  ]
end

.optionalsObject

An array for optional fields



79
80
81
82
83
84
85
# File 'lib/the_plaid_api/models/document_analysis.rb', line 79

def self.optionals
  %w[
    fraud_analysis_details
    image_quality_details
    human_review
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



161
162
163
164
165
166
167
168
169
# File 'lib/the_plaid_api/models/document_analysis.rb', line 161

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} authenticity: #{@authenticity.inspect}, image_quality:"\
  " #{@image_quality.inspect}, extracted_data: #{@extracted_data.inspect},"\
  " fraud_analysis_details: #{@fraud_analysis_details.inspect}, image_quality_details:"\
  " #{@image_quality_details.inspect}, human_review: #{@human_review.inspect},"\
  " aamva_verification: #{@aamva_verification.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



151
152
153
154
155
156
157
158
# File 'lib/the_plaid_api/models/document_analysis.rb', line 151

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} authenticity: #{@authenticity}, image_quality: #{@image_quality},"\
  " extracted_data: #{@extracted_data}, fraud_analysis_details: #{@fraud_analysis_details},"\
  " image_quality_details: #{@image_quality_details}, human_review: #{@human_review},"\
  " aamva_verification: #{@aamva_verification}, additional_properties:"\
  " #{@additional_properties}>"
end