plaid 1.1.0 → 1.1.1

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: 2df30fbdad26bdf216850618dadf355fd17e3cee
4
- data.tar.gz: 2e70845646767b8174a1b77314933b2bb8a384fb
3
+ metadata.gz: 4b9b30810a3e3392732bf1ee7e843267f19a01aa
4
+ data.tar.gz: ac4cbb40ad2161c03d410f3cbec2054e059fa193
5
5
  SHA512:
6
- metadata.gz: 2fba432e8eb41e8abd6603f00327aa8d07da2ed5be065cd63b73784f8205f4524e7e4b486ef497a9a666f4714570c34e432119802a454b12c588e7e0a621d062
7
- data.tar.gz: 3a01497f2fe95e950924fb314d00cb1fbdeb01cc779e201a2c48f541d4c55ce6dcd6fe3726d0281afe972be9b121a4e00dda0696131368e7c4c6dbddf08d1203
6
+ metadata.gz: ce258ad0a147fe6125ad54ea652ea22c2e06f61459f137e5e1284873cd5f59e12a8cfe1d69aa489f77d20be228585f1a15cf652a0218f8147830ef785cb0826b
7
+ data.tar.gz: ce3bc86d3f69fa81615420d177360f9d41848b12f7ed14cc176360afc7e4777c97d6f513e64982ec7fa9c7012fda3a549f2668bc2e4e51a0c265fc2e34e77102
@@ -1,10 +1,11 @@
1
1
  module Plaid
2
2
  module AddUser
3
- def add_user(api_level,username,password,type,pin=nil)
3
+ def add_user(api_level,username,password,type,pin=nil,options=nil)
4
4
  begin
5
- options = {username:username,password:password,type:type}
6
- options.merge!(pin:pin) if pin
7
- res = self.post(api_level,options)
5
+ payload = {username:username,password:password,type:type}
6
+ payload.merge!(pin:pin) if pin
7
+ payload.merge!(options: options) if options
8
+ res = self.post(api_level,payload)
8
9
  self.user(res,api_level)
9
10
  rescue => e
10
11
  error_handler(e)
@@ -3,13 +3,13 @@ module Plaid
3
3
  class Account
4
4
  include Plaid::Util
5
5
  # Define vars for user accounts
6
- attr_accessor(:available_balance, :current_balance, :institution_type, :meta, :transactions, :numbers, :name)
6
+ attr_accessor(:available_balance, :current_balance, :institution_type, :meta, :transactions, :numbers, :name, :id, :type)
7
7
 
8
8
  # Instantiate a new account with the results of the successful API call
9
9
  # Build an array of nested transactions, and return self if successful
10
10
  def new(res)
11
11
  begin
12
- self.name = res['name'], self.available_balance = res['balance']['available'], self.current_balance = res['balance']['current'], self.institution_type = res['institution_type']
12
+ 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']
13
13
  self.meta = res['meta'] if res['meta']
14
14
  res['numbers'] ? self.numbers = res['numbers'] : self.numbers = 'Upgrade user to access routing information for this account'
15
15
  rescue => e
@@ -68,6 +68,7 @@ module Plaid
68
68
  self.permissions << api_level
69
69
  self.access_token = res['access_token']
70
70
  self.api_res = 'success'
71
+ clean_up_user(self)
71
72
  else
72
73
  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]
73
74
  end
@@ -112,5 +113,12 @@ module Plaid
112
113
  @transaction.new(transaction)
113
114
  end
114
115
 
116
+ private
117
+
118
+ def clean_up_user(user)
119
+ user.accounts.reject! { |c| !c.instance_of? Plaid::Account }
120
+ user
121
+ end
122
+
115
123
  end
116
124
  end
@@ -1,3 +1,3 @@
1
1
  module Plaid
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -141,6 +141,76 @@ describe Plaid do
141
141
  user = Plaid.add_user('connect','plaid_selections', 'plaid_locked','wells')
142
142
  it { expect(user.api_res).to eq 'User account is locked' }
143
143
  end
