plaid 4.1.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +23 -0
- data/.rubocop.yml +18 -0
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile.lock +58 -0
- data/README.md +50 -39
- data/Rakefile +7 -10
- data/lib/plaid.rb +40 -1
- data/lib/plaid/client.rb +72 -63
- data/lib/plaid/errors.rb +46 -41
- data/lib/plaid/middleware.rb +11 -6
- data/lib/plaid/models.rb +683 -0
- data/lib/plaid/products/accounts.rb +38 -35
- data/lib/plaid/products/auth.rb +32 -19
- data/lib/plaid/products/base_product.rb +69 -0
- data/lib/plaid/products/categories.rb +11 -8
- data/lib/plaid/products/credit_details.rb +31 -19
- data/lib/plaid/products/identity.rb +27 -11
- data/lib/plaid/products/income.rb +22 -11
- data/lib/plaid/products/institutions.rb +50 -28
- data/lib/plaid/products/item.rb +251 -136
- data/lib/plaid/products/processor.rb +104 -34
- data/lib/plaid/products/sandbox.rb +21 -20
- data/lib/plaid/products/transactions.rb +50 -45
- data/lib/plaid/version.rb +1 -1
- data/plaid.gemspec +10 -8
- metadata +51 -19
- data/circle.yml +0 -9
data/lib/plaid/products/item.rb
CHANGED
@@ -1,21 +1,27 @@
|
|
1
1
|
module Plaid
|
2
2
|
# Public: Class used to call the AccessToken sub-product.
|
3
|
-
class AccessToken
|
4
|
-
def initialize(client)
|
5
|
-
@client = client
|
6
|
-
end
|
7
|
-
|
3
|
+
class AccessToken < BaseProduct
|
8
4
|
# Public: Rotate your access_token, keeping it attached to the item
|
9
5
|
#
|
10
|
-
# Does a POST /item/access_token/invalidate call which will give you a new
|
11
|
-
# allowing you to rotate access_tokens
|
6
|
+
# Does a POST /item/access_token/invalidate call which will give you a new
|
7
|
+
# access_token allowing you to rotate access_tokens.
|
12
8
|
#
|
13
|
-
# access_token - access_token to invalidate and rotate
|
9
|
+
# access_token - The String access_token to invalidate and rotate.
|
14
10
|
#
|
15
|
-
# Returns
|
11
|
+
# Returns an InvalidateResponse object with the new access_token and
|
12
|
+
# request id.
|
16
13
|
def invalidate(access_token)
|
17
|
-
|
18
|
-
|
14
|
+
post_with_auth 'item/access_token/invalidate',
|
15
|
+
InvalidateResponse,
|
16
|
+
access_token: access_token
|
17
|
+
end
|
18
|
+
|
19
|
+
# Public: Response for /item/access_token/invalidate.
|
20
|
+
class InvalidateResponse < Models::BaseResponse
|
21
|
+
##
|
22
|
+
# :attr_reader:
|
23
|
+
# Public: The String new access token.
|
24
|
+
property :new_access_token
|
19
25
|
end
|
20
26
|
|
21
27
|
# Public: Generate a new API access_token for a legacy access_token
|
@@ -25,136 +31,188 @@ module Plaid
|
|
25
31
|
#
|
26
32
|
# access_token_v1 - legacy access_token
|
27
33
|
#
|
28
|
-
# Returns
|
34
|
+
# Returns an UpdateVersionResponse object with new access_token and item
|
35
|
+
# ID.
|
29
36
|
def update_version(access_token_v1)
|
30
|
-
|
31
|
-
|
37
|
+
post_with_auth 'item/access_token/update_version',
|
38
|
+
UpdateVersionResponse,
|
39
|
+
access_token_v1: access_token_v1
|
32
40
|
end
|
33
|
-
end
|
34
41
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
42
|
+
# Public: Response for /item/access_token/update_version.
|
43
|
+
class UpdateVersionResponse < Models::BaseResponse
|
44
|
+
##
|
45
|
+
# :attr_reader:
|
46
|
+
# Public: The String new access token for use.
|
47
|
+
property :access_token
|
48
|
+
|
49
|
+
##
|
50
|
+
# :attr_reader:
|
51
|
+
# Public: The String item ID.
|
52
|
+
property :item_id
|
39
53
|
end
|
54
|
+
end
|
40
55
|
|
56
|
+
# Public: Class used to call the Credentials sub-product.
|
57
|
+
class Credentials < BaseProduct
|
41
58
|
# Public: Update credentials for an access_token.
|
42
59
|
#
|
43
|
-
# Does a POST /item/credentials/update call which is used to update
|
44
|
-
# if the credentials become no longer valid
|
60
|
+
# Does a POST /item/credentials/update call which is used to update
|
61
|
+
# credentials if the credentials become no longer valid.
|
45
62
|
#
|
46
63
|
# access_token - access_token who's item to update credentials for
|
47
64
|
# credentials - New credentials
|
48
65
|
#
|
49
|
-
# Returns
|
66
|
+
# Returns an UpdateResponse object with either an ItemStatus or MFA
|
67
|
+
# response.
|
50
68
|
def update(access_token, credentials)
|
51
|
-
|
52
|
-
|
53
|
-
|
69
|
+
post_with_auth 'item/credentials/update',
|
70
|
+
UpdateResponse,
|
71
|
+
access_token: access_token,
|
72
|
+
credentials: credentials
|
54
73
|
end
|
55
|
-
end
|
56
74
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
75
|
+
# Public: Response for /item/credentials/update.
|
76
|
+
class UpdateResponse < Models::BaseResponse
|
77
|
+
##
|
78
|
+
# :attr_reader:
|
79
|
+
# Public: The item: Plaid::Models::Item.
|
80
|
+
property :item, coerce: Models::Item
|
61
81
|
end
|
82
|
+
end
|
62
83
|
|
84
|
+
# Public: Class used to call the PublicToken sub-product
|
85
|
+
class PublicToken < BaseProduct
|
63
86
|
# Public: Creates a public token from an access_token.
|
64
87
|
#
|
65
|
-
# Does a POST /item/public_token/create call which can be used to
|
66
|
-
# in update mode
|
88
|
+
# Does a POST /item/public_token/create call which can be used to
|
89
|
+
# initialize Link in update mode.
|
67
90
|
#
|
68
91
|
# access_token - access_token to create a public token for
|
69
92
|
#
|
70
|
-
# Returns a
|
93
|
+
# Returns a CreateResponse object with a public token and expiration info.
|
71
94
|
def create(access_token)
|
72
|
-
|
73
|
-
|
95
|
+
post_with_auth 'item/public_token/create',
|
96
|
+
CreateResponse,
|
97
|
+
access_token: access_token
|
98
|
+
end
|
99
|
+
|
100
|
+
# Public: Response for /item/public_token/create.
|
101
|
+
class CreateResponse < Models::BaseResponse
|
102
|
+
##
|
103
|
+
# :attr_reader:
|
104
|
+
# Public: The String token.
|
105
|
+
property :public_token
|
106
|
+
|
107
|
+
##
|
108
|
+
# :attr_reader:
|
109
|
+
# Public: The String token expiration time.
|
110
|
+
property :expiration
|
74
111
|
end
|
75
112
|
|
76
113
|
# Public: Exchange a public token for an access_token
|
77
114
|
#
|
78
|
-
# Does a POST /item/public_token/exchange call helps you exchange a public
|
79
|
-
# (possibly from Plaid Link) for an access_token you can use in the
|
115
|
+
# Does a POST /item/public_token/exchange call helps you exchange a public
|
116
|
+
# token (possibly from Plaid Link) for an access_token you can use in the
|
117
|
+
# rest of your app.
|
80
118
|
#
|
81
|
-
# public_token - Public token to get an access_token from
|
119
|
+
# public_token - The Public token to get an access_token from.
|
82
120
|
#
|
83
|
-
# Returns
|
121
|
+
# Returns an ExchangeResponse object with an access_token and request id.
|
84
122
|
def exchange(public_token)
|
85
|
-
|
86
|
-
|
123
|
+
post_with_auth 'item/public_token/exchange',
|
124
|
+
ExchangeResponse,
|
125
|
+
public_token: public_token
|
87
126
|
end
|
88
|
-
end
|
89
127
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
128
|
+
# Public: Response for /item/public_token/exchange.
|
129
|
+
class ExchangeResponse < Models::BaseResponse
|
130
|
+
##
|
131
|
+
# :attr_reader:
|
132
|
+
# Public: The String access token for use with API.
|
133
|
+
property :access_token
|
134
|
+
|
135
|
+
##
|
136
|
+
# :attr_reader:
|
137
|
+
# Public: The String item ID.
|
138
|
+
property :item_id
|
94
139
|
end
|
140
|
+
end
|
95
141
|
|
96
|
-
|
142
|
+
# Public: Class used to call the Webhook sub-product
|
143
|
+
class Webhook < BaseProduct
|
144
|
+
# Public: Update webhook for an access_token.
|
97
145
|
#
|
98
146
|
# Does a POST /item/webhook/update call which is used to update webhook
|
99
|
-
# for a particular access_token
|
100
|
-
# transactions for an item are updated and ready
|
147
|
+
# for a particular access_token. Webhooks are used to be notified when
|
148
|
+
# transactions for an item are updated and ready.
|
101
149
|
#
|
102
|
-
# access_token - access_token
|
103
|
-
# webhook -
|
150
|
+
# access_token - The access_token of an item to update webhook for.
|
151
|
+
# webhook - The new webhook link.
|
104
152
|
#
|
105
|
-
# Returns
|
153
|
+
# Returns an UpdateResponse object with either an ItemStatus or MFA
|
154
|
+
# response.
|
106
155
|
def update(access_token, webhook)
|
107
|
-
|
108
|
-
|
109
|
-
|
156
|
+
post_with_auth 'item/webhook/update',
|
157
|
+
UpdateResponse,
|
158
|
+
access_token: access_token,
|
159
|
+
webhook: webhook
|
160
|
+
end
|
161
|
+
|
162
|
+
# Public: Response for /item/webhook/update.
|
163
|
+
class UpdateResponse < Models::BaseResponse
|
164
|
+
##
|
165
|
+
# :attr_reader:
|
166
|
+
# Public: The item: Plaid::Models::Item.
|
167
|
+
property :item, coerce: Models::Item
|
110
168
|
end
|
111
169
|
end
|
112
170
|
|
113
171
|
# Public: Class used to call the Item product.
|
114
|
-
class Item
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
172
|
+
class Item < BaseProduct
|
173
|
+
##
|
174
|
+
# :attr_reader:
|
175
|
+
# Public: The Plaid::AccessToken product accessor.
|
176
|
+
subproduct :access_token
|
119
177
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
178
|
+
##
|
179
|
+
# :attr_reader:
|
180
|
+
# Public: The Plaid::Credentials product accessor.
|
181
|
+
subproduct :credentials
|
124
182
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
183
|
+
##
|
184
|
+
# :attr_reader:
|
185
|
+
# Public: The Plaid::PublicToken product accessor.
|
186
|
+
subproduct :public_token
|
129
187
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
def initialize(client)
|
136
|
-
@client = client
|
137
|
-
end
|
188
|
+
##
|
189
|
+
# :attr_reader:
|
190
|
+
# Public: The Plaid::Webhook product accessor.
|
191
|
+
subproduct :webhook
|
138
192
|
|
139
193
|
# Public: Creates an item.
|
140
194
|
#
|
141
195
|
# Does a POST /item/create call which attemps to create a new item for you
|
142
|
-
# possibly returning a success, error, or multi-factor authentication
|
143
|
-
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
# (optional)
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
196
|
+
# possibly returning a success, error, or multi-factor authentication
|
197
|
+
# response.
|
198
|
+
#
|
199
|
+
# credentials - Institution credentials to create item with.
|
200
|
+
# institution_id - Institution ID to create item with.
|
201
|
+
# initial_products - Initial products to create the item with,
|
202
|
+
# i.e. [:transactions].
|
203
|
+
# transactions_start_date - date at which to begin the item's initial
|
204
|
+
# transaction pull (optional).
|
205
|
+
# transactions_end_date - date at which to end the item's initial
|
206
|
+
# transaction pull (optional).
|
207
|
+
# transactions_await_results - if true, the initial transaction pull will
|
208
|
+
# be performed synchronously (optional).
|
209
|
+
# webhook - webhook to associate with the item
|
210
|
+
# (optional).
|
211
|
+
# options - Additional options to merge into API
|
212
|
+
# request.
|
213
|
+
#
|
214
|
+
# Returns an ItemResponse object with item info including access_token and
|
215
|
+
# ItemStatus, or MFA response or error.
|
158
216
|
def create(credentials:,
|
159
217
|
institution_id:,
|
160
218
|
initial_products:,
|
@@ -164,67 +222,115 @@ module Plaid
|
|
164
222
|
webhook: nil,
|
165
223
|
options: nil)
|
166
224
|
|
167
|
-
transactions_options = {}
|
168
|
-
unless transactions_start_date.nil?
|
169
|
-
transactions_options[:start_date] = Plaid.convert_to_date_string(transactions_start_date)
|
170
|
-
end
|
171
|
-
unless transactions_end_date.nil?
|
172
|
-
transactions_options[:end_date] = Plaid.convert_to_date_string(transactions_end_date)
|
173
|
-
end
|
174
|
-
unless transactions_await_results.nil?
|
175
|
-
transactions_options[:await_results] = transactions_await_results
|
176
|
-
end
|
177
|
-
|
178
225
|
options_payload = {}
|
179
|
-
|
226
|
+
|
227
|
+
txn_options = transaction_options transactions_start_date,
|
228
|
+
transactions_end_date,
|
229
|
+
transactions_await_results
|
230
|
+
|
231
|
+
options_payload[:transactions] = txn_options if txn_options != {}
|
180
232
|
options_payload[:webhook] = webhook unless webhook.nil?
|
181
233
|
options_payload = options_payload.merge(options) unless options.nil?
|
182
234
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
235
|
+
post_with_auth 'item/create',
|
236
|
+
ItemResponse,
|
237
|
+
credentials: credentials,
|
238
|
+
institution_id: institution_id,
|
239
|
+
initial_products: initial_products,
|
240
|
+
options: options_payload
|
241
|
+
end
|
242
|
+
|
243
|
+
private def transaction_options(start_date, end_date, await_results)
|
244
|
+
{}.tap do |options|
|
245
|
+
options[:start_date] = Plaid.convert_to_date_string(start_date) \
|
246
|
+
if start_date
|
247
|
+
|
248
|
+
options[:end_date] = Plaid.convert_to_date_string(end_date) \
|
249
|
+
if end_date
|
250
|
+
|
251
|
+
options[:await_results] = await_results if await_results
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
# Public: Response for /item/create and /item/mfa endpoints.
|
256
|
+
class ItemResponse < Models::BaseResponse
|
257
|
+
##
|
258
|
+
# :attr_reader:
|
259
|
+
# Public: The String access_token to use with API.
|
260
|
+
property :access_token
|
261
|
+
|
262
|
+
##
|
263
|
+
# :attr_reader:
|
264
|
+
# Public: The Plaid::Models::Item object, returned if item has been
|
265
|
+
# successfully created.
|
266
|
+
property :item, coerce: Models::Item
|
267
|
+
|
268
|
+
##
|
269
|
+
# :attr_reader:
|
270
|
+
# Public: The MFA/OTP device information: Plaid::Models::MFA::Device.
|
271
|
+
property :device, coerce: Models::MFA::Device
|
272
|
+
|
273
|
+
##
|
274
|
+
# :attr_reader:
|
275
|
+
# Public: The list of devices to send the OTP to:
|
276
|
+
# Array of Plaid::Models::MFA::DeviceListElement.
|
277
|
+
property :device_list, coerce: Array[Models::MFA::DeviceListElement]
|
278
|
+
|
279
|
+
##
|
280
|
+
# :attr_reader:
|
281
|
+
# Public: The String MFA type. E.g. "device_list", "device", "questions",
|
282
|
+
# "selections".
|
283
|
+
property :mfa_type
|
284
|
+
|
285
|
+
##
|
286
|
+
# :attr_reader:
|
287
|
+
# Public: The Array of String MFA questions.
|
288
|
+
property :questions
|
289
|
+
|
290
|
+
##
|
291
|
+
# :attr_reader:
|
292
|
+
# Public: The Array of MFA selections: Plaid::Models::MFA::Selection.
|
293
|
+
property :selections, coerce: Array[Models::MFA::Selection]
|
188
294
|
end
|
189
295
|
|
190
296
|
# Public: Submit an MFA step.
|
191
297
|
#
|
192
|
-
# Does a POST /item/mfa call which gives you the ability to
|
298
|
+
# Does a POST /item/mfa call which gives you the ability to respond to an
|
299
|
+
# MFA.
|
193
300
|
#
|
194
|
-
# access_token - To submit MFA step for
|
195
|
-
# mfa_type - The MFA type indicated in the MFA response
|
196
|
-
# responses - List of answers/responses to MFA
|
301
|
+
# access_token - To submit MFA step for.
|
302
|
+
# mfa_type - The MFA type indicated in the MFA response.
|
303
|
+
# responses - List of answers/responses to MFA.
|
197
304
|
#
|
198
|
-
# Returns
|
305
|
+
# Returns an ItemResponse instance.
|
199
306
|
def mfa(access_token, mfa_type, responses)
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
307
|
+
post_with_auth 'item/mfa',
|
308
|
+
ItemResponse,
|
309
|
+
access_token: access_token,
|
310
|
+
mfa_type: mfa_type,
|
311
|
+
responses: responses
|
204
312
|
end
|
205
313
|
|
206
|
-
# Public: Get information about an item
|
314
|
+
# Public: Get information about an item.
|
207
315
|
#
|
208
|
-
# Does a POST /item/get call which returns information about an item or
|
316
|
+
# Does a POST /item/get call which returns information about an item or
|
317
|
+
# ItemStatus.
|
209
318
|
#
|
210
319
|
# access_token - access_token who's item to fetch status for
|
211
320
|
#
|
212
|
-
# Returns a
|
321
|
+
# Returns a GetResponse object with item information.
|
213
322
|
def get(access_token)
|
214
|
-
|
215
|
-
|
323
|
+
post_with_auth 'item/get',
|
324
|
+
GetResponse,
|
325
|
+
access_token: access_token
|
216
326
|
end
|
217
327
|
|
218
|
-
# Public:
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
# Returns a parsed JSON of delete result
|
225
|
-
def delete(access_token)
|
226
|
-
payload = { access_token: access_token }
|
227
|
-
@client.post_with_auth('item/delete', payload)
|
328
|
+
# Public: Response for /item/get.
|
329
|
+
class GetResponse < Models::BaseResponse
|
330
|
+
##
|
331
|
+
# :attr_reader:
|
332
|
+
# Public: The item: Plaid::Models::Item.
|
333
|
+
property :item, coerce: Models::Item
|
228
334
|
end
|
229
335
|
|
230
336
|
# Public: Removes an item
|
@@ -233,10 +339,19 @@ module Plaid
|
|
233
339
|
#
|
234
340
|
# access_token - access_token who's item to remove
|
235
341
|
#
|
236
|
-
# Returns a
|
342
|
+
# Returns a RemoveResponse object with remove result.
|
237
343
|
def remove(access_token)
|
238
|
-
|
239
|
-
|
344
|
+
post_with_auth 'item/remove',
|
345
|
+
RemoveResponse,
|
346
|
+
access_token: access_token
|
347
|
+
end
|
348
|
+
|
349
|
+
# Public: Response for /item/remove.
|
350
|
+
class RemoveResponse < Models::BaseResponse
|
351
|
+
##
|
352
|
+
# :attr_reader:
|
353
|
+
# Public: The Boolean flag meaning successful removal.
|
354
|
+
property :removed
|
240
355
|
end
|
241
356
|
end
|
242
357
|
end
|