plaid 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/plaid/user/account/account.rb +12 -0
- data/lib/plaid/user/user.rb +25 -29
- data/lib/plaid/version.rb +1 -1
- data/spec/plaid_spec.rb +28 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb83ce0044d87a79faa370283d1d16a85c5b3e34
|
4
|
+
data.tar.gz: 430bc60bc0ef7358624aeeb8ba6810d707692d96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38e5062cacf0c071ccf06fd25797d533ce40089b820f966a05c41ee6bcbe7d288461a0f1e95fef6b0f570648ebabd993a110f877d5837ffffc7bfaffcac560c2
|
7
|
+
data.tar.gz: 842052852e27e8d125a58c97b48a7fe470595340db39e08ea63028b956f023da86b3f637a963f40b3d155b7031982372ed0054429d4b8755fd862b54bd0d0e4a
|
data/README.md
CHANGED
@@ -6,9 +6,9 @@ Ruby bindings for the Plaid API
|
|
6
6
|
|
7
7
|
This version is a beta version that contains failing tests for the new 'info' endpoint. While these have been tested individually on real accounts the tests here will fail with the test accounts supplied. These will be updated soon with test credentials.
|
8
8
|
|
9
|
-
Latest stable version: **1.
|
9
|
+
Latest stable version: **1.2.2**
|
10
10
|
|
11
|
-
Last stable version: 1.
|
11
|
+
Last stable version: 1.1.2
|
12
12
|
|
13
13
|
**Warning: If you have been using any version < 1 please switch to the correct branch (V0.1.6). Installing without specifying a version from RubyGems results in V1.1 build. **
|
14
14
|
|
@@ -19,5 +19,17 @@ module Plaid
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def update_account(res)
|
23
|
+
begin
|
24
|
+
self.name = res['name'], self.available_balance = res['balance']['available'], self.current_balance = res['balance']['current'], self.institution_type = res['institution_type'], self.id = res['_id'], self.type = res['type']
|
25
|
+
self.meta = res['meta'] if res['meta']
|
26
|
+
res['numbers'] ? self.numbers = res['numbers'] : self.numbers = 'Upgrade user to access routing information for this account'
|
27
|
+
rescue => e
|
28
|
+
error_handler(e)
|
29
|
+
else
|
30
|
+
self
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
22
34
|
end
|
23
35
|
end
|
data/lib/plaid/user/user.rb
CHANGED
@@ -24,10 +24,10 @@ module Plaid
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def mfa_authentication(auth,type)
|
27
|
-
auth_path = self.permissions
|
27
|
+
auth_path = self.permissions.last + '/step'
|
28
28
|
res = Plaid.post(auth_path,{mfa:auth,access_token:self.access_token,type:type})
|
29
29
|
self.accounts = [], self.transactions = []
|
30
|
-
|
30
|
+
build_user(res)
|
31
31
|
end
|
32
32
|
|
33
33
|
def get_auth
|
@@ -68,6 +68,11 @@ module Plaid
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def update_balance
|
72
|
+
res = Plaid.post('balance',{access_token:self.access_token})
|
73
|
+
build_user(res)
|
74
|
+
end
|
75
|
+
|
71
76
|
def upgrade(api_level=nil)
|
72
77
|
if api_level.nil?
|
73
78
|
api_level = 'auth' unless self.permissions.include? 'auth'
|
@@ -87,40 +92,31 @@ module Plaid
|
|
87
92
|
begin
|
88
93
|
if res[:msg].nil?
|
89
94
|
res['accounts'].each do |account|
|
90
|
-
self.accounts
|
95
|
+
if self.accounts.any? { |h| h == account['_id'] }
|
96
|
+
owned_account = self.accounts.find { |h| h == account['_id'] }
|
97
|
+
owned_account.new(account)
|
98
|
+
else
|
99
|
+
self.accounts << new_account(account)
|
100
|
+
end
|
91
101
|
end if res['accounts']
|
92
102
|
res['transactions'].each do |transaction|
|
93
|
-
self.transactions
|
103
|
+
if self.transactions.any? { |t| t == transaction['_id'] }
|
104
|
+
owned_transaction = self.transactions.find { |h| h == transaction['_id'] }
|
105
|
+
owned_transaction.new(transaction)
|
106
|
+
else
|
107
|
+
self.transactions << new_transaction(transaction)
|
108
|
+
end
|
94
109
|
end if res['transactions']
|
95
|
-
self.
|
96
|
-
self.permissions << api_level
|
97
|
-
self.access_token = res['access_token']
|
98
|
-
self.api_res = 'success'
|
99
|
-
clean_up_user(self)
|
100
|
-
else
|
101
|
-
self.pending_mfa_questions = res[:body], self.accounts = res[:msg], self.transactions = res[:msg], self.permissions << api_level, self.access_token = res[:body]['access_token'], self.api_res = res[:msg]
|
102
|
-
end
|
103
|
-
rescue => e
|
104
|
-
error_handler(e)
|
105
|
-
else
|
106
|
-
self
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def update_user(res,api_level=nil)
|
111
|
-
begin
|
112
|
-
if res[:msg].nil?
|
113
|
-
res['accounts'].each do |account|
|
114
|
-
self.accounts << new_account(account)
|
115
|
-
end if res['accounts']
|
116
|
-
res['transactions'].each do |transaction|
|
117
|
-
self.transactions << new_transaction(transaction)
|
118
|
-
end if res['transactions']
|
119
|
-
self.permissions << api_level
|
110
|
+
self.permissions << api_level unless self.permissions.include? api_level
|
120
111
|
self.api_res = 'success'
|
121
112
|
self.pending_mfa_questions = ''
|
113
|
+
self.access_token = res['access_token']
|
114
|
+
clean_up_user(self)
|
122
115
|
else
|
116
|
+
self.access_token = res[:body]['access_token']
|
123
117
|
self.pending_mfa_questions = res[:body]
|
118
|
+
self.api_res = res[:msg]
|
119
|
+
self.permissions << api_level
|
124
120
|
end
|
125
121
|
rescue => e
|
126
122
|
error_handler(e)
|
data/lib/plaid/version.rb
CHANGED
data/spec/plaid_spec.rb
CHANGED
@@ -196,7 +196,7 @@ describe Plaid do
|
|
196
196
|
p.secret = 'test_secret'
|
197
197
|
p.environment_location = 'https://tartan.plaid.com/'
|
198
198
|
end
|
199
|
-
user = Plaid.add_user('connect','plaid_selections', '
|
199
|
+
user = Plaid.add_user('connect','plaid_selections', 'plaid_good','wells',{pending: true})
|
200
200
|
it { expect(user.accounts.empty?).to be_falsey }
|
201
201
|
end
|
202
202
|
|
@@ -206,7 +206,7 @@ describe Plaid do
|
|
206
206
|
p.secret = 'test_secret'
|
207
207
|
p.environment_location = 'https://tartan.plaid.com/'
|
208
208
|
end
|
209
|
-
user = Plaid.add_user('connect','plaid_selections', '
|
209
|
+
user = Plaid.add_user('connect','plaid_selections', 'plaid_good','wells',{login_only:true})
|
210
210
|
it { expect(user.accounts.empty?).to be_falsey }
|
211
211
|
end
|
212
212
|
|
@@ -216,8 +216,8 @@ describe Plaid do
|
|
216
216
|
p.secret = 'test_secret'
|
217
217
|
p.environment_location = 'https://tartan.plaid.com/'
|
218
218
|
end
|
219
|
-
user = Plaid.add_user('connect','plaid_selections', '
|
220
|
-
it { expect(user.
|
219
|
+
user = Plaid.add_user('connect','plaid_selections', 'plaid_good','citi',{list: true})
|
220
|
+
it { expect(user.pending_mfa_questions.nil?).to be_falsey }
|
221
221
|
end
|
222
222
|
|
223
223
|
context 'sets a start date for transactions' do
|
@@ -226,7 +226,7 @@ describe Plaid do
|
|
226
226
|
p.secret = 'test_secret'
|
227
227
|
p.environment_location = 'https://tartan.plaid.com/'
|
228
228
|
end
|
229
|
-
user = Plaid.add_user('connect','plaid_selections', '
|
229
|
+
user = Plaid.add_user('connect','plaid_selections', 'plaid_good','wells',{login_only:true, start_date:'10 days ago'})
|
230
230
|
it { expect(user.accounts.empty?).to be_falsey }
|
231
231
|
end
|
232
232
|
|
@@ -236,7 +236,7 @@ describe Plaid do
|
|
236
236
|
p.secret = 'test_secret'
|
237
237
|
p.environment_location = 'https://tartan.plaid.com/'
|
238
238
|
end
|
239
|
-
user = Plaid.add_user('connect','plaid_selections', '
|
239
|
+
user = Plaid.add_user('connect','plaid_selections', 'plaid_good','wells',{login_only:true, end_date: '10 days ago'})
|
240
240
|
it { expect(user.accounts.empty?).to be_falsey }
|
241
241
|
end
|
242
242
|
end
|
@@ -422,6 +422,27 @@ describe Plaid do
|
|
422
422
|
end
|
423
423
|
end
|
424
424
|
|
425
|
+
describe '#get_balance' do
|
426
|
+
Plaid.config do |p|
|
427
|
+
p.customer_id = 'test_id'
|
428
|
+
p.secret = 'test_secret'
|
429
|
+
p.environment_location = 'https://tartan.plaid.com/'
|
430
|
+
end
|
431
|
+
|
432
|
+
user = Plaid.add_user('info','plaid_test','plaid_good','wells')
|
433
|
+
user.update_balance
|
434
|
+
context 'updates user accounts' do
|
435
|
+
it { expect(user.accounts.empty?).to be_falsey }
|
436
|
+
end
|
437
|
+
|
438
|
+
context 'should not double up accounts or transactions' do
|
439
|
+
dup = user.accounts.select{|element| user.accounts.count(element) > 1}
|
440
|
+
dup = dup.length + user.transactions.select{|element| user.transactions.count(element) > 1}.length
|
441
|
+
it{ expect(dup).to eq(0) }
|
442
|
+
end
|
443
|
+
|
444
|
+
end
|
445
|
+
|
425
446
|
=begin
|
426
447
|
describe '#update_info' do
|
427
448
|
info_user = Plaid.add_user('info','plaid_test','plaid_good','wells')
|
@@ -438,6 +459,7 @@ describe Plaid do
|
|
438
459
|
p.secret = 'test_secret'
|
439
460
|
p.environment_location = 'https://tartan.plaid.com/'
|
440
461
|
end
|
462
|
+
|
441
463
|
info_user = Plaid.add_user('info','plaid_test','plaid_good','wells')
|
442
464
|
info_user.delete_user
|
443
465
|
|