144
+
145
+ context 'enters webhook option as part of standard call' do
146
+ Plaid.config do |p|
147
+ p.customer_id = 'test_id'
148
+ p.secret = 'test_secret'
149
+ p.environment_location = 'https://tartan.plaid.com/'
150
+ end
151
+ user = Plaid.add_user('connect','plaid_test', 'plaid_good','wells',{login_only: true, webhook: 'test.com/test.endpoint.aspx'})
152
+ it { expect(user.accounts.empty?).to be_falsey }
153
+ end
154
+
155
+ context 'enters webhook option as part of mfa required institution authentication' do
156
+ Plaid.config do |p|
157
+ p.customer_id = 'test_id'
158
+ p.secret = 'test_secret'
159
+ p.environment_location = 'https://tartan.plaid.com/'
160
+ end
161
+ user = Plaid.add_user('connect','plaid_selections', 'plaid_good','bofa',{login_only: true, webhook: 'test.com/test.endpoint.aspx'})
162
+ it { expect(user.api_res).to eq 'Requires further authentication' }
163
+ end
164
+
165
+ context 'requests pending transactions from an institution' do
166
+ Plaid.config do |p|
167
+ p.customer_id = 'test_id'
168
+ p.secret = 'test_secret'
169
+ p.environment_location = 'https://tartan.plaid.com/'
170
+ end
171
+ user = Plaid.add_user('connect','plaid_selections', 'plaid_locked','wells',{pending: true})
172
+ it { expect(user.accounts.empty?).to be_falsey }
173
+ end
174
+
175
+ context 'sets the login only option to true' do
176
+ Plaid.config do |p|
177
+ p.customer_id = 'test_id'
178
+ p.secret = 'test_secret'
179
+ p.environment_location = 'https://tartan.plaid.com/'
180
+ end
181
+ user = Plaid.add_user('connect','plaid_selections', 'plaid_locked','wells',{login_only:true})
182
+ it { expect(user.accounts.empty?).to be_falsey }
183
+ end
184
+
185
+ context 'requests a list of options for code based MFA' do
186
+ Plaid.config do |p|
187
+ p.customer_id = 'test_id'
188
+ p.secret = 'test_secret'
189
+ p.environment_location = 'https://tartan.plaid.com/'
190
+ end
191
+ user = Plaid.add_user('connect','plaid_selections', 'plaid_locked','citi',{list: true})
192
+ it { expect(user.accounts.empty?).to be_falsey }
193
+ end
194
+
195
+ context 'sets a start date for transactions' do
196
+ Plaid.config do |p|
197
+ p.customer_id = 'test_id'
198
+ p.secret = 'test_secret'
199
+ p.environment_location = 'https://tartan.plaid.com/'
200
+ end
201
+ user = Plaid.add_user('connect','plaid_selections', 'plaid_locked','wells',{login_only:true, start_date:'10 days ago'})
202
+ it { expect(user.accounts.empty?).to be_falsey }
203
+ end
204
+
205
+ context 'sets an end date for transactions' do
206
+ Plaid.config do |p|
207
+ p.customer_id = 'test_id'
208
+ p.secret = 'test_secret'
209
+ p.environment_location = 'https://tartan.plaid.com/'
210
+ end
211
+ user = Plaid.add_user('connect','plaid_selections', 'plaid_locked','wells',{login_only:true, end_date: '10 days ago'})
212
+ it { expect(user.accounts.empty?).to be_falsey }
213
+ end
144
214
  end
145
215
 
146
216
  # Institution specs
@@ -215,6 +285,30 @@ describe Plaid do
215
285
  ########## Plaid instantiated user specs ##########
216
286
 
217
287
  describe '#User' do
288
+
289
+ describe 'user vars' do
290
+
291
+ context 'valid user has accounts and accounts contain id attribute' do
292
+ Plaid.config do |p|
293
+ p.customer_id = 'test_id'
294
+ p.secret = 'test_secret'
295
+ p.environment_location = 'https://tartan.plaid.com/'
296
+ end
297
+ user = Plaid.add_user('connect','plaid_test','plaid_good','wells')
298
+ it { expect(user.accounts.first.id).to be_truthy }
299
+ end
300
+
301
+ context 'valid user has accounts and accounts contain type attribute' do
302
+ Plaid.config do |p|
303
+ p.customer_id = 'test_id'
304
+ p.secret = 'test_secret'
305
+ p.environment_location = 'https://tartan.plaid.com/'
306
+ end
307
+ user = Plaid.add_user('connect','plaid_test','plaid_good','wells')
308
+ it { expect(user.accounts.first.type).to eq('depository') }
309
+ end
310
+ end
311
+
218
312
  # MFA specs - after user is instantiated,
219
313
  describe '#mfa_authentication' do
220
314
 
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.1.0
4
+ version: 1.1.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-02-02 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler