Class: ThePlaidApi::Error

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

Overview

Errors are identified by ‘error_code` and categorized by `error_type`. Use these in preference to HTTP status codes to identify and handle specific errors. HTTP status codes are set and provide the broadest categorization of errors: 4xx codes are for developer- or user-related errors, and 5xx codes are for Plaid-related errors, and the status will be 2xx in non-error cases. An Item with a non-`null` error object will only be part of an API response when calling `/item/get` to view Item status. Otherwise, error fields will be `null` if no error has occurred; if an error has occurred, an error code will be returned instead.

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(error_type:, error_code:, error_message:, display_message:, error_code_reason: SKIP, request_id: SKIP, causes: SKIP, status: SKIP, documentation_url: SKIP, suggested_action: SKIP, required_account_subtypes: SKIP, provided_account_subtypes: SKIP, additional_properties: nil) ⇒ Error

Returns a new instance of Error.



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/the_plaid_api/models/error.rb', line 137

def initialize(error_type:, error_code:, error_message:, display_message:,
               error_code_reason: SKIP, request_id: SKIP, causes: SKIP,
               status: SKIP, documentation_url: SKIP,
               suggested_action: SKIP, required_account_subtypes: SKIP,
               provided_account_subtypes: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @error_type = error_type
  @error_code = error_code
  @error_code_reason = error_code_reason unless error_code_reason == SKIP
  @error_message = error_message
  @display_message = display_message
  @request_id = request_id unless request_id == SKIP
  @causes = causes unless causes == SKIP
  @status = status unless status == SKIP
  @documentation_url = documentation_url unless documentation_url == SKIP
  @suggested_action = suggested_action unless suggested_action == SKIP
  unless  == SKIP
    @required_account_subtypes =
      
  end
  unless  == SKIP
    @provided_account_subtypes =
      
  end
  @additional_properties = additional_properties
end

Instance Attribute Details

#causesArray[Object]

In this product, a request can pertain to more than one Item. If an error is returned for such a request, ‘causes` will return an array of errors containing a breakdown of these errors on the individual Item level, if any can be identified. `causes` will be provided for the `error_type` `ASSET_REPORT_ERROR` or `CHECK_REPORT_ERROR`. `causes` will also not be populated inside an error nested within a `warning` object.

Returns:

  • (Array[Object])


65
66
67
# File 'lib/the_plaid_api/models/error.rb', line 65

def causes
  @causes
end

#display_messageString

A user-friendly representation of the error code. ‘null` if the error is not related to user action. This may change over time and is not safe for programmatic use.

Returns:

  • (String)


50
51
52
# File 'lib/the_plaid_api/models/error.rb', line 50

def display_message
  @display_message
end

#documentation_urlString

The URL of a Plaid documentation page with more information about the error

Returns:

  • (String)


75
76
77
# File 'lib/the_plaid_api/models/error.rb', line 75

def documentation_url
  @documentation_url
end

#error_codeString

The particular error code. Safe for programmatic use.

Returns:

  • (String)


26
27
28
# File 'lib/the_plaid_api/models/error.rb', line 26

def error_code
  @error_code
end

#error_code_reasonString

The specific reason for the error code. Currently, reasons are only supported OAuth-based item errors; ‘null` will be returned otherwise. Safe for programmatic use. Possible values: `OAUTH_INVALID_TOKEN`: The user’s OAuth connection to this institution has been invalidated. `OAUTH_CONSENT_EXPIRED`: The user’s access consent for this OAuth connection to this institution has expired. ‘OAUTH_USER_REVOKED`: The user’s OAuth connection to this institution is invalid because the user revoked their connection.

Returns:

  • (String)


39
40
41
# File 'lib/the_plaid_api/models/error.rb', line 39

def error_code_reason
  @error_code_reason
end

#error_messageString

A developer-friendly representation of the error code. This may change over time and is not safe for programmatic use.

Returns:

  • (String)


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

def error_message
  @error_message
end

#error_typePlaidErrorType

A broad categorization of the error. Safe for programmatic use.

Returns:



22
23
24
# File 'lib/the_plaid_api/models/error.rb', line 22

def error_type
  @error_type
end

#provided_account_subtypesArray[String]

A list of the account subtypes that were extracted but did not match the requested subtypes via the ‘account_filters` parameter in `/link/token/create`. Currently only populated for `NO_ACCOUNTS` errors from Items with `investments_auth` as an enabled product.

Returns:

  • (Array[String])


93
94
95
# File 'lib/the_plaid_api/models/error.rb', line 93

def 
  @provided_account_subtypes
end

#request_idString

A unique ID identifying the request, to be used for troubleshooting purposes. This field will be omitted in errors provided by webhooks.

Returns:

  • (String)


55
56
57
# File 'lib/the_plaid_api/models/error.rb', line 55

