Class: ThePlaidApi::DocumentMetadata

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

Overview

An object representing metadata from the end user’s uploaded document.

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(name: SKIP, status: SKIP, doc_id: SKIP, doc_type: SKIP, additional_properties: nil) ⇒ DocumentMetadata

Returns a new instance of DocumentMetadata.



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/the_plaid_api/models/document_metadata.rb', line 80

def initialize(name: SKIP, status: SKIP, doc_id: SKIP, doc_type: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @name = name unless name == SKIP
  @status = status unless status == SKIP
  @doc_id = doc_id unless doc_id == SKIP
  @doc_type = doc_type unless doc_type == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#doc_idString

An identifier of the document that is also present in the paystub response.

Returns:

  • (String)


30
31
32
# File 'lib/the_plaid_api/models/document_metadata.rb', line 30

def doc_id
  @doc_id
end

#doc_typeDocType

The type of document. ‘DOCUMENT_TYPE_PAYSTUB`: A paystub. `DOCUMENT_TYPE_BANK_STATEMENT`: A bank statement. `DOCUMENT_TYPE_US_TAX_W2`: A W-2 wage and tax statement provided by a US employer reflecting wages earned by the employee. `DOCUMENT_TYPE_US_MILITARY_ERAS`: An electronic Retirement Account Statement (eRAS) issued by the US military. `DOCUMENT_TYPE_US_MILITARY_LES`: A Leave and Earnings Statement (LES) issued by the US military. `DOCUMENT_TYPE_US_MILITARY_CLES`: A Civilian Leave and Earnings Statement (CLES) issued by the US military. `DOCUMENT_TYPE_GIG`: Used to indicate that the income is related to gig work. Does not necessarily correspond to a specific document type. `DOCUMENT_TYPE_NONE`: Used to indicate that there is no underlying document for the data. `DOCUMENT_TYPE_PLAID_GENERATED_PAYSTUB_PDF`: Used to indicate that the PDF for the paystub was generated by Plaid. `UNKNOWN`: Document type could not be determined.

Returns:



51
52
53
# File 'lib/the_plaid_api/models/document_metadata.rb', line 51

def doc_type
  @doc_type
end

#nameString

The name of the document.

Returns:

  • (String)


14
15
16
# File 'lib/the_plaid_api/models/document_metadata.rb', line 14

def name
  @name
end

#statusString

The processing status of the document. ‘PROCESSING_COMPLETE`: The document was successfully processed. `DOCUMENT_ERROR`: The document could not be processed. Possible causes include: The document was an unacceptable document type such as an offer letter or bank statement, the document image was cropped or blurry, or the document was corrupted. `UNKNOWN` or `null`: An internal error occurred. If this happens repeatedly, contact support or your Plaid account manager.

Returns:

  • (String)


25
26
27
# File 'lib/the_plaid_api/models/document_metadata.rb', line 25

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/the_plaid_api/models/document_metadata.rb', line 93

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  doc_id = hash.key?('doc_id') ? hash['doc_id'] : SKIP
  doc_type = hash.key?('doc_type') ? hash['doc_type'] : SKIP

  # 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.
  DocumentMetadata.new(name: name,
                       status: status,
                       doc_id: doc_id,
                       doc_type: doc_type,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



54
55
56
57
58
59
60
61
# File 'lib/the_plaid_api/models/document_metadata.rb', line 54

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['status'] = 'status'
  @_hash['doc_id'] = 'doc_id'
  @_hash['doc_type'] = 'doc_type'
  @_hash
end

.nullablesObject

An array for nullable fields



74
75
76
77
78
# File 'lib/the_plaid_api/models/document_metadata.rb', line 74

def self.nullables
  %w[
    status
  ]
end

.optionalsObject

An array for optional fields



64
65
66
67
68
69
70
71
# File 'lib/the_plaid_api/models/document_metadata.rb', line 64

def self.optionals
  %w[
    name
    status
    doc_id
    doc_type
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



125
126
127
128
129
130
# File 'lib/the_plaid_api/models/document_metadata.rb', line 125

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name.inspect}, status: #{@status.inspect}, doc_id:"\
  " #{@doc_id.inspect}, doc_type: #{@doc_type.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



118
119
120
121
122
# File 'lib/the_plaid_api/models/document_metadata.rb', line 118

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name}, status: #{@status}, doc_id: #{@doc_id}, doc_type:"\
  " #{@doc_type}, additional_properties: #{@additional_properties}>"
end