Class: ThePlaidApi::CreditDocumentMetadata

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

Overview

Object representing metadata pertaining to the 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:, document_type:, download_url:, status:, page_count: SKIP, error_message: SKIP, additional_properties: nil) ⇒ CreditDocumentMetadata

Returns a new instance of CreditDocumentMetadata.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/the_plaid_api/models/credit_document_metadata.rb', line 104

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

  @name = name
  @document_type = document_type
  @download_url = download_url
  @status = status
  @page_count = page_count unless page_count == SKIP
  @error_message = error_message unless error_message == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#document_typeString

The type of document. ‘PAYSTUB`: A paystub. `BANK_STATEMENT`: A bank statement. `US_TAX_W2`: A W-2 wage and tax statement provided by a US employer reflecting wages earned by the employee. `US_MILITARY_ERAS`: An electronic Retirement Account Statement (eRAS) issued by the US military. `US_MILITARY_LES`: A Leave and Earnings Statement (LES) issued by the US military. `US_MILITARY_CLES`: A Civilian Leave and Earnings Statement (CLES) issued by the US military. `GIG`: Used to indicate that the income is related to gig work. Does not necessarily correspond to a specific document type. `PLAID_GENERATED_PAYSTUB_PDF`: Used to indicate that the PDF for the paystub was generated by Plaid. `NONE`: Used to indicate that there is no underlying document for the data. `UNKNOWN`: Document type could not be determined.

Returns:

  • (String)


35
36
37
# File 'lib/the_plaid_api/models/credit_document_metadata.rb', line 35

def document_type
  @document_type
end

#download_urlString

Signed URL to retrieve the document(s). The payload will be a .zip file containing the document(s). For Payroll Income, the file type of the documents will always be PDF, and the documents may not be available, in which case the field will be ‘null`. If you would like Plaid to generate a PDF if the original is not available, contact your Account Manager. [Example generated pay stub](plaid.com/documents/plaid-generated-mock-paystub.pdf). For Document Income, this field will not be `null`, and the file type of the underlying document(s) will be the original file type uploaded by the user. For more details on available file types, see the [Document Income](plaid.com/docs/income/payroll-income) documentation. This download URL can only be used once and expires after two minutes. To generate a new download URL, call `/credit/payroll_income/get` again.

Returns:

  • (String)


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

def download_url
  @download_url
end

#error_messageString

The reason why a failure occurred during document processing (if available).

Returns:

  • (String)


71
72
73
# File 'lib/the_plaid_api/models/credit_document_metadata.rb', line 71

def error_message
  @error_message
end

#nameString

The name of the document.

Returns:

  • (String)


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

def name
  @name
end

#page_countInteger

The number of pages of the uploaded document (if available).

Returns:

  • (Integer)


66
67
68
# File 'lib/the_plaid_api/models/credit_document_metadata.rb', line 66

def page_count
  @page_count
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)


62
63
64
# File 'lib/the_plaid_api/models/credit_document_metadata.rb', line 62

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/the_plaid_api/models/credit_document_metadata.rb', line 120

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
  document_type = hash.key?('document_type') ? hash['document_type'] : nil
  download_url = hash.key?('download_url') ? hash['download_url'] : nil
  status = hash.key?('status') ? hash['status'] : nil
  page_count = hash.key?('page_count') ? hash['page_count'] : SKIP
  error_message = hash.key?('error_message') ? hash['error_message'] : 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.
  CreditDocumentMetadata.new(name: name,
                             document_type: document_type,
                             download_url: download_url,
                             status: status,
                             page_count: page_count,
                             error_message: error_message,
                             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



74
75
76
77
78
79
80
81
82
83
# File 'lib/the_plaid_api/models/credit_document_metadata.rb', line 74

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['document_type'] = 'document_type'
  @_hash['download_url'] = 'download_url'
  @_hash['status'] = 'status'
  @_hash['page_count'] = 'page_count'
  @_hash['error_message'] = 'error_message'
  @_hash
end

.nullablesObject

An array for nullable fields



94
95
96
97
98
99
100
101
102
# File 'lib/the_plaid_api/models/credit_document_metadata.rb', line 94

def self.nullables
  %w[
    document_type
    download_url
    status
    page_count
    error_message
  ]
end

.optionalsObject

An array for optional fields



86
87
88
89
90
91
# File 'lib/the_plaid_api/models/credit_document_metadata.rb', line 86

def self.optionals
  %w[
    page_count
    error_message
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



157
158
159
160
161
162
163
# File 'lib/the_plaid_api/models/credit_document_metadata.rb', line 157

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

#to_sObject

Provides a human-readable string representation of the object.



149
150
151
152
153
154
# File 'lib/the_plaid_api/models/credit_document_metadata.rb', line 149

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