def request_id
  @request_id
end

#required_account_subtypesArray[String]

A list of the account subtypes that were requested via the ‘account_filters` parameter in `/link/token/create`. Currently only populated for `NO_ACCOUNTS` errors from Items with `investments_auth` as an enabled product.

Returns:

  • (Array[String])


86
87
88
# File 'lib/the_plaid_api/models/error.rb', line 86

def 
  @required_account_subtypes
end

#statusInteger

The HTTP status code associated with the error. This will only be returned in the response body when the error information is provided via a webhook.

Returns:

  • (Integer)


70
71
72
# File 'lib/the_plaid_api/models/error.rb', line 70

def status
  @status
end

#suggested_actionString

Suggested steps for resolving the error

Returns:

  • (String)


79
80
81
# File 'lib/the_plaid_api/models/error.rb', line 79

def suggested_action
  @suggested_action
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/the_plaid_api/models/error.rb', line 167

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  error_type = hash.key?('error_type') ? hash['error_type'] : nil
  error_code = hash.key?('error_code') ? hash['error_code'] : nil
  error_message = hash.key?('error_message') ? hash['error_message'] : nil
  display_message =
    hash.key?('display_message') ? hash['display_message'] : nil
  error_code_reason =
    hash.key?('error_code_reason') ? hash['error_code_reason'] : SKIP
  request_id = hash.key?('request_id') ? hash['request_id'] : SKIP
  causes = hash.key?('causes') ? hash['causes'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  documentation_url =
    hash.key?('documentation_url') ? hash['documentation_url'] : SKIP
  suggested_action =
    hash.key?('suggested_action') ? hash['suggested_action'] : SKIP
   =
    hash.key?('required_account_subtypes') ? hash['required_account_subtypes'] : SKIP
   =
    hash.key?('provided_account_subtypes') ? hash['provided_account_subtypes'] : 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.
  Error.new(error_type: error_type,
            error_code: error_code,
            error_message: error_message,
            display_message: display_message,
            error_code_reason: error_code_reason,
            request_id: request_id,
            causes: causes,
            status: status,
            documentation_url: documentation_url,
            suggested_action: suggested_action,
            required_account_subtypes: ,
            provided_account_subtypes: ,
            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['error_type'] = 'error_type'
  @_hash['error_code'] = 'error_code'
  @_hash['error_code_reason'] = 'error_code_reason'
  @_hash['error_message'] = 'error_message'
  @_hash['display_message'] = 'display_message'
  @_hash['request_id'] = 'request_id'
  @_hash['causes'] = 'causes'
  @_hash['status'] = 'status'
  @_hash['documentation_url'] = 'documentation_url'
  @_hash['suggested_action'] = 'suggested_action'
  @_hash['required_account_subtypes'] = 'required_account_subtypes'
  @_hash['provided_account_subtypes'] = 'provided_account_subtypes'
  @_hash
end

.nullablesObject

An array for nullable fields



128
129
130
131
132
133
134
135
# File 'lib/the_plaid_api/models/error.rb', line 128

def self.nullables
  %w[
    error_code_reason
    display_message
    status
    suggested_action
  ]
end

.optionalsObject

An array for optional fields



114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/the_plaid_api/models/error.rb', line 114

def self.optionals
  %w[
    error_code_reason
    request_id
    causes
    status
    documentation_url
    suggested_action
    required_account_subtypes
    provided_account_subtypes
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



225
226
227
228
229
230
231
232
233
234
235
# File 'lib/the_plaid_api/models/error.rb', line 225

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} error_type: #{@error_type.inspect}, error_code: #{@error_code.inspect},"\
  " error_code_reason: #{@error_code_reason.inspect}, error_message:"\
  " #{@error_message.inspect}, display_message: #{@display_message.inspect}, request_id:"\
  " #{@request_id.inspect}, causes: #{@causes.inspect}, status: #{@status.inspect},"\
  " documentation_url: #{@documentation_url.inspect}, suggested_action:"\
  " #{@suggested_action.inspect}, required_account_subtypes:"\
  " #{@required_account_subtypes.inspect}, provided_account_subtypes:"\
  " #{@provided_account_subtypes.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



214
215
216
217
218
219
220
221
222
# File 'lib/the_plaid_api/models/error.rb', line 214

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} error_type: #{@error_type}, error_code: #{@error_code}, error_code_reason:"\
  " #{@error_code_reason}, error_message: #{@error_message}, display_message:"\
  " #{@display_message}, request_id: #{@request_id}, causes: #{@causes}, status: #{@status},"\
  " documentation_url: #{@documentation_url}, suggested_action: #{@suggested_action},"\
  " required_account_subtypes: #{@required_account_subtypes}, provided_account_subtypes:"\
  " #{@provided_account_subtypes}, additional_properties: #{@additional_properties}>"
end