plaid 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb83ce0044d87a79faa370283d1d16a85c5b3e34
4
- data.tar.gz: 430bc60bc0ef7358624aeeb8ba6810d707692d96
3
+ metadata.gz: 00be434d6e58902d9c47db517d0907f668fe620c
4
+ data.tar.gz: c60a4d95dc87cbff07092a77af43e03bc4f7c1f3
5
5
  SHA512:
6
- metadata.gz: 38e5062cacf0c071ccf06fd25797d533ce40089b820f966a05c41ee6bcbe7d288461a0f1e95fef6b0f570648ebabd993a110f877d5837ffffc7bfaffcac560c2
7
- data.tar.gz: 842052852e27e8d125a58c97b48a7fe470595340db39e08ea63028b956f023da86b3f637a963f40b3d155b7031982372ed0054429d4b8755fd862b54bd0d0e4a
6
+ metadata.gz: f0d01df929e6ea2c7a3c3329304814189d78a6074e07507c07124f8c54e60cf1cfc6c2fd8740d35fef964fec26003996576792ddc905ce29ae992b5a4b8c457a
7
+ data.tar.gz: c90dc4c04e8f953c197a8838984cb53a584ce33325c48112fee5972719179195f153f3f3fb3010e70b76353ae00662feded4ad6a37dd0f653aae73493a05aa7e
@@ -1,6 +1,7 @@
1
1
  require_relative 'account/account'
2
2
  require_relative 'transaction/transaction'
3
3
  require 'plaid/util'
4
+ require 'json'
4
5
  module Plaid
5
6
  class Plaid::User
6
7
  include Plaid::Util
@@ -30,6 +31,12 @@ module Plaid
30
31
  build_user(res)
31
32
  end
32
33
 
34
+ def select_mfa_method(selection,type)
35
+ auth_path = self.permissions.last + '/step'
36
+ res = Plaid.post(auth_path,{options:{send_method: selection}.to_json, access_token:self.access_token,type:type})
37
+ build_user(res,self.permissions.last)
38
+ end
39
+
33
40
  def get_auth
34
41
  if self.permissions.include? 'auth'
35
42
  res = Plaid.post('auth/get',{access_token:self.access_token})
@@ -79,6 +86,7 @@ module Plaid
79
86
  api_level = 'connect' unless self.permissions.include? 'connect'
80
87
  end
81
88
  res = Plaid.post('upgrade',{access_token:self.access_token,upgrade_to:api_level})
89
+ self.accounts = [], self.transactions = []
82
90
  build_user(res)
83
91
  end
84
92
 
@@ -107,16 +115,17 @@ module Plaid
107
115
  self.transactions << new_transaction(transaction)
108
116
  end
109
117
  end if res['transactions']
110
- self.permissions << api_level unless self.permissions.include? api_level
118
+ self.permissions << api_level unless self.permissions.include? api_level && api_level.nil?
111
119
  self.api_res = 'success'
112
120
  self.pending_mfa_questions = ''
121
+ self.info.merge!(res['info']) if res['info']
113
122
  self.access_token = res['access_token']
114
123
  clean_up_user(self)
115
124
  else
116
125
  self.access_token = res[:body]['access_token']
117
126
  self.pending_mfa_questions = res[:body]
118
127
  self.api_res = res[:msg]
119
- self.permissions << api_level
128
+ self.permissions << api_level unless self.permissions.include? api_level && api_level.nil?
120
129
  end
121
130
  rescue => e
122
131
  error_handler(e)
data/lib/plaid/util.rb CHANGED
@@ -31,7 +31,6 @@ module Plaid
31
31
  req.body = URI.encode_www_form(options) if options
32
32
  req.content_type = 'multipart/form-data'
33
33
  res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
34
- puts res
35
34
  end
36
35
 
37
36
  def error_handler(err,res=nil)
data/lib/plaid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plaid
2
- VERSION = '1.2.2'
2
+ VERSION = '1.2.3'
3
3
  end
data/spec/plaid_spec.rb CHANGED
@@ -373,6 +373,42 @@ describe Plaid do
373
373
  mfa_user = Plaid.add_user('connect','plaid_selections', 'plaid_good','bofa')
374
374
  it { expect { mfa_user.mfa_authentication('bad','bofa') }.to raise_error }
375
375
  end
376
+
377
+ context 'requests list of MFA credentials' do
378
+ Plaid.config do |p|
379
+ p.customer_id = 'test_id'
380
+ p.secret = 'test_secret'
381
+ p.environment_location = 'https://tartan.plaid.com/'
382
+ end
383
+
384
+ new_mfa_user = Plaid.add_user('auth','plaid_test','plaid_good','chase',nil,'{"list":true}')
385
+ 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"}) }
386
+ end
387
+
388
+ context 'selects MFA method and returns successful response' do
389
+ Plaid.config do |p|
390
+ p.customer_id = 'test_id'
391
+ p.secret = 'test_secret'
392
+ p.environment_location = 'https://tartan.plaid.com/'
393
+ end
394
+
395
+ new_mfa_user = Plaid.add_user('auth','plaid_test','plaid_good','chase',nil,'{"list":true}')
396
+ new_mfa_user.select_mfa_method({mask:'xxx-xxx-5309'},'chase')
397
+ it { expect(new_mfa_user.pending_mfa_questions).to eq({"type"=>"device", "mfa"=>{"message"=>"Code sent to xxx-xxx-5309"}, "access_token"=>"test"}) }
398
+ end
399
+
400
+ context 'selects MFA method, and delivers correct payload to authenticate user' do
401
+ Plaid.config do |p|
402
+ p.customer_id = 'test_id'
403
+ p.secret = 'test_secret'
404
+ p.environment_location = 'https://tartan.plaid.com/'
405
+ end
406
+
407
+ new_mfa_user = Plaid.add_user('auth','plaid_test','plaid_good','chase',nil,'{"list":true}')
408
+ new_mfa_user.select_mfa_method({mask:'xxx-xxx-5309'},'chase')
409
+ new_mfa_user.mfa_authentication(1234,'chase')
410
+ it { expect(new_mfa_user.accounts).to be_truthy }
411
+ end
376
412
  end
377
413
 
378
414
  # Auth specs
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.2.2
4
+ version: 1.2.3
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-09 00:00:00.000000000 Z
11
+ date: 2015-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler