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 +4 -4
- data/CONTRIBUTING.md +7 -1
- data/Gemfile +0 -1
- data/LICENSE.txt +21 -0
- data/README.md +233 -206
- data/Rakefile +1 -2
- data/bin/console +8 -7
- data/circle.yml +3 -0
- data/lib/plaid.rb +15 -60
- data/lib/plaid/client.rb +120 -52
- data/lib/plaid/connect.rb +75 -0
- data/lib/plaid/errors.rb +60 -24
- data/lib/plaid/products/accounts.rb +60 -0
- data/lib/plaid/products/auth.rb +29 -0
- data/lib/plaid/products/categories.rb +18 -0
- data/lib/plaid/products/credit_details.rb +21 -0
- data/lib/plaid/products/identity.rb +20 -0
- data/lib/plaid/products/income.rb +20 -0
- data/lib/plaid/products/institutions.rb +51 -0
- data/lib/plaid/products/item.rb +230 -0
- data/lib/plaid/products/processor.rb +48 -0
- data/lib/plaid/products/sandbox.rb +32 -0
- data/lib/plaid/products/transactions.rb +74 -0
- data/lib/plaid/version.rb +1 -1
- data/plaid.gemspec +13 -8
- metadata +21 -61
- data/CHANGELOG.md +0 -34
- data/LICENSE +0 -20
- data/UPGRADING.md +0 -60
- data/lib/plaid/account.rb +0 -144
- data/lib/plaid/category.rb +0 -62
- data/lib/plaid/connector.rb +0 -172
- data/lib/plaid/income.rb +0 -106
- data/lib/plaid/info.rb +0 -65
- data/lib/plaid/institution.rb +0 -253
- data/lib/plaid/risk.rb +0 -34
- data/lib/plaid/transaction.rb +0 -128
- data/lib/plaid/user.rb +0 -507
- data/lib/plaid/webhook.rb +0 -153
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b5ab6d107eb42bdc74441ce2e47c068b43b66c0
|
4
|
+
data.tar.gz: fd69213bbb1001c8b283edb6742da94647ae9a53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fe17b5426f28e1657f38541b2434c7462f60205d9073b778761a516587e8e809ef582720e5ccad3c08e5cb3f7f2f67a5aad08a0f402c99da0536d8d3129c2b8
|
7
|
+
data.tar.gz: 46bc2fe7a2f1da6895e15b4a9c265613f8da13c8966b75c9e069bbe55185a95dbfed3a15f8445a7929aab6d9e5867afe0aeef11ee42a3d1fd9ddd692499c3e09
|
data/CONTRIBUTING.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
|
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
data/LICENSE.txt
ADDED
@@ -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
|
-
#
|
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.
|
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](
|
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](
|
29
|
+
The RubyDoc for the gem is available [here](LINKPLACEHOLDER).
|
28
30
|
|
29
|
-
###
|
31
|
+
### Creating a Plaid client
|
30
32
|
|
31
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
48
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
60
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
124
|
+
## Examples
|
100
125
|
|
101
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
116
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
131
|
-
|
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
|
-
|
134
|
-
|
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
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
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
|
-
|
206
|
+
### Deleting an item
|
143
207
|
|
144
208
|
```ruby
|
145
|
-
|
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
|
-
|
154
|
-
|
211
|
+
client = Plaid::Client.new(env: :sandbox,
|
212
|
+
client_id: '***',
|
213
|
+
secret: '***',
|
214
|
+
public_key: '***')
|
155
215
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
(
|
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
|
-
|
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
|
-
|
169
|
-
|
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
|
-
|
173
|
-
|
174
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
264
|
+
client = Plaid::Client.new(env: :sandbox,
|
265
|
+
client_id: '***',
|
266
|
+
secret: '***',
|
267
|
+
public_key: '***')
|
190
268
|
|
191
|
-
|
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
|
-
|
274
|
+
access_token = item_response['access_token']
|
194
275
|
|
195
|
-
|
196
|
-
|
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
|
-
|
279
|
+
```
|
201
280
|
|
202
|
-
|
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
|
-
|
206
|
-
inst = Plaid::Institution.get('5301a93ac140de84910000e0') # A single institution by its ID
|
285
|
+
require 'plaid'
|
207
286
|
|
208
|
-
|
209
|
-
|
287
|
+
client = Plaid::Client.new(env: :sandbox,
|
288
|
+
client_id: '***',
|
289
|
+
secret: '***',
|
290
|
+
public_key: '***')
|
210
291
|
|
211
|
-
|
292
|
+
exchange_token_response = client.item.public_token.exchange('[Plaid Link public_token]')
|
293
|
+
access_token = exchange_token_response['access_token']
|
212
294
|
|
213
|
-
|
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
|
-
|
300
|
+
There are also a number of other methods you can use to retrieve data:
|
226
301
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
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
|
-
|
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
|
-
|
263
|
-
explicit instantiation of `Plaid::Client`:
|
311
|
+
### Categories
|
264
312
|
|
265
|
-
|
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
|
-
|
274
|
-
|
315
|
+
```ruby
|
316
|
+
categories = client.categories.get # Array of all known categories
|
317
|
+
```
|
275
318
|
|
276
|
-
|
277
|
-
user1 = Plaid::User.create(:connect, 'wells', 'plaid_test', 'plaid_good')
|
319
|
+
### Institutions
|
278
320
|
|
279
|
-
|
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
|
-
|
283
|
-
|
323
|
+
```ruby
|
324
|
+
institutions = client.institutions.get(count: 3, offset: 1)
|
284
325
|
```
|
285
326
|
|
286
|
-
|
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
|
-
"
|
330
|
+
"210: MFA Required".
|
302
331
|
|
303
|
-
`Plaid::
|
332
|
+
`Plaid::InvalidRequestError` is returned when the request is malformed and cannot be processed.
|
304
333
|
|
305
|
-
`Plaid::
|
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::
|
336
|
+
`Plaid::RateLimitExceededError` returned when the request is valid but has exceeded established rate limits.
|
308
337
|
|
309
|
-
`Plaid::
|
338
|
+
`Plaid::APIError` is returned during planned maintenance windows and in response to API internal server errors.
|
310
339
|
|
311
|
-
`Plaid::
|
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
|
315
|
-
|
316
|
-
## Development
|
343
|
+
[Plaid documentation](https://plaid.com/docs/api).
|
317
344
|
|
318
|
-
|
345
|
+
## Network Timeout
|
319
346
|
|
320
|
-
|
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
|
|