zen-plaid 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6b519922fa379a6daeb4daab3532af7ce63fa46
4
- data.tar.gz: cf7ee2f343ab48afc87a17ce65b5edca75333e40
3
+ metadata.gz: 0c3e87f8a6171381574d7e3e643f3cb6f23c7baa
4
+ data.tar.gz: 60efc4c37af64802d244e641b0647d2a487ea4be
5
5
  SHA512:
6
- metadata.gz: 00ad929ef2b22e9c452b44d53c125b3921dc321332e376adcef981c3d517c72a27c626c43cd34756b6321eb85b7ba3e1ca76ce7f398d671cbfac0d1a9bb333ca
7
- data.tar.gz: 05df053ed9761ecf194dd22c25a2a0cc6b1df1253b449540c3e8d8568359aaf11fbb5c82c6554803d961d3e4029ac88d86c841c41e16e4a7bcc055b569639800
6
+ metadata.gz: 33bf4ec03e57e8d21f4bbcf067c85c65e9603dce1281be7cd91a94fa8e7b3208770c697d4d5facc224a0b595875e73369788d019ad8362f93c23aa44470d84bf
7
+ data.tar.gz: 5ade6cc8a485d42e881c4d2ddd1b7a8a7ffd0fa06b6ef390cf652e74c1319c3ff1b671635b2bf67bf97a9dffe92694e1becfcf88a49e09d708da26b597202645
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --format documentation
@@ -1,7 +1,7 @@
1
1
  module Plaid
2
2
  class Auth
3
3
  def self.add(params)
4
- Plaid.request(:post, '/auth', params)
4
+ Plaid.request(:post, '/auth', Plaid::Util.credentials_params(params))
5
5
  end
6
6
  end
7
7
  end
@@ -5,7 +5,7 @@ module Plaid
5
5
  end
6
6
 
7
7
  def self.add(params)
8
- Plaid.request(:post, '/connect', params)
8
+ Plaid.request(:post, '/connect', Plaid::Util.credentials_params(params))
9
9
  end
10
10
 
11
11
  def self.mfa_step(params)
@@ -63,5 +63,22 @@ module Plaid
63
63
  end
64
64
  result
65
65
  end
66
+
67
+ def self.credentials_params(params)
68
+ unless params.has_key?(:credentials)
69
+ warn "You should use credentials to pass in username/password/pin"
70
+
71
+ params[:credentials] = {}
72
+ params[:credentials][:username] = params[:username] if params[:username]
73
+ params[:credentials][:password] = params[:password] if params[:password]
74
+ params[:credentials][:pin] = params[:pin] if params[:pin]
75
+ end
76
+
77
+ params.delete(:username)
78
+ params.delete(:password)
79
+ params.delete(:pin)
80
+
81
+ params
82
+ end
66
83
  end
67
84
  end
@@ -1,3 +1,3 @@
1
1
  module Plaid
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/spec/auth_spec.rb CHANGED
@@ -9,9 +9,9 @@ describe Plaid::Auth do
9
9
  end
10
10
 
11
11
  context 'missing password' do
12
- it "returns 400 http code" do
12
+ it "returns 402 http code" do
13
13
  connection = Plaid::Auth.add({type: 'bofa', username: 'plaid_test'})
14
- expect(connection[:code]).to eq(400)
14
+ expect(connection[:code]).to eq(402)
15
15
  end
16
16
  end
17
17
 
@@ -75,22 +75,17 @@ describe Plaid::Auth do
75
75
  end
76
76
  end
77
77
 
78
- # context 'correct credentials with pin' do
79
- # it "returns 200 http code" do
80
- # connection = Plaid::Auth.add({type: 'usaa', username: 'plaid_test', password: 'plaid_good', pin: 1234})
81
- # expect(connection[:code]).to eq(200)
82
- # end
83
-
84
- # it "returns accounts" do
85
- # connection = Plaid::Auth.add({type: 'usaa', username: 'plaid_test', password: 'plaid_good', pin: 1234})
86
- # expect(connection[:message]).to have_key(:accounts)
87
- # end
88
-
89
- # it "returns transactions" do
90
- # connection = Plaid::Auth.add({type: 'usaa', username: 'plaid_test', password: 'plaid_good', pin: 1234})
91
- # expect(connection[:message]).to have_key(:transactions)
92
- # end
93
- # end
78
+ context 'correct credentials with pin' do
79
+ it "returns 201 http code" do
80
+ connection = Plaid::Auth.add({type: 'usaa', username: 'plaid_test', password: 'plaid_good', pin: 1234})
81
+ expect(connection[:code]).to eq(201)
82
+ end
83
+
84
+ it "returns mfa question" do
85
+ connection = Plaid::Auth.add({type: 'usaa', username: 'plaid_test', password: 'plaid_good', pin: 1234})
86
+ expect(connection[:message]).to have_key(:mfa)
87
+ end
88
+ end
94
89
 
