Class: Plaid::CheckReport::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/plaid/check_report/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



9
10
11
# File 'lib/plaid/check_report/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#create(request_options: {}, **params) ⇒ Plaid::Types::CraCheckReportCreateResponse

Use /cra/check_report/create to refresh data in an existing report. A Consumer Report will last for 24 hours before expiring; you should call any /get endpoints on the report before it expires. If a report expires, you can call /cra/check_report/create again to re-generate it and refresh the data in the report. The report is generated from all Items associated with the user, excluding duplicate Items and Items that cannot supply data.

Each call to /cra/check_report/create creates a new, independent report. /get endpoints will retrieve the most recently created report for the requested user.

Examples:

client.check_report.create(
  webhook: "webhook",
  days_requested: 1,
  consumer_report_permissible_purpose: "ACCOUNT_REVIEW_CREDIT"
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/plaid/check_report/client.rb', line 201

def create(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "cra/check_report/create",
    body: Plaid::CheckReport::Types::CraCheckReportCreateRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::CraCheckReportCreateResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#get_base_report(request_options: {}, **params) ⇒ Plaid::Types::CraCheckReportBaseReportGetResponse

This endpoint allows you to retrieve the Base Report for your user, allowing you to receive comprehensive bank account and cash flow data. You should call this endpoint after you've received a CHECK_REPORT_READY or a USER_CHECK_REPORT_READY webhook, either after the Link session for the user or after calling /cra/check_report/create. If the most recent consumer report for the user doesn't have sufficient data to generate the base report, or the consumer report has expired, you will receive an error indicating that you should create a new consumer report by calling /cra/check_report/create.

Examples:

client.check_report.get_base_report

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/plaid/check_report/client.rb', line 94

def get_base_report(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "cra/check_report/base_report/get",
    body: Plaid::CheckReport::Types::CraCheckReportBaseReportGetRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::CraCheckReportBaseReportGetResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#get_cashflow_insights(request_options: {}, **params) ⇒ Plaid::Types::CraCheckReportCashflowInsightsGetResponse

This endpoint allows you to retrieve the Cashflow Insights report for your user. You should call this endpoint after you've received a CHECK_REPORT_READY or a USER_CHECK_REPORT_READY webhook, either after the Link session for the user or after calling /cra/check_report/create. If the most recent consumer report for the user doesn't have sufficient data to generate the report, or the consumer report has expired, you will receive an error indicating that you should create a new consumer report by calling /cra/check_report/create.

Examples:

client.check_report.get_cashflow_insights

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/plaid/check_report/client.rb', line 309

def get_cashflow_insights(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "cra/check_report/cashflow_insights/get",
    body: Plaid::CheckReport::Types::CraCheckReportCashflowInsightsGetRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::CraCheckReportCashflowInsightsGetResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#get_income_insights(request_options: {}, **params) ⇒ Plaid::Types::CraCheckReportIncomeInsightsGetResponse

This endpoint allows you to retrieve the Income Insights report for your user. You should call this endpoint after you've received a CHECK_REPORT_READY or a USER_CHECK_REPORT_READY webhook, either after the Link session for the user or after calling /cra/check_report/create. If the most recent consumer report for the user doesn't have sufficient data to generate the report, or the consumer report has expired, you will receive an error indicating that you should create a new consumer report by calling /cra/check_report/create.

NOTE: The following schema was updated in April 2026 to reflect the response when the provided version is "II2". Please see this document for guidance on migrating to II2 if you are currently using the II1 version, and this section for an example II1 response along with its documentation.

Examples:

client.check_report.get_income_insights

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/plaid/check_report/client.rb', line 39

def get_income_insights(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "cra/check_report/income_insights/get",
    body: Plaid::CheckReport::Types::CraCheckReportIncomeInsightsGetRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::CraCheckReportIncomeInsightsGetResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#get_lend_score(request_options: {}, **params) ⇒ Plaid::Types::CraCheckReportLendScoreGetResponse

This endpoint allows you to retrieve the LendScore report for your user. You should call this endpoint after you've received a CHECK_REPORT_READY or a USER_CHECK_REPORT_READY webhook, either after the Link session for the user or after calling /cra/check_report/create. If the most recent consumer report for the user doesn't have sufficient data to generate the report, or the consumer report has expired, you will receive an error indicating that you should create a new consumer report by calling /cra/check_report/create.

Examples:

client.check_report.get_lend_score

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/plaid/check_report/client.rb', line 363

def get_lend_score(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "cra/check_report/lend_score/get",
    body: Plaid::CheckReport::Types::CraCheckReportLendScoreGetRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::CraCheckReportLendScoreGetResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#get_network_insights(request_options: {}, **params) ⇒ Plaid::Types::CraCheckReportNetworkInsightsGetResponse

This endpoint allows you to retrieve the Network Insights report for your user. You should call this endpoint after you've received a CHECK_REPORT_READY or a USER_CHECK_REPORT_READY webhook, either after the Link session for the user or after calling /cra/check_report/create. If the most recent consumer report for the user doesn't have sufficient data to generate the report, or the consumer report has expired, you will receive an error indicating that you should create a new consumer report by calling /cra/check_report/create.

Examples:

client.check_report.get_network_insights

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'lib/plaid/check_report/client.rb', line 417

def get_network_insights(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "cra/check_report/network_insights/get",
    body: Plaid::CheckReport::Types::CraCheckReportNetworkInsightsGetRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::CraCheckReportNetworkInsightsGetResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#get_partner_insights(request_options: {}, **params) ⇒ Plaid::Types::CraCheckReportPartnerInsightsGetResponse

This endpoint allows you to retrieve the Partner Insights report for your user. You should call this endpoint after you've received a CHECK_REPORT_READY or a USER_CHECK_REPORT_READY webhook, either after the Link session for the user or after calling /cra/check_report/create. If the most recent consumer report for the user doesn't have sufficient data to generate the report, or the consumer report has expired, you will receive an error indicating that you should create a new consumer report by calling /cra/check_report/create.

Examples:

client.check_report.get_partner_insights

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/plaid/check_report/client.rb', line 255

def get_partner_insights(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "cra/check_report/partner_insights/get",
    body: Plaid::CheckReport::Types::CraCheckReportPartnerInsightsGetRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::CraCheckReportPartnerInsightsGetResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#get_pdf(request_options: {}, **params) ⇒ String

/cra/check_report/pdf/get retrieves the most recent Consumer Report in PDF format. The most recent Base Report for the user is always included. Use the add_ons field to also include the most recent Income Insights, Partner Insights or LendScore report in the PDF.

Examples:

client.check_report.get_pdf

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:

  • (String)

Raises:

  • (error_class)


146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/plaid/check_report/client.rb', line 146

def get_pdf(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "cra/check_report/pdf/get",
    body: Plaid::CheckReport::Types::CraCheckReportPdfGetRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  return response.body if code.between?(200, 299)

  error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
  error_types = {
    400 => Plaid::Types::PlaidError,
    401 => Plaid::Types::PlaidError,
    429 => Plaid::Types::PlaidError,
    500 => Plaid::Types::PlaidError,
    (400..499) => Plaid::Types::PlaidError,
    (500..599) => Plaid::Types::PlaidError
  }
  error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
  raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
end

#get_verification(request_options: {}, **params) ⇒ Plaid::Types::CraCheckReportVerificationGetResponse

This endpoint allows you to retrieve home lending reports for a user. To obtain a VoA or Employment Refresh report, you need to make sure that cra_base_report is included in the products parameter when calling /link/token/create or /cra/check_report/create.

You should call this endpoint after you've received a CHECK_REPORT_READY or a USER_CHECK_REPORT_READY webhook, either after the Link session for the user or after calling /cra/check_report/create.

If the most recent consumer report for the user doesn't have sufficient data to generate the report, or the consumer report has expired, you will receive an error indicating that you should create a new consumer report by calling /cra/check_report/create.

Examples:

client.check_report.get_verification(reports_requested: ["VOA"])

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
# File 'lib/plaid/check_report/client.rb', line 476

def get_verification(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "cra/check_report/verification/get",
    body: Plaid::CheckReport::Types::CraCheckReportVerificationGetRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::CraCheckReportVerificationGetResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#get_verification_pdf(request_options: {}, **params) ⇒ String

The /cra/check_report/verification/pdf/get endpoint retrieves the most recent Consumer Report in PDF format, specifically formatted for Home Lending verification use cases. Before calling this endpoint, ensure that you've created a VOA report through Link or the /cra/check_report/create endpoint, and have received a CHECK_REPORT_READY or a USER_CHECK_REPORT_READY webhook.

The response to /cra/check_report/verification/pdf/get is the PDF binary data. The request_id is returned in the Plaid-Request-ID header.

Examples:

client.check_report.get_verification_pdf

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:

  • (String)

Raises:

  • (error_class)


532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/plaid/check_report/client.rb', line 532

def get_verification_pdf(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "cra/check_report/verification/pdf/get",
    body: Plaid::CheckReport::Types::CraCheckReportVerificationPdfGetRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  return response.body if code.between?(200, 299)

  error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
  error_types = {
    400 => Plaid::Types::PlaidError,
    401 => Plaid::Types::PlaidError,
    429 => Plaid::Types::PlaidError,
    500 => Plaid::Types::PlaidError,
    (400..499) => Plaid::Types::PlaidError,
    (500..599) => Plaid::Types::PlaidError
  }
  error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
  raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
end