plaid 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/lib/plaid/user/user.rb +30 -6
- data/lib/plaid/util.rb +17 -0
- data/lib/plaid/version.rb +1 -1
- data/spec/plaid_spec.rb +73 -7
- 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: d73424e0c08de86274b16655572d2d2245d6c37f
|
4
|
+
data.tar.gz: 229a58e9cbe23b38b77f6c234da0aef34d368e93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 126c8ecebc361f4dfb2a1b7526e2533f61824254784681ca9fa196cfa03651ceac1ed9d5dd7f5b9666c644aa017439446195be03f860909a34d2f66a9cb8bd6a
|
7
|
+
data.tar.gz: e2063d06312d326982ab7faced2d7bae6b72049f1bb2a22e43a70bd0ec9b07ab6fa5efab62cf06f768615cbf3977f9fc6ca0f658741ccb4016ae5696e6a3c77e
|
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
# Plaid [![Build Status](https://travis-ci.org/plaid/plaid-ruby.svg?branch=release_v_1.0.0)](https://travis-ci.org/plaid/plaid-ruby)
|
1
|
+
# Plaid [![Build Status](https://travis-ci.org/plaid/plaid-ruby.svg?branch=release_v_1.0.0)](https://travis-ci.org/plaid/plaid-ruby)
|
2
2
|
|
3
3
|
Ruby bindings for the Plaid API
|
4
4
|
|
5
5
|
## Notes
|
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
|
+
|
9
|
+
Latest stable version: **1.1.1**
|
8
10
|
|
9
11
|
Last stable version: 1.0.1
|
10
12
|
|
@@ -15,7 +17,7 @@ Last stable version: 1.0.1
|
|
15
17
|
Add this line to your application's Gemfile:
|
16
18
|
|
17
19
|
```ruby
|
18
|
-
gem 'plaid'
|
20
|
+
gem 'plaid'
|
19
21
|
```
|
20
22
|
|
21
23
|
And install
|
data/lib/plaid/user/user.rb
CHANGED
@@ -6,7 +6,7 @@ module Plaid
|
|
6
6
|
include Plaid::Util
|
7
7
|
|
8
8
|
# Define user vars
|
9
|
-
attr_accessor(:accounts, :transactions, :access_token, :permissions, :api_res, :pending_mfa_questions)
|
9
|
+
attr_accessor(:accounts, :transactions, :access_token, :permissions, :api_res, :pending_mfa_questions, :info)
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
self.accounts = []
|
@@ -14,6 +14,7 @@ module Plaid
|
|
14
14
|
self.permissions = []
|
15
15
|
self.access_token = ''
|
16
16
|
self.api_res = ''
|
17
|
+
self.info = {}
|
17
18
|
end
|
18
19
|
|
19
20
|
# Instantiate a new user with the results of the successful API call
|
@@ -47,15 +48,37 @@ module Plaid
|
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
def
|
51
|
-
if
|
52
|
-
|
53
|
-
|
51
|
+
def get_info
|
52
|
+
if self.permissions.include? 'info'
|
53
|
+
res = Plaid.get('info',{access_token:self.access_token})
|
54
|
+
build_user(res)
|
55
|
+
else
|
56
|
+
false
|
54
57
|
end
|
55
|
-
|
58
|
+
end
|
59
|
+
|
60
|
+
def update_info(username,pass,pin=nil)
|
61
|
+
if self.permissions.include? 'info'
|
62
|
+
payload = {username:username,password:pass,access_token:self.access_token}
|
63
|
+
payload.merge!({pin:pin}) if pin
|
64
|
+
res = Plaid.patch('info',payload)
|
65
|
+
build_user(res)
|
66
|
+
else
|
67
|
+
false
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def upgrade
|
72
|
+
upgrade_to = 'auth' unless self.permissions.include? 'auth'
|
73
|
+
upgrade_to = 'connect' unless self.permissions.include? 'connect'
|
74
|
+
res = Plaid.post('upgrade',{access_token:self.access_token,upgrade_to:upgrade_to})
|
56
75
|
build_user(res)
|
57
76
|
end
|
58
77
|
|
78
|
+
def delete_user
|
79
|
+
Plaid.delete('info',{access_token:self.access_token})
|
80
|
+
end
|
81
|
+
|
59
82
|
protected
|
60
83
|
|
61
84
|
def build_user(res,api_level=nil)
|
@@ -67,6 +90,7 @@ module Plaid
|
|
67
90
|
res['transactions'].each do |transaction|
|
68
91
|
self.transactions << new_transaction(transaction)
|
69
92
|
end if res['transactions']
|
93
|
+
self.info = res['info'] if res['info']
|
70
94
|
self.permissions << api_level
|
71
95
|
self.access_token = res['access_token']
|
72
96
|
self.api_res = 'success'
|
data/lib/plaid/util.rb
CHANGED
@@ -17,6 +17,23 @@ module Plaid
|
|
17
17
|
JSON.parse(res)
|
18
18
|
end
|
19
19
|
|
20
|
+
def patch(path,options={})
|
21
|
+
uri = build_uri(path)
|
22
|
+
options.merge!({client_id: self.instance_variable_get(:'@customer_id') ,secret: self.instance_variable_get(:'@secret')})
|
23
|
+
res = Net::HTTP.patch(uri,options)
|
24
|
+
parse_response(res)
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete(path,options={})
|
28
|
+
uri = build_uri(path)
|
29
|
+
options.merge!({client_id: self.instance_variable_get(:'@customer_id') ,secret: self.instance_variable_get(:'@secret')})
|
30
|
+
req = Net::HTTP::Delete.new(uri)
|
31
|
+
req.body = URI.encode_www_form(options) if options
|
32
|
+
req.content_type = 'multipart/form-data'
|
33
|
+
res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
|
34
|
+
puts res
|
35
|
+
end
|
36
|
+
|
20
37
|
def error_handler(err,res=nil)
|
21
38
|
case err
|
22
39
|
when 'Bad Request'
|
data/lib/plaid/version.rb
CHANGED
data/spec/plaid_spec.rb
CHANGED
@@ -67,6 +67,16 @@ describe Plaid do
|
|
67
67
|
it { expect(user.accounts[0].numbers.nil?).to be_falsey }
|
68
68
|
end
|
69
69
|
|
70
|
+
context 'has correct credentials for single factor auth, authenticates to the info level of api access' do
|
71
|
+
Plaid.config do |p|
|
72
|
+
p.customer_id = 'test_id'
|
73
|
+
p.secret = 'test_secret'
|
74
|
+
p.environment_location = 'https://tartan.plaid.com/'
|
75
|
+
end
|
76
|
+
user = Plaid.add_user('info','plaid_test','plaid_good','wells')
|
77
|
+
it { expect(user.info).to be_truthy }
|
78
|
+
end
|
79
|
+
|
70
80
|
context 'has correct username, but incorrect password for single factor auth under auth level of api access' do
|
71
81
|
Plaid.config do |p|
|
72
82
|
p.customer_id = 'test_id'
|
@@ -103,6 +113,24 @@ describe Plaid do
|
|
103
113
|
it { expect{Plaid.add_user('connect','plaid_bad','plaid_bad','wells')}.to raise_error }
|
104
114
|
end
|
105
115
|
|
116
|
+
context 'has correct username, but incorrect password for single factor auth under info level of api access' do
|
117
|
+
Plaid.config do |p|
|
118
|
+
p.customer_id = 'test_id'
|
119
|
+
p.secret = 'test_secret'
|
120
|
+
p.environment_location = 'https://tartan.plaid.com/'
|
121
|
+
end
|
122
|
+
it { expect{Plaid.add_user('info','plaid_test','plaid_bad','wells')}.to raise_error }
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'has incorrect username under info level of api access' do
|
126
|
+
Plaid.config do |p|
|
127
|
+
p.customer_id = 'test_id'
|
128
|
+
p.secret = 'test_secret'
|
129
|
+
p.environment_location = 'https://tartan.plaid.com/'
|
130
|
+
end
|
131
|
+
it { expect{Plaid.add_user('info','plaid_bad','plaid_bad','wells')}.to raise_error }
|
132
|
+
end
|
133
|
+
|
106
134
|
context 'enters pin for extra parameter authentication required by certain institutions' do
|
107
135
|
Plaid.config do |p|
|
108
136
|
p.customer_id = 'test_id'
|
@@ -375,6 +403,49 @@ describe Plaid do
|
|
375
403
|
end
|
376
404
|
end
|
377
405
|
|
406
|
+
# Get info specs
|
407
|
+
describe '#get_info' do
|
408
|
+
Plaid.config do |p|
|
409
|
+
p.customer_id = 'test_id'
|
410
|
+
p.secret = 'test_secret'
|
411
|
+
p.environment_location = 'https://tartan.plaid.com/'
|
412
|
+
end
|
413
|
+
info_user = Plaid.add_user('info','plaid_test','plaid_good','wells')
|
414
|
+
auth_user = Plaid.add_user('auth','plaid_test','plaid_good','wells')
|
415
|
+
|
416
|
+
context 'has access and returns user info' do
|
417
|
+
it { expect(info_user.permissions[0]).to eq('info') }
|
418
|
+
end
|
419
|
+
|
420
|
+
context 'does not have access to info' do
|
421
|
+
it{ expect(auth_user.permissions.include? 'info' ).to be false }
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
=begin
|
426
|
+
describe '#update_info' do
|
427
|
+
info_user = Plaid.add_user('info','plaid_test','plaid_good','wells')
|
428
|
+
|
429
|
+
context 'updates information correctly' do
|
430
|
+
it { expect { info_user.update_info('info','plaid_test','plaid_new','wells') }.to be_truthy }
|
431
|
+
end
|
432
|
+
end
|
433
|
+
=end
|
434
|
+
|
435
|
+
describe '#delete_user' do
|
436
|
+
Plaid.config do |p|
|
437
|
+
p.customer_id = 'test_id'
|
438
|
+
p.secret = 'test_secret'
|
439
|
+
p.environment_location = 'https://tartan.plaid.com/'
|
440
|
+
end
|
441
|
+
info_user = Plaid.add_user('info','plaid_test','plaid_good','wells')
|
442
|
+
info_user.delete_user
|
443
|
+
|
444
|
+
context 'updates information correctly' do
|
445
|
+
it { expect { info_user.get_info }.to raise_error }
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
378
449
|
# Upgrade specs - either pass or fails
|
379
450
|
=begin TODO: Write upgrade methods to pass without paying
|
380
451
|
describe '#upgrade' do
|
@@ -382,17 +453,12 @@ describe Plaid do
|
|
382
453
|
connect_user = Plaid.add_user('connect','plaid_test','plaid_good','wells')
|
383
454
|
|
384
455
|
context 'auth upgrade is successful' do
|
385
|
-
connect_user.upgrade
|
456
|
+
connect_user.upgrade
|
386
457
|
it { expect(connect_user.get_auth).to be_truthy }
|
387
458
|
end
|
388
459
|
|
389
460
|
context 'connect upgrade is successful' do
|
390
|
-
auth_user.upgrade
|
391
|
-
it { expect(auth_user.get_connect).to be_truthy }
|
392
|
-
end
|
393
|
-
|
394
|
-
context 'connect upgrade is successful' do
|
395
|
-
auth_user.upgrade('info')
|
461
|
+
auth_user.upgrade
|
396
462
|
it { expect(auth_user.get_connect).to be_truthy }
|
397
463
|
end
|
398
464
|
end
|