plaid 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f8aeb4ddef4c58a7a03b9902450a8b87fc82296
4
- data.tar.gz: d9b2daf9205549d39fa5a4f25700ddfae73cf6d7
3
+ metadata.gz: 1b5ab6d107eb42bdc74441ce2e47c068b43b66c0
4
+ data.tar.gz: fd69213bbb1001c8b283edb6742da94647ae9a53
5
5
  SHA512:
6
- metadata.gz: 51e64249b4daad06dd8dd03d648b721204d3383ae493289b1dccf85e80ec2fe5892a83b388d4ec8ac2b417dd47732dafb1f3658a3cfb790947cb94b1866d2aaa
7
- data.tar.gz: 2ab1e1bb607cb87ddaaa3a0adc52946b18dbac5e4112f8db945226985fafd2b93ef10d763eba101cd0ac2fea688c8cec455e660caacab9b8f0972a307d1135f2
6
+ metadata.gz: 8fe17b5426f28e1657f38541b2434c7462f60205d9073b778761a516587e8e809ef582720e5ccad3c08e5cb3f7f2f67a5aad08a0f402c99da0536d8d3129c2b8
7
+ data.tar.gz: 46bc2fe7a2f1da6895e15b4a9c265613f8da13c8966b75c9e069bbe55185a95dbfed3a15f8445a7929aab6d9e5867afe0aeef11ee42a3d1fd9ddd692499c3e09
@@ -1,4 +1,10 @@
1
- # Contributing
1
+ ## Development
2
+
3
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
4
+
5
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
6
+
7
+ ## Contributing
2
8
 
3
9
  1. Make one or more atomic commits, and ensure that each commit has a
4
10
  descriptive commit message. Commit messages should be line wrapped
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in plaid.gemspec
4
3
  gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # Plaid [![Build Status](https://travis-ci.org/plaid/plaid-ruby.svg)](https://travis-ci.org/plaid/plaid-ruby) [![Gem Version](https://badge.fury.io/rb/plaid.svg)](http://badge.fury.io/rb/plaid)
1
+ # plaid-ruby [![Build Status](https://travis-ci.org/plaid/plaid-ruby.svg)](https://travis-ci.org/plaid/plaid-ruby) [![Gem Version](https://badge.fury.io/rb/plaid.svg)](http://badge.fury.io/rb/plaid)
2
2
 
