Class: Plaid::Identity::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



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

def initialize(client:)
  @client = client
end

Instance Method Details

#get(request_options: {}, **params) ⇒ Plaid::Types::IdentityGetResponse

The /identity/get endpoint allows you to retrieve various account holder information on file with the financial institution, including names, emails, phone numbers, and addresses. Only name data is guaranteed to be returned; other fields will be empty arrays if not provided by the institution.

Note: In API versions 2018-05-22 and earlier, the owners object is not returned, and instead identity information is returned in the top level identity object. For more details, see Plaid API versioning.

Examples:

client.identity.get(access_token: "access_token")

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:



33
34
35
36
37
38
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
# File 'lib/plaid/identity/client.rb', line 33

def get(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: "identity/get",
    body: Plaid::Identity::Types::IdentityGetRequest.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::IdentityGetResponse.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_document_uploads(request_options: {}, **params) ⇒ Plaid::Types::IdentityDocumentsUploadsGetResponse

Use /identity/documents/uploads/get to retrieve identity details when using Identity Document Upload.

Examples:

client.identity.get_document_uploads(access_token: "access_token")

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:



84
85
86
87
88
89
90
91
92
93
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
# File 'lib/plaid/identity/client.rb', line 84

def get_document_uploads(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: "identity/documents/uploads/get",
    body: Plaid::Identity::Types::IdentityDocumentsUploadsGetRequest.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::IdentityDocumentsUploadsGetResponse.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

#list_matches(request_options: {}, **params) ⇒ Plaid::Internal::CursorItemIterator

Returns a chronological history of Link-originated Identity Match attempts for a client, ordered by creation time with the oldest attempt first.

This endpoint requires separate enablement in addition to access to Identity Match. To request endpoint access, contact your account manager or submit a product access support ticket.

Results are retained for up to one year. Attempts marked as deleted are omitted.

Returns a Plaid::Internal::CursorItemIterator that yields each Plaid::Types::IdentityMatchListAttempt in the identity_match_attempts field of every page, requesting pages as they are needed. Call pages on it to get each page as a Plaid::Types::IdentityMatchListResponse, including its other fields.

No request is sent by this call. The first page is requested when you start iterating (or call load_first_page), so an API error is raised by the loop (or by load_first_page), not by this call.

Examples:

client.identity.list_matches(
  start_time: "2024-01-15T09:30:00Z",
  end_time: "2024-01-15T09:30:00Z"
)

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:



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
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/plaid/identity/client.rb', line 206

def list_matches(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  Plaid::Internal::CursorItemIterator.new(
    cursor_field: :next_cursor,
    item_field: :identity_match_attempts,
    initial_cursor: params[:cursor]
  ) do |next_cursor|
    params[:cursor] = next_cursor
    request = Plaid::Internal::JSON::Request.new(
      base_url: request_options[:base_url],
      method: "POST",
      path: "identity/match/list",
      body: Plaid::Identity::Types::IdentityMatchListRequest.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
        parsed_response = (response.body.to_s.empty? ? nil : Plaid::Types::IdentityMatchListResponse.load(response.body))
      rescue ::JSON::ParserError
        raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
      end
      [parsed_response, response]
    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
end

#match(request_options: {}, **params) ⇒ Plaid::Types::IdentityMatchResponse

The /identity/match endpoint generates a match score, which indicates how well the provided identity data matches the identity information on file with the account holder's financial institution.

Fields within the balances object will always be null when retrieved by /identity/match. Instead, use the free /accounts/get endpoint to request balance cached data, or /accounts/balance/get or /signal/evaluate for real-time data.

Examples:

client.identity.match(access_token: "access_token")

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:



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
165
166
167
168
169
170
171
172
173
# File 'lib/plaid/identity/client.rb', line 139

def match(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: "identity/match",
    body: Plaid::Identity::Types::IdentityMatchRequest.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::IdentityMatchResponse.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

#refresh(request_options: {}, **params) ⇒ Plaid::Types::IdentityRefreshResponse

/identity/refresh is an optional endpoint for users of the Identity product. It initiates an on-demand extraction to fetch the most up to date Identity information from the Financial Institution. This on-demand extraction takes place in addition to the periodic extractions that automatically occur for any Identity-enabled Item. If changes to Identity are discovered after calling /identity/refresh, Plaid will fire a webhook DEFAULT_UPDATE.

As this endpoint triggers a synchronous request for fresh data, latency may be higher than for other Plaid endpoints (typically less than 10 seconds, but occasionally up to 30 seconds or more); if you encounter errors, you may find it necessary to adjust your timeout period when making requests.

/identity/refresh is offered as an add-on to Identity and has a separate fee model. To request access to this endpoint, submit a product access request or contact your Plaid account manager.

Examples:

client.identity.refresh(access_token: "access_token")

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:



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/plaid/identity/client.rb', line 276

def refresh(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: "identity/refresh",
    body: Plaid::Identity::Types::IdentityRefreshRequest.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::IdentityRefreshResponse.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

#verification ⇒ Plaid::Verification::Client

Returns:

  • (Plaid::Verification::Client)


313
314
315
# File 'lib/plaid/identity/client.rb', line 313

def verification
  @verification ||= Plaid::Identity::Verification::Client.new(client: @client)
end