plaid 1.3.0 → 1.4.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 +3 -1
- data/lib/plaid/user/user.rb +7 -4
- data/lib/plaid/util.rb +1 -1
- data/lib/plaid/version.rb +1 -1
- data/spec/add_user_spec.rb +8 -8
- data/spec/user_spec.rb +17 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 186866b9b7d8f2b78d2b6c851713a6d7ac1a9347
|
4
|
+
data.tar.gz: 75667f9a71954b24ba53568064fdcd99f5b64d30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95dfd209ad86cde321e151ab521cc6deedbb6dcf59d50b659760fb3fbf7af3b9e9e66b7059d14f50bfe2972db02339e9728a6a21fb5a8db5d38df6c084eb0edb
|
7
|
+
data.tar.gz: 3c4b4e2d9fb277ed33d881449c14e897425f1c0c6451c65a6e45e0c6d13c25241e7eb6b323c1664bfbe4b0043de86b4083cb7563b0d8b9230fe881a9cc7bd30f
|
data/README.md
CHANGED
@@ -6,7 +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.4.0**
|
10
|
+
|
11
|
+
This version removes the need to use 'type' in each additional call.
|
10
12
|
|
11
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. **
|
12
14
|
|
data/lib/plaid/user/user.rb
CHANGED
@@ -8,7 +8,7 @@ module Plaid
|
|
8
8
|
include Plaid::Util
|
9
9
|
|
10
10
|
# Define user vars
|
11
|
-
attr_accessor(:accounts, :transactions, :access_token, :permissions, :api_res, :pending_mfa_questions, :info, :information)
|
11
|
+
attr_accessor(:accounts, :transactions, :access_token, :type, :permissions, :api_res, :pending_mfa_questions, :info, :information)
|
12
12
|
|
13
13
|
def initialize
|
14
14
|
self.accounts = [], self.transactions = [], self.permissions = [], self.access_token = '', self.api_res = '', self.info = {}, self.information = Information.new
|
@@ -20,14 +20,16 @@ module Plaid
|
|
20
20
|
build_user(res,api_level)
|
21
21
|
end
|
22
22
|
|
23
|
-
def mfa_authentication(auth,type)
|
23
|
+
def mfa_authentication(auth,type=nil)
|
24
|
+
type = self.type if type.nil?
|
24
25
|
auth_path = self.permissions.last + '/step'
|
25
26
|
res = Plaid.post(auth_path,{mfa:auth,access_token:self.access_token,type:type})
|
26
27
|
self.accounts = [], self.transactions = []
|
27
28
|
build_user(res)
|
28
29
|
end
|
29
30
|
|
30
|
-
def select_mfa_method(selection,type)
|
31
|
+
def select_mfa_method(selection,type=nil)
|
32
|
+
type = self.type if type.nil?
|
31
33
|
auth_path = self.permissions.last + '/step'
|
32
34
|
res = Plaid.post(auth_path,{options:{send_method: selection}.to_json, access_token:self.access_token,type:type})
|
33
35
|
build_user(res,self.permissions.last)
|
@@ -162,7 +164,8 @@ module Plaid
|
|
162
164
|
# TODO: Remove the following line when upgrading to V-2
|
163
165
|
user.info.merge!(res['info']) if res['info']
|
164
166
|
# End TODO
|
165
|
-
user.access_token = res['access_token']
|
167
|
+
user.access_token = res['access_token'].split[0]
|
168
|
+
user.type = res['access_token'].split[1]
|
166
169
|
end
|
167
170
|
|
168
171
|
end
|
data/lib/plaid/util.rb
CHANGED
@@ -96,7 +96,7 @@ module Plaid
|
|
96
96
|
if body['code'].nil?
|
97
97
|
body
|
98
98
|
else
|
99
|
-
if body['code'] == 1401 || body['code'] == 1501 || body['code'] == 1601
|
99
|
+
if body['code'] == 1301 || body['code'] == 1401 || body['code'] == 1501 || body['code'] == 1601
|
100
100
|
error_handler('Not Found',body)
|
101
101
|
else
|
102
102
|
body
|
data/lib/plaid/version.rb
CHANGED
data/spec/add_user_spec.rb
CHANGED
@@ -57,12 +57,12 @@ describe '.add_user' do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
context 'has to enter MFA credentials' do
|
60
|
-
user = Plaid.add_user('connect','
|
60
|
+
user = Plaid.add_user('connect','plaid_test', 'plaid_good','bofa')
|
61
61
|
it { expect(user.api_res).to eq 'Requires further authentication' }
|
62
62
|
end
|
63
63
|
|
64
64
|
context 'enters correct information with locked account' do
|
65
|
-
user = Plaid.add_user('connect','
|
65
|
+
user = Plaid.add_user('connect','plaid_test', 'plaid_locked','wells')
|
66
66
|
it { expect(user.api_res).to eq 'User account is locked' }
|
67
67
|
end
|
68
68
|
|
@@ -72,32 +72,32 @@ describe '.add_user' do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
context 'enters webhook option as part of mfa required institution authentication' do
|
75
|
-
user = Plaid.add_user('connect','
|
75
|
+
user = Plaid.add_user('connect','plaid_test', 'plaid_good','bofa',{login_only: true, webhook: 'test.com/test.endpoint.aspx'})
|
76
76
|
it { expect(user.api_res).to eq 'Requires further authentication' }
|
77
77
|
end
|
78
78
|
|
79
79
|
context 'requests pending transactions from an institution' do
|
80
|
-
user = Plaid.add_user('connect','
|
80
|
+
user = Plaid.add_user('connect','plaid_test', 'plaid_good','wells',{pending: true})
|
81
81
|
it { expect(user.accounts.empty?).to be_falsey }
|
82
82
|
end
|
83
83
|
|
84
84
|
context 'sets the login only option to true' do
|
85
|
-
user = Plaid.add_user('connect','
|
85
|
+
user = Plaid.add_user('connect','plaid_test', 'plaid_good','wells',{login_only:true})
|
86
86
|
it { expect(user.accounts.empty?).to be_falsey }
|
87
87
|
end
|
88
88
|
|
89
89
|
context 'requests a list of options for code based MFA' do
|
90
|
-
user = Plaid.add_user('connect','
|
90
|
+
user = Plaid.add_user('connect','plaid_test', 'plaid_good','citi',{list: true})
|
91
91
|
it { expect(user.pending_mfa_questions.nil?).to be_falsey }
|
92
92
|
end
|
93
93
|
|
94
94
|
context 'sets a start date for transactions' do
|
95
|
-
user = Plaid.add_user('connect','
|
95
|
+
user = Plaid.add_user('connect','plaid_test', 'plaid_good','wells',{login_only:true, start_date:'10 days ago'})
|
96
96
|
it { expect(user.accounts.empty?).to be_falsey }
|
97
97
|
end
|
98
98
|
|
99
99
|
context 'sets an end date for transactions' do
|
100
|
-
user = Plaid.add_user('connect','
|
100
|
+
user = Plaid.add_user('connect','plaid_test', 'plaid_good','wells',{login_only:true, end_date: '10 days ago'})
|
101
101
|
it { expect(user.accounts.empty?).to be_falsey }
|
102
102
|
end
|
103
103
|
|
data/spec/user_spec.rb
CHANGED
@@ -25,39 +25,45 @@ describe '#User' do
|
|
25
25
|
describe '#mfa_authentication' do
|
26
26
|
|
27
27
|
context 'enters correct credentials for MFA auth and authenticates' do
|
28
|
-
new_mfa_user = Plaid.add_user('connect','
|
28
|
+
new_mfa_user = Plaid.add_user('connect','plaid_test', 'plaid_good','bofa')
|
29
|
+
new_mfa_user.mfa_authentication('tomato')
|
30
|
+
it { expect(new_mfa_user.accounts).to be_truthy }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'enters old method of adding type strongly in each method and authenticates correctly using 2FA' do
|
34
|
+
new_mfa_user = Plaid.add_user('connect','plaid_test', 'plaid_good','bofa')
|
29
35
|
new_mfa_user.mfa_authentication('tomato','bofa')
|
30
36
|
it { expect(new_mfa_user.accounts).to be_truthy }
|
31
37
|
end
|
32
38
|
|
33
39
|
context 'has to enter another round of MFA credentials' do
|
34
|
-
mfa_again = Plaid.add_user('connect','
|
35
|
-
mfa_again.mfa_authentication('again'
|
40
|
+
mfa_again = Plaid.add_user('connect','plaid_test', 'plaid_good','bofa')
|
41
|
+
mfa_again.mfa_authentication('again')
|
36
42
|
it { expect(mfa_again.api_res).to eq 'Requires further authentication' }
|
37
43
|
end
|
38
44
|
|
39
45
|
context 'enters incorrect credentials for MFA auth' do
|
40
|
-
mfa_user = Plaid.add_user('connect','
|
41
|
-
mfa_user.mfa_authentication('tomato'
|
42
|
-
mfa_user = Plaid.add_user('connect','
|
43
|
-
it { expect { mfa_user.mfa_authentication('bad'
|
46
|
+
mfa_user = Plaid.add_user('connect','plaid_test', 'plaid_good','bofa')
|
47
|
+
mfa_user.mfa_authentication('tomato')
|
48
|
+
mfa_user = Plaid.add_user('connect','plaid_test', 'plaid_good','bofa')
|
49
|
+
it { expect { mfa_user.mfa_authentication('bad') }.to raise_error }
|
44
50
|
end
|
45
51
|
|
46
52
|
context 'requests list of MFA credentials' do
|
47
53
|
new_mfa_user = Plaid.add_user('auth','plaid_test','plaid_good','chase',nil,'{"list":true}')
|
48
|
-
it { expect(new_mfa_user.pending_mfa_questions).to eq({"type"=>"list", "mfa"=>[{"mask"=>"xxx-xxx-5309", "type"=>"phone"}, {"mask"=>"t..t@plaid.com", "type"=>"email"}], "access_token"=>"
|
54
|
+
it { expect(new_mfa_user.pending_mfa_questions).to eq({"type"=>"list", "mfa"=>[{"mask"=>"xxx-xxx-5309", "type"=>"phone"}, {"mask"=>"t..t@plaid.com", "type"=>"email"}], "access_token"=>"test_chase"}) }
|
49
55
|
end
|
50
56
|
|
51
57
|
context 'selects MFA method and returns successful response' do
|
52
58
|
new_mfa_user = Plaid.add_user('auth','plaid_test','plaid_good','chase',nil,'{"list":true}')
|
53
59
|
new_mfa_user.select_mfa_method({mask:'xxx-xxx-5309'},'chase')
|
54
|
-
it { expect(new_mfa_user.pending_mfa_questions).to eq({"type"=>"device", "mfa"=>{"message"=>"Code sent to xxx-xxx-5309"}, "access_token"=>"
|
60
|
+
it { expect(new_mfa_user.pending_mfa_questions).to eq({"type"=>"device", "mfa"=>{"message"=>"Code sent to xxx-xxx-5309"}, "access_token"=>"test_chase"}) }
|
55
61
|
end
|
56
62
|
|
57
63
|
context 'selects MFA method, and delivers correct payload to authenticate user' do
|
58
64
|
new_mfa_user = Plaid.add_user('auth','plaid_test','plaid_good','chase',nil,'{"list":true}')
|
59
|
-
new_mfa_user.select_mfa_method({mask:'xxx-xxx-5309'}
|
60
|
-
new_mfa_user.mfa_authentication(1234
|
65
|
+
new_mfa_user.select_mfa_method({mask:'xxx-xxx-5309'})
|
66
|
+
new_mfa_user.mfa_authentication(1234)
|
61
67
|
it { expect(new_mfa_user.accounts).to be_truthy }
|
62
68
|
end
|
63
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plaid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Crites
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|