3
- Ruby bindings for the Plaid API.
3
+ The official Ruby bindings for the [Plaid API](https://plaid.com/docs).
4
+
5
+ This module was recently released as version `4.0.x` for Plaid's updated API. Use the gem `plaid-legacy` for version `3.0.x`.
4
6
 
5
7
  ## Installation
6
8
 
@@ -18,306 +20,331 @@ Or install it yourself as:
18
20
 
19
21
  $ gem install plaid
20
22
 
21
- The gem supports Ruby 2.x only.
23
+ The gem supports Ruby 2.1+ only.
22
24
 
23
25
  ## Usage
24
26
 
25
- This gem wraps the Plaid API, which is fully described in the [documentation](http://plaid.com/docs).
27
+ This gem wraps the Plaid API, which is fully described in the [documentation](https://plaid.com/docs/api).
26
28
 
27
- The RubyDoc for the gem is available [here](http://plaid.github.io/plaid-ruby).
29
+ The RubyDoc for the gem is available [here](LINKPLACEHOLDER).
28
30
 
29
- ### Configuring access to Plaid
31
+ ### Creating a Plaid client
30
32
 
31
- Configure the gem with your client id, secret, and the environment you would like to use.
33
+ Create an instance of the client using the `client_id`, `secret`, and `public_key` from your Plaid dashboard along with your environment of choice:
32
34
 
33
35
  ```ruby
34
- Plaid.config do |p|
35
- p.client_id = '<<< Plaid provided client ID >>>'
36
- p.secret = '<<< Plaid provided secret key >>>'
37
- p.env = :tartan # or :production
38
- end
39
- ```
36
+ require 'plaid'
40
37
 
41
- ### Creating a new User
38
+ $client = Plaid::Client.new(env: :sandbox,
39
+ client_id: '***',
40
+ secret: '***',
41
+ public_key: '***')
42
42
 
43
- ```ruby
44
- user = Plaid::User.create(:connect, 'wells', 'plaid_test', 'plaid_good')
45
43
  ```
46
44
 
47
- This call will do a `POST /connect`. The response will contain account information and transactions
48
- for last 30 days, which you can find in `user.accounts` and `user.initial_transactions`, accordingly.
45
+ The `env` field is the environment which the client will be running in. Your choices for the `env` field include:
46
+ - `:sandbox` allows you to do your initial integrations tests against preloaded data without being billed or making expensive API calls. More information about using the API sandbox can be found on the [API Sandbox documentation](https://plaid.com/docs/api/blob/master/SANDBOX.md).
47
+ - `:development` allows you to test against both real and test accounts without being billed. More information about Plaid test accounts can be found in our [API documentation](https://plaid.com/docs/api/#sandbox).
48
+ - `:production` is the production environment where you can launch your production ready application and be charged for your Plaid usage.
49
49
 
50
- If the authentication requires a pin, you can pass it as a named parameter:
50
+ ### Creating a new item
51
+
52
+ A new item can be created by providing a set of credentials, an institution code, and a list of products to create the item with.
51
53
 
52
54
  ```ruby
53
- user = Plaid::User.create(:income, 'usaa', 'plaid_test', 'plaid_good', pin: '1234')
55
+ item = client.item.create(credentials: { username: 'user_good',
56
+ password: 'pass_good',
57
+ pin: '1234' },
58
+ institution_id: 'ins_109509',
59
+ initial_products: %i(auth identity transactions))
54
60
  ```
55
-
56
- To add options such as `login_only` or `webhook`, use `options` argument:
57
-
61
+ The first argument for `client.item.create` is always the credentials in the form of a hash.
58
62
  ```ruby
59
- user = Plaid::User.create(:connect, 'wells', 'plaid_test', 'plaid_good',
60
- options: { login_only: true, webhook: 'https://example.org/callbacks/plaid')
63
+ credentials = { username: 'user_good',
64
+ password: 'pass_good',
65
+ pin: '1234' }
61
66
  ```
67
+ The `pin` field in the credentials hash is not required and does not need to be entered if your institution does not require it.
62
68
 
63
- The first argument for `Plaid::User.create` is always a product you want to add the user to (like,
64
- `:connect`, `:auth`, `:info`, `:income`, or `:risk`). The user object is bound to the product, and subsequent
65
- calls like `user.update` or `user.delete` are done for this product (i.e., `PATCH /info` and `DELETE /info`
66
- for `:info`).
67
-
68
- ### Instantiating a User with an existing access token
69
-
70
- If you've already added the user and saved the access token, you should use `User.load`:
71
-
69
+ A successful, non-MFA (multi-factor authentication) response (HTTP 200) to an item creation will come in the form of a hash where each of these attributes can be accessed by the corresponding string key:
72
70
  ```ruby
73
- user = Plaid::User.load(:risk, 'access_token')
71
+ { "access_token" => String,
72
+ "item" => { "available_products" => [String],
73
+ "billed_products" => [String],
74
+ "error" => Object,
75
+ "institution_id" => String,
76
+ "item_id" => String,
77
+ "webhook" => nullable String },
78
+ "request_id" => String }
74
79
  ```
80
+ The response provides three primary pieces of information:
81
+ - `access_token` is your token to access this item and the item's products in the future such as `auth` or `transactions`
82
+ - `item` provides information about the item such as the `item_id` and `available_products`
83
+ - `request_id` is the identifier for your actual request, this is often used to file tickets if necessary
75
84
 
76
- This won't make any API requests by itself, just set the product and the token in the `User` instance.
85
+ There are other responses you can receive from an item creation such as an MFA response and an error response (they're all in hash form).
77
86
 
78
- ### Exchanging a Link public token for a Plaid access token
87
+ An MFA response (HTTP 210) looks like this:
88
+ ```ruby
89
+ { "access_token" => String,
90
+ "device" => nullable String,
91
+ "device_list" => nullable [Object],
92
+ "mfa_type" => String Enum (device, device_list, questions, selections),
93
+ "questions" => nullable [String],
94
+ "request_id" => String,
95
+ "selections" => nullable [Object] }
96
+ ```
79
97
 
80
- If you have a Link public token, use `User.exchange_token`:
98
+ An example of how an MFA onboarding flow looks like can be seen below in the Examples section.
81
99
 
100
+ If an error occurs during the creation, an error will be thrown. The class for the error has values that you can access by using the following keys.
82
101
  ```ruby
83
- user = Plaid::User.exchange_token('public_token') # bound to :connect product
102
+ { "error_type" => String,
103
+ "error_code" => String,
104
+ "error_message" => String,
105
+ "display_message" => (nullable) String,
106
+ "request_id" => String }
84
107
  ```
108
+ Additional information on the meaning or usage of each field can be found in our [API Error documentation](https://plaid.com/docs/api#errors).
85
109
 
86
- With more options:
110
+ You can also add options such as `transactions.await_results` or `webhook` to your item creation, use keyed arguments:
87
111
 
88
112
  ```ruby
89
- user2 = Plaid::User.exchange_token('public_token', 'account_id', product: :auth)
113
+ item = client.item.create(credentials: { username: 'user_good',
114
+ password: 'pass_good' },
115
+ institution_id: 'ins_109509',
116
+ initial_products: %i(auth identity transactions),
117
+ transactions_await_results: true,
118
+ webhook: 'https://plaid.com/webhook-test')
90
119
  ```
91
120
 
92
- If you want to [move money via Stripe's ACH
93
- API](https://plaid.com/docs/link/stripe/#step-4-write-server-side-handler), you
94
- ought to specify the `account_id` param. In this case the returned user
95
- instance will have the `stripe_bank_account_token` attribute set.
121
+ More information about item creation options can be found in our [API documentation](https://plaid.com/docs/api#post-itemcreate).
96
122
 
97
- ### Upgrading and changing the current product
98
123
 
99
- Plaid supports upgrading a user, i.e. adding it to another product:
124
+ ## Examples
100
125
 
101
- ```ruby
102
- # Create a user in Connect
103
- user = Plaid::User.create(:connect, 'wells', 'plaid_test', 'plaid_good')
126
+ ### Exchanging a Link public token for a Plaid access_token
104
127
 
105
- # Upgrade this user, attaching it to Auth as well (makes a request to /upgrade).
106
- auth_user = user.upgrade(:auth)
107
- ```
128
+ If you have a [Link](https://github.com/plaid/link) `public token`, use this function to get an `access_token`: `client.item.public_token.exchange(public_token)`
108
129
 
109
- The `auth_user` will be a different instance of `User`, attached to Auth, but the access token will be the same.
110
-
111
- Sometimes you know that the user has already been added to another product. To get a `User` instance with
112
- same access token, but different current product, use `User.for_product`:
130
+ An example of the function's usage if you have a `public_token` in hand:
113
131
 
114
132
  ```ruby
115
- # Get a user attached to Connect
116
- user = Plaid::User.load(:connect, 'access_token')
117
-
118
- # Makes no requests
119
- info_user = user.for_product(:info)
133
+ response = client.item.public_token.exchange(public_token)
134
+ access_token = response['access_token']
120
135
  ```
121
136
 
122
- Basically it's the same as:
137
+ ### Handle MFA during item creation
123
138
 
139
+ If MFA is requested by the financial institution, there will be additional steps required to finish the item creation flow:
124
140
  ```ruby
125
- info_user = Plaid::User.load(:info, 'access_token')
126
- ```
141
+ require 'plaid'
142
+
143
+ def answer_mfa(client, access_token, data)
144
+ case data['mfa_type']
145
+ when 'questions'
146
+ answer_questions(client, access_token, data['questions'])
147
+ when 'device_list'
148
+ answer_device_list(client, access_token, data['device_list'])
149
+ when 'selections'
150
+ answer_selections(client, access_token, data['selections'])
151
+ when 'device'
152
+ answer_device(client, access_token, data['device'])
153
+ else
154
+ raise 'Unknown MFA type from Plaid'
155
+ end
156
+ end
127
157
 
128
- ### MFA (Multi-Factor Authorization)
158
+ def answer_questions(client, access_token, _questions)
159
+ # We have magically inferred the answer here, so we respond immediately.
160
+ # In the real world, we would present the questions to our user and
161
+ # submit their responses.
162
+ answers = ['answer_0_0']
163
+ client.item.mfa(access_token, 'questions', answers)
164
+ end
129
165
 
130
- If MFA is requested by the financial institution, the `User.create` call would behave
131
- a bit differently:
166
+ def answer_device_list(client, access_token, device_list)
167
+ # We have picked the first device here.
168
+ # In the real world, we would ask our user which device the passcode
169
+ # should be sent to.
170
+ device = device_list[0]['device_id']
171
+ client.item.mfa(access_token, 'device_list', [device])
172
+ end
132
173
 
133
- ```ruby
134
- user = Plaid::User.create(:auth, 'wells', 'plaid_test', 'plaid_good')
174
+ def answer_device(client, access_token, _device)
175
+ # Another magically inferred answer.
176
+ # In the real world, we would ask our user for the passcode they received.
177
+ client.item.mfa(access_token, 'device', ['1234'])
178
+ end
179
+
180
+ def answer_selections(client, access_token, _selections)
181
+ # We have magically inferred the answer here, so we respond immediately.
182
+ # In the real world, we would present the selection question and choices
183
+ # to our user and submit their responses.
184
+ answers = %w(tomato ketchup)
185
+ client.item.mfa(access_token, 'selections', answers)
186
+ end
135
187
 
136
- user.accounts #=> nil
137
- user.mfa? #=> true
138
- user.mfa_type #=> :questions
139
- user.mfa #=> [{question: "What's the nickname of the person who created Ruby?"}]
188
+ begin
189
+ client = Plaid::Client.new(env: :sandbox,
190
+ client_id: '***',
191
+ secret: '***',
192
+ public_key: '***')
193
+
194
+ response = client.item.create(credentials: { username: 'user_good',
195
+ password: 'mfa_device' },
196
+ institution_id: 'ins_109508',
197
+ initial_products: %i(transactions auth))
198
+
199
+ access_token = response['access_token']
200
+ response = answer_mfa(client, access_token, response) while response.key?('mfa_type')
201
+ rescue Plaid::PlaidError
202
+ raise 'Error in main flow.'
203
+ end
140
204
  ```
141
205
 
142
- In this case you'll have to submit the answer to the question:
206
+ ### Deleting an item
143
207
 
144
208
  ```ruby
145
- user.mfa_step('matz') # This is the correct answer!
146
-
147
- user.mfa? #=> false
148
- user.mfa_type #=> nil
149
- user.mfa #=> nil
150
- user.accounts #=> [<Plaid::Account ...>, ...]
151
- ```
209
+ require 'plaid'
152
210
 
153
- The code-based MFA workflow is similar. Basically you need to call `user.mfa_step(...)`
154
- until `user.mfa?` becomes false.
211
+ client = Plaid::Client.new(env: :sandbox,
212
+ client_id: '***',
213
+ secret: '***',
214
+ public_key: '***')
155
215
 
156
- ### Obtaining user-related data
157
-
158
- If you have a live `User` instance, you can use following methods
159
- (independent of instance's current product):
216
+ response = client.item.create(credentials: { username: 'user_good',
217
+ password: 'pass_good' },
218
+ institution_id: 'ins_109509',
219
+ initial_products: %i(auth identity transactions))
160
220
 
161
- * `user.transactions(...)`. Makes a `/connect/get` request.
162
- * `user.auth(sync: false)`. Makes an `/auth/get` request.
163
- * `user.info(sync: false)`. Makes an `/info/get` request.
164
- * `user.income(sync: false)`. Makes an `/income/get` request.
165
- * `user.risk(sync: false)`. Makes an `/risk/get` request.
166
- * `user.balance`. Makes an `/balance` request.
221
+ access_token = response['access_token']
167
222
 
168
- All of these methods return appropriate data, but they also update the cached `user.accounts`. That is,
169
- if you user has access to Auth and Risk products, the following code:
223
+ # Provide the access_token for the Item you want to delete
224
+ client.item.delete(access_token)
225
+ ```
170
226
 
227
+ ### Get paginated transactions
171
228
  ```ruby
172
- user = User.load(:auth, 'access_token')
173
- user.auth
174
- user.risk
229
+ require 'plaid'
230
+
231
+ client = Plaid::Client.new(env: :sandbox,
232
+ client_id: '***',
233
+ secret: '***',
234
+ public_key: '***')
235
+
236
+ item_response = client.item.create(credentials: { username: 'user_good',
237
+ password: 'pass_good' },
238
+ institution_id: 'ins_109509',
239
+ initial_products: %i(auth identity transactions))
240
+
241
+ access_token = item_response['access_token']
242
+
243
+ transaction_response = client.transactions.get(access_token, '2016-07-12', '2017-01-09')
244
+ transactions = transaction_response['transactions']
245
+
246
+ # the transactions in the response are paginated, so make multiple calls while
247
+ # increasing the offset to retrieve all transactions
248
+ while transactions.length < response['total_transactions']
249
+ transaction_response = client.transactions.get(access_token,
250
+ '2016-07-12',
251
+ '2017-01-09',
252
+ offset: transactions.length)
253
+ transactions += transaction_response['transactions']
254
+ end
255
+
175
256
  ```
176
- will result in `user.accounts` having both routing number and risk information for all the accounts. The
177
- subsequent `user.balance` call will just update the current balance, not touching the routing and risk information.
178
257
 
179
- The `sync` flag, if set to true, will result in updating the information from the server even if it has already been
180
- loaded. Otherwise cached information will be returned:
258
+ ### Obtaining user-related data
181
259
 
260
+ If you have an `access_token`, you can use following code to retreive data:
182
261
  ```ruby
183
- user = User.load(:auth, 'access_token') # Just set the token
184
- user.auth # POST /auth/get
185
- user.auth # No POST, return cached info
186
- user.auth(sync: true) # POST /auth/get again
187
- ```
262
+ require 'plaid'
188
263
 
189
- Same goes for other methods, except `User#transactions` and `User#balance` which always make requests to the API.
264
+ client = Plaid::Client.new(env: :sandbox,
265
+ client_id: '***',
266
+ secret: '***',
267
+ public_key: '***')
190
268
 
191
- ### Categories
269
+ item_response = client.item.create(credentials: { username: 'user_good',
270
+ password: 'pass_good' },
271
+ institution_id: 'ins_109509',
272
+ initial_products: %i(auth identity transactions))
192
273
 
193
- You can request category information:
274
+ access_token = item_response['access_token']
194
275
 
195
- ```ruby
196
- cats = Plaid::Category.all # Array of all known categories
197
- cat = Plaid::Category.get('17001013') # A single category by its ID
198
- ```
276
+ auth_response = client.auth.get(access_token)
277
+ auth = auth_response['auth']
199
278
 
200
- ### Institutions
279
+ ```
201
280
 
202
- Financial institution information is available via `Plaid::Institution`.
281
+ ### Create a Stripe bank_account_token
203
282
 
283
+ Exchange a Plaid Link `public_token` for an API `access_token` and a Stripe `bank_account_token`:
204
284
  ```ruby
205
- insts = Plaid::Institution.all(count: 20, offset: 20) # A page
206
- inst = Plaid::Institution.get('5301a93ac140de84910000e0') # A single institution by its ID
285
+ require 'plaid'
207
286
 
208
- res = Plaid::Institution.search(query: 'c') # Lookup by name
209
- ```
287
+ client = Plaid::Client.new(env: :sandbox,
288
+ client_id: '***',
289
+ secret: '***',
290
+ public_key: '***')
210
291
 
211
- ### Webhooks
292
+ exchange_token_response = client.item.public_token.exchange('[Plaid Link public_token]')
293
+ access_token = exchange_token_response['access_token']
212
294
 
213
- You can register to receive [Webhooks](https://plaid.com/docs/api/#webhook) from Plaid when your users have new events. If you do, you'll receive `POST` requests with JSON.
295
+ stripe_response = client.processor.stripe.bank_account_token.create(access_token, '[Account ID]')
296
+ bank_account_token = stripe_response['stripe_bank_account_token']
214
297
 
215
- E.g. Initial Transaction Webhook:
216
- ```json
217
- {
218
- "message": "Initial transaction pull finished",
219
- "access_token": "xxxxx",
220
- "total_transactions": 123,
221
- "code": 0
222
- }
223
298
  ```
224
299
 
225
- You should parse that JSON into a Ruby Hash with String keys (eg. `webhook_hash = JSON.parse(json_string)`). Then, you can convert that Hash into a Ruby object using `Plaid::Webhook`:
300
+ There are also a number of other methods you can use to retrieve data:
226
301
 
227
- ```ruby
228
- webhook = Plaid::Webhook.new(webhook_hash)
229
-
230
- # Was that the Initial Transaction Webhook?
231
- webhook.initial_transaction?
232
- access_token = webhook.access_token
233
- total_transactions = webhook.total_transactions
234
-
235
- # Or did Historical Transactions become available?
236
- webhook.historical_transaction?
237
- access_token = webhook.access_token
238
- total_transactions = webhook.total_transactions
239
-
240
- # Or did Normal Transactions become available?
241
- webhook.normal_transaction?
242
- access_token = webhook.access_token
243
- total_transactions = webhook.total_transactions
244
-
245
- # Or maybe a transaction was removed?
246
- webhook.removed_transaction?
247
- access_token = webhook.access_token
248
- removed_transactions_ids = webhook.removed_transactions_ids
249
-
250
- # Or was the User's Webhook Updated?
251
- webhook.user_webhook_updated?
252
- access_token = webhook.access_token
253
-
254
- # Otherwise, was it an error?
255
- webhook.error_response?
256
- # Which error?
257
- error = webhook.error
258
- ```
302
+ * `client.accounts.get(access_code, ...)`: accounts
303
+ * `client.accounts.balance.get(access_code, ...)`: real-time balances
304
+ * `client.auth.get(access_code, ...)`: auth
305
+ * `client.identity.get(access_code, ...)`: identity
306
+ * `client.transactions.get(access_code, ...)`: transactions
307
+ * `client.credit_details.get(access_code, ...)`: credit details
259
308
 
260
- ### Custom clients
309
+ All of these methods return appropriate data. More information and especially information about fields available in all the returned hashes can be found on the [API documentation](https://plaid.com/docs/api).
261
310
 
262
- It's possible to use several Plaid environments and/or credentials in one app by
263
- explicit instantiation of `Plaid::Client`:
311
+ ### Categories
264
312
 
265
- ```ruby
266
- # Configuring the global client (Plaid.client) which is used by default
267
- Plaid.config do |p|
268
- p.client_id = 'client_id_1'
269
- p.secret = 'secret_1'
270
- p.env = :tartan
271
- end
313
+ You can request category information:
272
314
 
273
- # Creating a custom client
274
- api = Plaid::Client.new(client_id: 'client_id_2', secret: 'secret_2', env: :production)
315
+ ```ruby
316
+ categories = client.categories.get # Array of all known categories
317
+ ```
275
318
 
276
- # Tartan user (using default client)
277
- user1 = Plaid::User.create(:connect, 'wells', 'plaid_test', 'plaid_good')
319
+ ### Institutions
278
320
 
279
- # Api user (using api client)
280
- user2 = Plaid::User.create(:connect, 'wells', 'plaid_test', 'plaid_good', client: api)
321
+ Financial institution information is available as shown below where the function arguments represent count and offset:
281
322
 
282
- # Lookup an institution in production
283
- res = Plaid::Institution.search(query: 'c', client: api)
323
+ ```ruby
324
+ institutions = client.institutions.get(count: 3, offset: 1)
284
325
  ```
285
326
 
286
- The `client` option can be passed to the following methods:
287
-
288
- * `User.create`
289
- * `User.load`
290
- * `User.exchange_token`
291
- * `Category.all`
292
- * `Category.get`
293
- * `Institution.all`
294
- * `Institution.get`
295
- * `Institution.search`
296
- * `Institution.search_by_id`
297
-
298
- ### Errors
327
+ ## Errors
299
328
 
300
329
  Any methods making API calls will result in an exception raised unless the response code is "200: Success" or
301
- "201: MFA Required".
330
+ "210: MFA Required".
302
331
 
303
- `Plaid::BadRequestError` is raised when status code is "400: Bad Request".
332
+ `Plaid::InvalidRequestError` is returned when the request is malformed and cannot be processed.
304
333
 
305
- `Plaid::UnauthorizedError` is raised when status code is "401: Unauthorized".
334
+ `Plaid::InvalidInputError` is returned when all fields are provided and are in the correct format, but the values provided are incorrect in some way.
306
335
 
307
- `Plaid::RequestFailedError` is raised when status code is "402: Request Failed".
336
+ `Plaid::RateLimitExceededError` returned when the request is valid but has exceeded established rate limits.
308
337
 
309
- `Plaid::NotFoundError` is raised when status code is "404: Cannot be Found".
338
+ `Plaid::APIError` is returned during planned maintenance windows and in response to API internal server errors.
310
339
 
311
- `Plaid::ServerError` is raised when status code is "50X: Server Error".
340
+ `Plaid::ItemError` indicates that information provided for the Item (such as credentials or MFA) may be invalid or that the Item is not supported on Plaid's platform.
312
341
 
313
342
  Read more about response codes and their meaning in the
314
- [Plaid documentation](https://plaid.com/docs/api/#response-codes).
315
-
316
- ## Development
343
+ [Plaid documentation](https://plaid.com/docs/api).
317
344
 
318
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
345
+ ## Network Timeout
319
346
 
320
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
347
+ A network timeout value is set in the `lib/plaid/connect.rb` file. It is currently defaulted at 600 (in seconds) which equates to about 10 minutes. Some requests from the Plaid API may take longer than others and we want to make sure that all valid requests have a chance to complete. Adjust this value if necessary.
321
348
 
322
349
  ## Contributing
323
350