95
90
  context 'correct credentials with default chase mfa' do
96
91
  it "returns 201 http code" do
data/spec/connect_spec.rb CHANGED
@@ -67,9 +67,9 @@ describe Plaid::Connect do
67
67
 
68
68
  describe "#add" do
69
69
  context 'missing password' do
70
- it "returns 400 http code" do
70
+ it "returns 402 http code" do
71
71
  connection = Plaid::Connect.add({type: 'amex', username: 'plaid_test'})
72
- expect(connection[:code]).to eq(400)
72
+ expect(connection[:code]).to eq(402)
73
73
  end
74
74
  end
75
75
 
@@ -156,19 +156,14 @@ describe Plaid::Connect do
156
156
  end
157
157
 
158
158
  context 'correct credentials with pin' do
159
- it "returns 200 http code" do
160
- connection = Plaid::Connect.add({type: 'amex', username: 'plaid_test', password: 'plaid_good', pin: 1234})
161
- expect(connection[:code]).to eq(200)
162
- end
163
-
164
- it "returns accounts" do
165
- connection = Plaid::Connect.add({type: 'amex', username: 'plaid_test', password: 'plaid_good', pin: 1234})
166
- expect(connection[:message]).to have_key(:accounts)
159
+ it "returns 201 http code" do
160
+ connection = Plaid::Connect.add({type: 'usaa', username: 'plaid_test', password: 'plaid_good', pin: 1234})
161
+ expect(connection[:code]).to eq(201)
167
162
  end
168
163
 
169
- it "returns transactions" do
170
- connection = Plaid::Connect.add({type: 'amex', username: 'plaid_test', password: 'plaid_good', pin: 1234})
171
- expect(connection[:message]).to have_key(:transactions)
164
+ it "returns mfa question" do
165
+ connection = Plaid::Auth.add({type: 'usaa', username: 'plaid_test', password: 'plaid_good', pin: 1234})
166
+ expect(connection[:message]).to have_key(:mfa)
172
167
  end
173
168
  end
174
169
 
data/spec/util_spec.rb ADDED
@@ -0,0 +1,42 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Plaid::Util do
4
+ describe ".credentials_params" do
5
+ context 'already has credentials' do
6
+ let(:params) { { credentials: {username: 'plaid_test', password: 'plaid_good'}, type: 'chase' } }
7
+ let(:fixed_params) { Plaid::Util.credentials_params(params) }
8
+
9
+ it { expect(fixed_params).to have_key(:credentials) }
10
+ it { expect(fixed_params[:credentials]).to have_key(:username) }
11
+ it { expect(fixed_params[:credentials]).to have_key(:password) }
12
+ it { expect(fixed_params[:credentials]).to_not have_key(:pin) }
13
+ end
14
+
15
+ context 'no credentials' do
16
+ let(:params) { { username: 'plaid_test', password: 'plaid_good', type: 'chase' } }
17
+ let(:fixed_params) { Plaid::Util.credentials_params(params) }
18
+
19
+ it { expect(fixed_params).to have_key(:credentials) }
20
+ it { expect(fixed_params[:credentials]).to have_key(:username) }
21
+ it { expect(fixed_params[:credentials]).to have_key(:password) }
22
+
23
+ it { expect(fixed_params).to_not have_key(:username) }
24
+ it { expect(fixed_params).to_not have_key(:password) }
25
+ it { expect(fixed_params[:credentials]).to_not have_key(:pin) }
26
+ end
27
+
28
+ context 'no credentials with pin' do
29
+ let(:params) { { username: 'plaid_test', password: 'plaid_good', pin: 1234, type: 'chase' } }
30
+ let(:fixed_params) { Plaid::Util.credentials_params(params) }
31
+
32
+ it { expect(fixed_params).to have_key(:credentials) }
33
+ it { expect(fixed_params[:credentials]).to have_key(:username) }
34
+ it { expect(fixed_params[:credentials]).to have_key(:password) }
35
+ it { expect(fixed_params[:credentials]).to have_key(:pin) }
36
+
37
+ it { expect(fixed_params).to_not have_key(:username) }
38
+ it { expect(fixed_params).to_not have_key(:password) }
39
+ it { expect(fixed_params).to_not have_key(:pin) }
40
+ end
41
+ end
42
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zen-plaid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean McCann
@@ -96,6 +96,7 @@ files:
96
96
  - spec/entity_spec.rb
97
97
  - spec/institution_spec.rb
98
98
  - spec/spec_helper.rb
99
+ - spec/util_spec.rb
99
100
  - zen-plaid.gemspec
100
101
  homepage: https://github.com/seanmccann/zen-plaid
101
102
  licenses: