plaid 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/README.md +37 -11
- data/lib/plaid.rb +8 -9
- data/lib/plaid/auth.rb +3 -2
- data/lib/plaid/category/category.rb +8 -15
- data/lib/plaid/institution/institution.rb +10 -17
- data/lib/plaid/user/user.rb +69 -7
- data/lib/plaid/util.rb +23 -18
- data/lib/plaid/version.rb +1 -1
- data/plaid.gemspec +1 -0
- data/spec/plaid_spec.rb +118 -86
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b2355e11af0826a2ace7a6c8f01c439927d68d4
|
4
|
+
data.tar.gz: ec087e866397828a734a808fa75e2400789ea8fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29fe226dcbb38dc8987d02996c827a9c47d9854c1d782ae4b7de56020b491b2dafbbd5003da43682bf5d5f6d62896f0576e8b841109ffa2cf2a1369e3866ba8c
|
7
|
+
data.tar.gz: a8181aaf03e10ebc3029d4535c979a9a988381714f5558cda88909190e8388753715534659b64fef540b689a45681bf6d51d22355ef781aeec1c797ee8850945
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
-
# Plaid
|
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
|
+
|
5
|
+
## Notes
|
6
|
+
|
7
|
+
Latest stable version: **1.0.0**
|
8
|
+
|
9
|
+
Last stable version: 0.1.6
|
10
|
+
|
11
|
+
**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.0.0 build. **
|
4
12
|
|
5
13
|
## Installation
|
6
14
|
|
@@ -10,22 +18,40 @@ Add this line to your application's Gemfile:
|
|
10
18
|
gem 'plaid'
|
11
19
|
```
|
12
20
|
|
13
|
-
And
|
21
|
+
And install
|
14
22
|
|
15
23
|
$ bundle
|
16
24
|
|
17
|
-
Or install it
|
25
|
+
Or install it system wide as:
|
18
26
|
|
19
27
|
$ gem install plaid
|
20
28
|
|
21
29
|
## Usage
|
22
30
|
|
23
|
-
|
31
|
+
Please read the great documentation at http://plaid.com/docs/ for more information.
|
32
|
+
|
33
|
+
Configure the gem with your customer id, secret key, and the environment path you would like to use.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Plaid.config do |p|
|
37
|
+
p.customer_id = ['test_id']
|
38
|
+
p.secret = ['test_secret']
|
39
|
+
p.environment_location = ['https://tartan.plaid.com/']
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
Authenticate a user to your desired level of api access (auth / connect).
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
user = Plaid.auth('auth','plaid_test','plaid_good','wells')
|
47
|
+
```
|
48
|
+
|
49
|
+
## Learn More
|
50
|
+
|
51
|
+
Learn about the full functionality of the library on our [Wiki](https://github.com/plaid/plaid-ruby/wiki)
|
52
|
+
|
53
|
+
## Contribute
|
24
54
|
|
25
|
-
|
55
|
+
We highly encourage helping out with the gem. Either adding more tests, building new helper classes, fixing bugs, or anything to increase overall quality.
|
26
56
|
|
27
|
-
|
28
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
-
5. Create a new Pull Request
|
57
|
+
Learn more about best practices, submitting a pull request, and rules for the build on our [Wiki](https://github.com/plaid/plaid-ruby/wiki/Contribute!)
|
data/lib/plaid.rb
CHANGED
@@ -8,10 +8,7 @@ require 'plaid/institution/institution'
|
|
8
8
|
require 'plaid/category/category'
|
9
9
|
|
10
10
|
module Plaid
|
11
|
-
# Define an instance of the gem thus responding with one customer at a time
|
12
11
|
class << self
|
13
|
-
# Include the SDK methods
|
14
|
-
|
15
12
|
# Configures the gem with the public, private, and environment vars
|
16
13
|
include Plaid::Configure
|
17
14
|
|
@@ -22,21 +19,23 @@ module Plaid
|
|
22
19
|
include Plaid::Auth
|
23
20
|
|
24
21
|
# Builds the user object and returns on successful authentication
|
25
|
-
def user(res)
|
22
|
+
def user(res,api_level=nil)
|
26
23
|
@user = Plaid::User.new
|
27
|
-
@user.new(res)
|
24
|
+
@user.new(res,api_level)
|
28
25
|
end
|
29
26
|
|
30
27
|
# Builds an institution object and returns when the institution details exist
|
31
|
-
def institution(
|
28
|
+
def institution(id=nil)
|
32
29
|
@institution = Plaid::Institution.new
|
33
|
-
|
30
|
+
res = self.get('institutions',id)
|
31
|
+
id.nil? ? @institution.instantiate_all_institutions(res) : @institution.instantiate_one_institution(res)
|
34
32
|
end
|
35
33
|
|
36
34
|
# Builds an institution object and returns when the category details exist
|
37
|
-
def category(
|
35
|
+
def category(id=nil)
|
38
36
|
@category = Plaid::Category.new
|
39
|
-
|
37
|
+
res = self.get('categories',id)
|
38
|
+
id.nil? ? @category.instantiate_all_categories(res) : @category.instantiate_one_category(res)
|
40
39
|
end
|
41
40
|
|
42
41
|
end
|
data/lib/plaid/auth.rb
CHANGED
@@ -2,8 +2,9 @@ module Plaid
|
|
2
2
|
module Auth
|
3
3
|
def auth(api_level,username,password,type)
|
4
4
|
begin
|
5
|
-
|
6
|
-
self.
|
5
|
+
options = {username:username,password:password,type:type}
|
6
|
+
res = self.post(api_level,options)
|
7
|
+
self.user(res,api_level)
|
7
8
|
rescue => e
|
8
9
|
error_handler(e)
|
9
10
|
end
|
@@ -3,27 +3,20 @@ module Plaid
|
|
3
3
|
class Category
|
4
4
|
include Plaid::Util
|
5
5
|
|
6
|
-
attr_accessor(:type, :hierarchy, :id)
|
7
|
-
|
8
|
-
# Returns an instantiated category object, or an array of all categories
|
9
|
-
def new(id=nil)
|
10
|
-
res = get('categories',id)
|
11
|
-
id.nil? ? cat = instantiate_all_categories(res) : cat = instantiate_one_category(res)
|
12
|
-
cat
|
13
|
-
end
|
6
|
+
attr_accessor(:type, :hierarchy, :id, :cat_array)
|
14
7
|
|
15
8
|
def instantiate_all_categories(res)
|
16
|
-
cat_array = []
|
17
|
-
res
|
18
|
-
|
19
|
-
cat_array <<
|
9
|
+
self.cat_array = []
|
10
|
+
res.each do |cat|
|
11
|
+
category = Category.new
|
12
|
+
self.cat_array << category.build_category(cat)
|
20
13
|
end
|
21
|
-
cat_array
|
14
|
+
self.cat_array
|
22
15
|
end
|
23
16
|
|
24
17
|
def instantiate_one_category(res)
|
25
|
-
|
26
|
-
|
18
|
+
self.build_category(res)
|
19
|
+
self
|
27
20
|
end
|
28
21
|
|
29
22
|
protected
|
@@ -3,33 +3,26 @@ module Plaid
|
|
3
3
|
class Institution
|
4
4
|
include Plaid::Util
|
5
5
|
|
6
|
-
attr_accessor(:id, :name, :type, :has_mfa, :mfa)
|
7
|
-
|
8
|
-
# Returns an instantiated category object, or an array of all categories
|
9
|
-
def new(id=nil)
|
10
|
-
res = get('institutions',id)
|
11
|
-
id.nil? ? cat = instantiate_all_institutions(res) : cat = instantiate_one_institution(res)
|
12
|
-
cat
|
13
|
-
end
|
6
|
+
attr_accessor(:id, :name, :type, :has_mfa, :mfa, :inst_array)
|
14
7
|
|
15
8
|
def instantiate_all_institutions(res)
|
16
|
-
inst_array = []
|
17
|
-
res
|
18
|
-
|
19
|
-
inst_array <<
|
9
|
+
self.inst_array = []
|
10
|
+
res.each do |inst|
|
11
|
+
institution = Institution.new
|
12
|
+
inst_array << institution.build_institution(inst)
|
20
13
|
end
|
21
|
-
inst_array
|
14
|
+
self.inst_array
|
22
15
|
end
|
23
16
|
|
24
17
|
def instantiate_one_institution(res)
|
25
|
-
|
26
|
-
|
18
|
+
self.build_institution(res)
|
19
|
+
self
|
27
20
|
end
|
28
21
|
|
29
22
|
protected
|
30
23
|
|
31
|
-
def build_institution(
|
32
|
-
self.id =
|
24
|
+
def build_institution(inst)
|
25
|
+
self.id = inst['id'], self.name = inst['name'], self.type = inst['type'], self.has_mfa =inst['has_mfa'], self.mfa = inst['mfa']
|
33
26
|
end
|
34
27
|
|
35
28
|
end
|
data/lib/plaid/user/user.rb
CHANGED
@@ -2,32 +2,74 @@ require_relative 'account/account'
|
|
2
2
|
require_relative 'transaction/transaction'
|
3
3
|
require 'plaid/util'
|
4
4
|
module Plaid
|
5
|
-
class User
|
5
|
+
class Plaid::User
|
6
6
|
include Plaid::Util
|
7
7
|
|
8
8
|
# Define user vars
|
9
|
-
attr_accessor(:accounts, :transactions, :access_token)
|
9
|
+
attr_accessor(:accounts, :transactions, :access_token, :permissions, :api_res, :pending_mfa_questions)
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
self.accounts = []
|
13
13
|
self.transactions = []
|
14
|
+
self.permissions = []
|
14
15
|
self.access_token = ''
|
16
|
+
self.api_res = ''
|
15
17
|
end
|
16
18
|
|
17
19
|
# Instantiate a new user with the results of the successful API call
|
18
20
|
# Build an array of nested accounts, and return self if successful
|
19
|
-
def new(res)
|
21
|
+
def new(res,api_level=nil)
|
22
|
+
build_user(res,api_level)
|
23
|
+
end
|
24
|
+
|
25
|
+
def mfa_authentication(auth,type)
|
26
|
+
auth_path = self.permissions[0] + '/step'
|
27
|
+
res = Plaid.post(auth_path,{mfa:auth,access_token:self.access_token,type:type})
|
28
|
+
self.accounts = [], self.transactions = []
|
29
|
+
update_user(res)
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_auth
|
33
|
+
if self.permissions.include? 'auth'
|
34
|
+
res = Plaid.post('auth/get',{access_token:self.access_token})
|
35
|
+
build_user(res)
|
36
|
+
else
|
37
|
+
false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_connect
|
42
|
+
if self.permissions.include? 'connect'
|
43
|
+
res = Plaid.post('connect/get',{access_token:self.access_token})
|
44
|
+
build_user(res)
|
45
|
+
else
|
46
|
+
false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def upgrade
|
51
|
+
upgrade_to = 'auth' unless self.permissions.include? 'auth'
|
52
|
+
upgrade_to = 'connect' unless self.permissions.include? 'connect'
|
53
|
+
res = Plaid.post('upgrade',{access_token:self.access_token,upgrade_to:upgrade_to})
|
54
|
+
build_user(res)
|
55
|
+
end
|
56
|
+
|
57
|
+
protected
|
58
|
+
|
59
|
+
def build_user(res,api_level=nil)
|
20
60
|
begin
|
21
|
-
|
22
|
-
if res['msg'].nil?
|
61
|
+
if res[:msg].nil?
|
23
62
|
res['accounts'].each do |account|
|
24
63
|
self.accounts << new_account(account)
|
25
64
|
end if res['accounts']
|
26
65
|
res['transactions'].each do |transaction|
|
27
66
|
self.transactions << new_transaction(transaction)
|
28
67
|
end if res['transactions']
|
68
|
+
self.permissions << api_level
|
69
|
+
self.access_token = res['access_token']
|
70
|
+
self.api_res = 'success'
|
29
71
|
else
|
30
|
-
self.accounts = res
|
72
|
+
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]
|
31
73
|
end
|
32
74
|
rescue => e
|
33
75
|
error_handler(e)
|
@@ -36,7 +78,27 @@ module Plaid
|
|
36
78
|
end
|
37
79
|
end
|
38
80
|
|
39
|
-
|
81
|
+
def update_user(res,api_level=nil)
|
82
|
+
begin
|
83
|
+
if res[:msg].nil?
|
84
|
+
res['accounts'].each do |account|
|
85
|
+
self.accounts << new_account(account)
|
86
|
+
end if res['accounts']
|
87
|
+
res['transactions'].each do |transaction|
|
88
|
+
self.transactions << new_transaction(transaction)
|
89
|
+
end if res['transactions']
|
90
|
+
self.permissions << api_level
|
91
|
+
self.api_res = 'success'
|
92
|
+
self.pending_mfa_questions = ''
|
93
|
+
else
|
94
|
+
self.pending_mfa_questions = res[:body]
|
95
|
+
end
|
96
|
+
rescue => e
|
97
|
+
error_handler(e)
|
98
|
+
else
|
99
|
+
self
|
100
|
+
end
|
101
|
+
end
|
40
102
|
|
41
103
|
# Instantiate and build a new account object, return this to the accounts array
|
42
104
|
def new_account(account)
|
data/lib/plaid/util.rb
CHANGED
@@ -4,16 +4,17 @@ require 'uri'
|
|
4
4
|
module Plaid
|
5
5
|
module Util
|
6
6
|
|
7
|
-
def post(path,
|
7
|
+
def post(path,options={})
|
8
8
|
uri = build_uri(path)
|
9
|
-
|
9
|
+
options.merge!({client_id: self.instance_variable_get(:'@customer_id') ,secret: self.instance_variable_get(:'@secret')})
|
10
|
+
res = Net::HTTP.post_form(uri,options)
|
10
11
|
parse_response(res)
|
11
12
|
end
|
12
13
|
|
13
14
|
def get(path,id=nil)
|
14
15
|
uri = build_uri(path,id)
|
15
16
|
res = Net::HTTP.get(uri)
|
16
|
-
|
17
|
+
JSON.parse(res)
|
17
18
|
end
|
18
19
|
|
19
20
|
def error_handler(err,res=nil)
|
@@ -26,6 +27,10 @@ module Plaid
|
|
26
27
|
raise 'Request Failed'
|
27
28
|
when 'Not Found'
|
28
29
|
raise 'Not Found'
|
30
|
+
when 'Institution not supported'
|
31
|
+
raise 'Institution not supported'
|
32
|
+
when 'Corrupted token'
|
33
|
+
raise 'It appears that the access_token has been corrupted'
|
29
34
|
else
|
30
35
|
raise err
|
31
36
|
end
|
@@ -33,31 +38,31 @@ module Plaid
|
|
33
38
|
|
34
39
|
protected
|
35
40
|
|
36
|
-
def build_uri(path,
|
37
|
-
|
38
|
-
|
41
|
+
def build_uri(path,option=nil)
|
42
|
+
path = path + '/' + option unless option.nil?
|
43
|
+
URI.parse(self.instance_variable_get(:'@environment_location') + path)
|
39
44
|
end
|
40
45
|
|
41
46
|
private
|
42
47
|
|
43
48
|
def parse_response(res)
|
44
49
|
body = JSON.parse(res.body)
|
45
|
-
case res.code
|
46
|
-
when
|
50
|
+
case res.code.delete('.').to_i
|
51
|
+
when 200
|
47
52
|
return body
|
48
|
-
when
|
53
|
+
when 201
|
49
54
|
return { msg: 'Requires further authentication', body: body}
|
50
|
-
when
|
55
|
+
when 400
|
51
56
|
error_handler('Bad Request',res)
|
52
|
-
when
|
57
|
+
when 401
|
58
|
+
error_handler('Institution not supported',res) if body['code'] == 1108
|
59
|
+
error_handler('Corrupted token',res) if body['code'] == 1105
|
60
|
+
error_handler('Not Found',res) if body['code'] == 1501
|
53
61
|
error_handler('Unauthorized',res)
|
54
|
-
when
|
55
|
-
if body['code'] == 1205
|
56
|
-
|
57
|
-
|
58
|
-
error_handler('Request Failed',res)
|
59
|
-
end
|
60
|
-
when '404'
|
62
|
+
when 402
|
63
|
+
return {msg: 'User account is locked', body: body} if body['code'] == 1205
|
64
|
+
error_handler('Request Failed', res)
|
65
|
+
when 404
|
61
66
|
error_handler('Not Found',res)
|
62
67
|
else
|
63
68
|
error_handler('Server Error',res)
|
data/lib/plaid/version.rb
CHANGED
data/plaid.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.description = 'Ruby gem wrapper for the Plaid API. Read more at the homepage, the wiki, or the plaid documentation.'
|
12
12
|
spec.homepage = 'https://github.com/plaid/plaid-ruby'
|
13
13
|
spec.license = 'MIT'
|
14
|
+
spec.required_ruby_version = '>= 2.1.3'
|
14
15
|
|
15
16
|
spec.files = `git ls-files -z`.split("\x0")
|
16
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
data/spec/plaid_spec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec_helper.rb'
|
2
2
|
########## Plaid specs ##########
|
3
3
|
describe Plaid do
|
4
|
+
|
4
5
|
# Configuration specs - used in gem configuration
|
5
6
|
describe '.config' do
|
6
7
|
context 'has valid dev keys' do
|
@@ -10,7 +11,7 @@ describe Plaid do
|
|
10
11
|
p.environment_location = 'https://tartan.plaid.com/'
|
11
12
|
end
|
12
13
|
res = Plaid.auth('connect','plaid_test','plaid_good','wells')
|
13
|
-
it { expect(res).to
|
14
|
+
it { expect(res).to be_instance_of Plaid::User }
|
14
15
|
end
|
15
16
|
|
16
17
|
context 'has valid production keys' do
|
@@ -19,9 +20,8 @@ describe Plaid do
|
|
19
20
|
p.secret = 'test_secret'
|
20
21
|
p.environment_location = 'https://api.plaid.com/'
|
21
22
|
end
|
22
|
-
#TODO: Test production level credentials
|
23
23
|
res = Plaid.auth('connect','plaid_test','plaid_good','wells')
|
24
|
-
it { expect(res).to
|
24
|
+
it { expect(res).to be_instance_of Plaid::User }
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'has invalid dev keys' do
|
@@ -30,7 +30,7 @@ describe Plaid do
|
|
30
30
|
p.secret = 'test_bad'
|
31
31
|
p.environment_location = 'https://tartan.plaid.com/'
|
32
32
|
end
|
33
|
-
it { expect
|
33
|
+
it { expect{Plaid.auth('connect','plaid_bad','plaid_bad','wells')}.to raise_error }
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'has invalid production keys' do
|
@@ -39,7 +39,7 @@ describe Plaid do
|
|
39
39
|
p.secret = 'test_bad'
|
40
40
|
p.environment_location = 'https://api.plaid.com/'
|
41
41
|
end
|
42
|
-
it { expect
|
42
|
+
it { expect{Plaid.auth('connect','plaid_bad','plaid_bad','wells')}.to raise_error }
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -54,7 +54,7 @@ describe Plaid do
|
|
54
54
|
p.environment_location = 'https://tartan.plaid.com/'
|
55
55
|
end
|
56
56
|
user = Plaid.auth('connect','plaid_test','plaid_good','wells')
|
57
|
-
it { expect(user.accounts.
|
57
|
+
it { expect(user.accounts.empty?).to be_falsey }
|
58
58
|
end
|
59
59
|
|
60
60
|
context 'has correct credentials for single factor auth, authenticates to the auth path' do
|
@@ -64,7 +64,7 @@ describe Plaid do
|
|
64
64
|
p.environment_location = 'https://tartan.plaid.com/'
|
65
65
|
end
|
66
66
|
user = Plaid.auth('auth','plaid_test','plaid_good','wells')
|
67
|
-
it { expect(user.accounts[0].numbers.nil?).to
|
67
|
+
it { expect(user.accounts[0].numbers.nil?).to be_falsey }
|
68
68
|
end
|
69
69
|
|
70
70
|
context 'has correct username, but incorrect password for single factor auth under auth path' do
|
@@ -73,7 +73,7 @@ describe Plaid do
|
|
73
73
|
p.secret = 'test_secret'
|
74
74
|
p.environment_location = 'https://tartan.plaid.com/'
|
75
75
|
end
|
76
|
-
it { expect
|
76
|
+
it { expect{Plaid.auth('auth','plaid_test','plaid_bad','wells')}.to raise_error }
|
77
77
|
end
|
78
78
|
|
79
79
|
context 'has incorrect username under auth path' do
|
@@ -82,7 +82,7 @@ describe Plaid do
|
|
82
82
|
p.secret = 'test_secret'
|
83
83
|
p.environment_location = 'https://tartan.plaid.com/'
|
84
84
|
end
|
85
|
-
it { expect
|
85
|
+
it { expect{Plaid.auth('auth','plaid_bad','plaid_bad','wells')}.to raise_error }
|
86
86
|
end
|
87
87
|
|
88
88
|
context 'has correct username, but incorrect password for single factor auth under connect path' do
|
@@ -91,7 +91,7 @@ describe Plaid do
|
|
91
91
|
p.secret = 'test_secret'
|
92
92
|
p.environment_location = 'https://tartan.plaid.com/'
|
93
93
|
end
|
94
|
-
it { expect
|
94
|
+
it { expect{Plaid.auth('connect','plaid_test','plaid_bad','wells')}.to raise_error }
|
95
95
|
end
|
96
96
|
|
97
97
|
context 'has incorrect username under connect path' do
|
@@ -100,7 +100,7 @@ describe Plaid do
|
|
100
100
|
p.secret = 'test_secret'
|
101
101
|
p.environment_location = 'https://tartan.plaid.com/'
|
102
102
|
end
|
103
|
-
it { expect
|
103
|
+
it { expect{Plaid.auth('connect','plaid_bad','plaid_bad','wells')}.to raise_error }
|
104
104
|
end
|
105
105
|
|
106
106
|
context 'has to enter MFA credentials' do
|
@@ -109,8 +109,8 @@ describe Plaid do
|
|
109
109
|
p.secret = 'test_secret'
|
110
110
|
p.environment_location = 'https://tartan.plaid.com/'
|
111
111
|
end
|
112
|
-
user = Plaid.auth('connect','plaid_selections', 'plaid_good','
|
113
|
-
it { expect(user.
|
112
|
+
user = Plaid.auth('connect','plaid_selections', 'plaid_good','bofa')
|
113
|
+
it { expect(user.api_res).to eq 'Requires further authentication' }
|
114
114
|
end
|
115
115
|
|
116
116
|
context 'enters correct information with locked account' do
|
@@ -120,133 +120,165 @@ describe Plaid do
|
|
120
120
|
p.environment_location = 'https://tartan.plaid.com/'
|
121
121
|
end
|
122
122
|
user = Plaid.auth('connect','plaid_selections', 'plaid_locked','wells')
|
123
|
-
it { expect(user.
|
123
|
+
it { expect(user.api_res).to eq 'User account is locked' }
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
-
=begin
|
128
|
-
TODO: Finish up these tests
|
129
127
|
# Institution specs
|
130
|
-
describe
|
128
|
+
describe '#Institution' do
|
129
|
+
context 'when a single institution is found' do
|
130
|
+
Plaid.config do |p|
|
131
|
+
p.customer_id = 'test_id'
|
132
|
+
p.secret = 'test_secret'
|
133
|
+
p.environment_location = 'https://tartan.plaid.com/'
|
134
|
+
end
|
135
|
+
institution = Plaid.institution('5301a93ac140de84910000e0')
|
136
|
+
it { expect(institution.class).to eq(Plaid::Institution) }
|
137
|
+
end
|
131
138
|
|
132
|
-
context 'when
|
139
|
+
context 'when all institutions are found' do
|
133
140
|
Plaid.config do |p|
|
134
141
|
p.customer_id = 'test_id'
|
135
142
|
p.secret = 'test_secret'
|
136
143
|
p.environment_location = 'https://tartan.plaid.com/'
|
137
144
|
end
|
138
|
-
institution = Plaid.institution
|
139
|
-
it { expect(institution).to
|
145
|
+
institution = Plaid.institution
|
146
|
+
it { expect(institution).to be_kind_of(Array) }
|
140
147
|
end
|
141
148
|
|
149
|
+
=begin TODO: Get this test passing
|
142
150
|
context 'when institution is not found' do
|
143
151
|
Plaid.config do |p|
|
144
152
|
p.customer_id = 'test_id'
|
145
153
|
p.secret = 'test_secret'
|
146
154
|
p.environment_location = 'https://tartan.plaid.com/'
|
147
155
|
end
|
148
|
-
|
156
|
+
res = Plaid.institution('dumb_bank')
|
157
|
+
it { expect(res).to eq('Bank not found') }
|
149
158
|
end
|
159
|
+
=end
|
150
160
|
end
|
151
161
|
|
152
162
|
# Category specs
|
153
|
-
describe
|
154
|
-
|
155
|
-
context 'when category is found' do
|
163
|
+
describe '#Category' do
|
164
|
+
context 'when a single category is found' do
|
156
165
|
Plaid.config do |p|
|
157
166
|
p.customer_id = 'test_id'
|
158
167
|
p.secret = 'test_secret'
|
159
168
|
p.environment_location = 'https://tartan.plaid.com/'
|
160
169
|
end
|
161
170
|
category = Plaid.category('17001013')
|
162
|
-
it { expect(category).to
|
171
|
+
it { expect(category.class).to eq (Plaid::Category) }
|
163
172
|
end
|
164
173
|
|
174
|
+
context 'when all categories are found' do
|
175
|
+
Plaid.config do |p|
|
176
|
+
p.customer_id = 'test_id'
|
177
|
+
p.secret = 'test_secret'
|
178
|
+
p.environment_location = 'https://tartan.plaid.com/'
|
179
|
+
end
|
180
|
+
category = Plaid.category
|
181
|
+
it { expect(category).to be_kind_of(Array)}
|
182
|
+
end
|
183
|
+
|
184
|
+
=begin TODO: Get this test passing
|
165
185
|
context 'when category is not found' do
|
166
186
|
Plaid.config do |p|
|
167
187
|
p.customer_id = 'test_id'
|
168
188
|
p.secret = 'test_secret'
|
169
189
|
p.environment_location = 'https://tartan.plaid.com/'
|
170
190
|
end
|
171
|
-
it { expect
|
191
|
+
it { expect { Plaid.category('dumb_cat') }.to raise_error }
|
172
192
|
end
|
193
|
+
=end
|
173
194
|
|
174
195
|
end
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
describe
|
180
|
-
|
181
|
-
|
196
|
+
########## Plaid instantiated user specs ##########
|
197
|
+
|
198
|
+
describe '#User' do
|
199
|
+
# MFA specs - after user is instantiated,
|
200
|
+
describe '#mfa_authentication' do
|
201
|
+
|
202
|
+
context 'enters correct credentials for MFA auth and authenticates' do
|
203
|
+
Plaid.config do |p|
|
204
|
+
p.customer_id = 'test_id'
|
205
|
+
p.secret = 'test_secret'
|
206
|
+
p.environment_location = 'https://tartan.plaid.com/'
|
207
|
+
end
|
208
|
+
new_mfa_user = Plaid.auth('connect','plaid_selections', 'plaid_good','bofa')
|
209
|
+
new_mfa_user.mfa_authentication('tomato','bofa')
|
210
|
+
it { expect(new_mfa_user.accounts).to be_truthy }
|
211
|
+
end
|
182
212
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
213
|
+
context 'has to enter another round of MFA credentials' do
|
214
|
+
Plaid.config do |p|
|
215
|
+
p.customer_id = 'test_id'
|
216
|
+
p.secret = 'test_secret'
|
217
|
+
p.environment_location = 'https://tartan.plaid.com/'
|
218
|
+
end
|
219
|
+
mfa_again = Plaid.auth('connect','plaid_selections', 'plaid_good','bofa')
|
220
|
+
mfa_again.mfa_authentication('again','bofa')
|
221
|
+
it { expect(mfa_again.api_res).to eq 'Requires further authentication' }
|
222
|
+
end
|
189
223
|
|
190
|
-
|
191
|
-
|
192
|
-
|
224
|
+
context 'enters incorrect credentials for MFA auth' do
|
225
|
+
Plaid.config do |p|
|
226
|
+
p.customer_id = 'test_id'
|
227
|
+
p.secret = 'test_secret'
|
228
|
+
p.environment_location = 'https://tartan.plaid.com/'
|
229
|
+
end
|
230
|
+
mfa_user = Plaid.auth('connect','plaid_selections', 'plaid_good','bofa')
|
231
|
+
mfa_user.mfa_authentication('tomato','bofa')
|
232
|
+
mfa_user = Plaid.auth('connect','plaid_selections', 'plaid_good','bofa')
|
233
|
+
it { expect { mfa_user.mfa_authentication('bad','bofa') }.to raise_error }
|
234
|
+
end
|
193
235
|
end
|
194
236
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
end
|
237
|
+
# Auth specs
|
238
|
+
describe '#get_auth' do
|
239
|
+
auth_user = Plaid.auth('auth','plaid_test','plaid_good','wells')
|
240
|
+
connect_user = Plaid.auth('connect','plaid_test','plaid_good','wells')
|
200
241
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
user.upgrade('auth')
|
205
|
-
expect(user.auth).to be true
|
206
|
-
end
|
242
|
+
context 'has access and returns accounts' do
|
243
|
+
it { expect(auth_user.permissions[0]).to eq('auth') }
|
244
|
+
end
|
207
245
|
|
208
|
-
|
209
|
-
|
210
|
-
|
246
|
+
context 'does not have access to auth' do
|
247
|
+
it{ expect(connect_user.permissions.include? 'auth' ).to be false }
|
248
|
+
end
|
211
249
|
end
|
212
250
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
251
|
+
# Connect specs
|
252
|
+
describe '#get_connect' do
|
253
|
+
auth_user = Plaid.auth('auth','plaid_test','plaid_good','wells')
|
254
|
+
connect_user = Plaid.auth('connect','plaid_test','plaid_good','wells')
|
217
255
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
end
|
222
|
-
end
|
256
|
+
context 'has access and returns accounts' do
|
257
|
+
it { expect(connect_user.permissions[0]).to eq('connect') }
|
258
|
+
end
|
223
259
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
auth = user.auth
|
228
|
-
expect(auth).to be true
|
229
|
-
expect(user.accounts).to be_truthy
|
260
|
+
context 'does not have access to auth' do
|
261
|
+
it{ expect(auth_user.permissions.include? 'connect' ).to be false }
|
262
|
+
end
|
230
263
|
end
|
231
264
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
265
|
+
# Upgrade specs - either pass or fails
|
266
|
+
=begin TODO: Write upgrade methods to pass without paying
|
267
|
+
describe '#upgrade' do
|
268
|
+
auth_user = Plaid.auth('auth','plaid_test','plaid_good','wells')
|
269
|
+
connect_user = Plaid.auth('connect','plaid_test','plaid_good','wells')
|
237
270
|
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
expect(user.transactions).to be_truthy
|
243
|
-
end
|
271
|
+
context 'auth upgrade is successful' do
|
272
|
+
connect_user.upgrade
|
273
|
+
it { expect(connect_user.get_auth).to be_truthy }
|
274
|
+
end
|
244
275
|
|
245
|
-
|
246
|
-
|
276
|
+
context 'connect upgrade is successful' do
|
277
|
+
auth_user.upgrade
|
278
|
+
it { expect(auth_user.get_connect).to be_truthy }
|
279
|
+
end
|
247
280
|
end
|
248
|
-
end
|
249
|
-
|
250
281
|
=end
|
251
282
|
|
283
|
+
end
|
252
284
|
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.0.
|
4
|
+
version: 1.0.1
|
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-01-
|
11
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -61,6 +61,7 @@ extensions: []
|
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
63
|
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
64
65
|
- Gemfile
|
65
66
|
- LICENSE.txt
|
66
67
|
- README.md
|
@@ -90,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
91
|
requirements:
|
91
92
|
- - ">="
|
92
93
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
94
|
+
version: 2.1.3
|
94
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
96
|
requirements:
|
96
97
|
- - ">="
|