plaid 1.5.3 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MjcyODE1ZDJkZmVhM2EzNDNhNDhmNzU3ZjJhYTkzM2E2NmMzMzY3Nw==
5
- data.tar.gz: !binary |-
6
- NDdlOWQzNzFhZTFkNmEwYjI1NGFkM2NjZmQ5NDkyOGQxZDYwNzQwNA==
2
+ SHA1:
3
+ metadata.gz: e6d908c1414b318f27227f565e9759fbf9bf4f70
4
+ data.tar.gz: 0b58a02596bc5962222f6a9e24a89356ffecf465
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YjIyODZmMWY4ZmYyMWM0MTc5Yzg5MGVkZThkMzlkZDc3NjEyMzExNmY0NDI1
10
- ODE1Y2QwMmExMGY5Yzc1MjNjYzkyYjk5NmZjZjAzMTJhZWM3YWZmYWU1OGIw
11
- ZDcwZGMxM2M0YTJkMTNmODMxMjg2ZmFlYjM1MWM5MTBhOWU4YmI=
12
- data.tar.gz: !binary |-
13
- ZDc3NjExNjFhMGM4NDNkZmY3NGMwMmI4OGI2YjBjOGQ1MGNkYmViYzVkNDE0
14
- MjA5Mzc2ZGI0OTQyNDE4NWQwNjVkNzlkMGNhM2E0ZWU3YWFkYjg5MWVlYzdj
15
- ZTlhNDM5ZmU1MjFkYTFhYjRlZTZlMThjNzAwMmMyMTZiNTFlNWU=
6
+ metadata.gz: 4607eca9f2685e8393b5bb7ee05038112c27be81e5f945e606d14f53d9d683c859b6a749475ee63bc57d6f00bdd2994b6981a7e95ecdf39c781d7803388faed9
7
+ data.tar.gz: 4604000d9d61b6c0962d083defc80bd9e76359f20c82d7177f0f91d781756d5d857ce3860fa68884c28b5c32a1b1d79a2b19b984316f484b41a964e8c52ba81f
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/README.md CHANGED
@@ -6,7 +6,7 @@ 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.5.3**
9
+ Latest stable version: **1.6.0**
10
10
 
11
11
  This version removes the need to use 'type' in each additional call.
12
12
 
@@ -49,7 +49,7 @@ end
49
49
  Authenticate a user to your desired level of api access (auth / connect).
50
50
 
51
51
  ```ruby
52
- user = Plaid.add_user('auth','plaid_test','plaid_good','wells')
52
+ user = Plaid.add_user('auth', 'plaid_test', 'plaid_good', 'wells')
53
53
  ```
54
54
 
55
55
  If the authentication requires a pin, you can pass it in as the fifth argument:
@@ -61,7 +61,7 @@ user = Plaid.add_user('auth', 'plaid_test', 'plaid_good', 'usaa', '1234')
61
61
  To add options such as `login_only` or `webhooks`, use the sixth argument:
62
62
 
63
63
  ```ruby
64
- user = Plaid.add_user('auth','plaid_test','plaid_good','wells', nil, { login_only: true, webhooks: 'https://example.org/callbacks/plaid')
64
+ user = Plaid.add_user('auth', 'plaid_test', 'plaid_good', 'wells', nil, { login_only: true, webhooks: 'https://example.org/callbacks/plaid')
65
65
  ```
66
66
 
67
67
  ### Restoring a Plaid User using an access token
@@ -101,7 +101,7 @@ user.accounts.each { |account| print account.meta['name'] + "\n"}
101
101
 
102
102
  Methods marked with `API: public` are officially supported by the gem maintainers. Since
103
103
  we are using semantic versioning (http://semver.org/spec/v2.0.0.html), the maintainers are
104
- commited to backwards-compatibility support for these API calls when we update the Minor
104
+ committed to backwards-compatibility support for these API calls when we update the Minor
105
105
  version. So for example, going from version 1.4.x to 1.5.x will not change these public
106
106
  API calls.
107
107
 
@@ -109,7 +109,7 @@ However, we may change these method signatures or even the gem architecture when
109
109
  the Major number. For example, we have some breaking changes in mind with version 2.0
110
110
 
111
111
  Methods marked with `API: semi-private` are used internally for consistency. While it is
112
- possible to monkey-patch against them for your own use, the maintainers make no gaurantees
112
+ possible to monkey-patch against them for your own use, the maintainers make no guarantees
113
113
  on backwards compatibility.
114
114
 
115
115
  ## Learn More
data/lib/plaid.rb CHANGED
@@ -7,7 +7,6 @@ require 'plaid/models/institution'
7
7
  require 'plaid/models/category'
8
8
  require 'plaid/models/exchange_token_response'
9
9
 
10
-
11
10
  require 'json'
12
11
 
13
12
  module Plaid
@@ -51,7 +50,7 @@ module Plaid
51
50
  _user.access_token = fully_qualified_token(token, institution_type)
52
51
  _user.permissions = api_levels
53
52
  api_levels.each { |l| _user.get(l) }
54
- return _user
53
+ _user
55
54
  end
56
55
 
57
56
  # API: public
@@ -71,7 +70,7 @@ module Plaid
71
70
  options = JSON.generate(options) if options.kind_of?(Hash)
72
71
 
73
72
  _user.get_connect(options: options)
74
- return _user
73
+ _user
75
74
  end
76
75
 
77
76
  # API: public
@@ -9,25 +9,32 @@ module Plaid
9
9
  def post(path, options = {})
10
10
  uri = build_uri(path)
11
11
  options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
12
- res = Net::HTTP.post_form(uri,options)
12
+ http = Net::HTTP.new(uri.host, uri.port)
13
+ http.use_ssl = true
14
+ request = Net::HTTP::Post.new(uri.path)
15
+ request.set_form_data(options)
16
+ res = http.request(request)
13
17
  parse_response(res)
14
18
  end
15
19
 
16
20
  # API: semi-private
17
21
  def get(path, id = nil)
18
22
  uri = build_uri(path,id)
19
- res = Net::HTTP.get(uri)
20
- parse_get_response(res)
23
+ http = Net::HTTP.new(uri.host, uri.port)
24
+ http.use_ssl = true
25
+ request = Net::HTTP::Get.new(uri.path)
26
+ res = http.request(request)
27
+ parse_get_response(res.body)
21
28
  end
22
29
 
23
30
  # API: semi-private
24
31
  def secure_get(path, access_token, options = {})
25
32
  uri = build_uri(path)
26
33
  options.merge!({access_token:access_token})
27
- req = Net::HTTP::Get.new(uri)
34
+ req = Net::HTTP::Get.new(uri.path)
28
35
  req.body = URI.encode_www_form(options) if options
29
36
  req.content_type = 'application/x-www-form-urlencoded'
30
- res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
37
+ res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
31
38
  parse_response(res)
32
39
  end
33
40
 
@@ -35,10 +42,10 @@ module Plaid
35
42
  def patch(path, options = {})
36
43
  uri = build_uri(path)
37
44
  options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
38
- req = Net::HTTP::Patch.new(uri)
45
+ req = Net::HTTP::Patch.new(uri.path)
39
46
  req.body = URI.encode_www_form(options) if options
40
47
  req.content_type = 'application/x-www-form-urlencoded'
41
- res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
48
+ res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
42
49
  parse_response(res)
43
50
  end
44
51
 
@@ -46,10 +53,10 @@ module Plaid
46
53
  def delete(path, options = {})
47
54
  uri = build_uri(path)
48
55
  options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
49
- req = Net::HTTP::Delete.new(uri)
56
+ req = Net::HTTP::Delete.new(uri.path)
50
57
  req.body = URI.encode_www_form(options) if options
51
58
  req.content_type = 'application/x-www-form-urlencoded'
52
- Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
59
+ Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
53
60
  end
54
61
 
55
62
  protected
@@ -1,9 +1,10 @@
1
1
  module Plaid
2
2
  class Institution
3
- attr_accessor :id, :name, :type, :has_mfa, :mfa
3
+ attr_accessor :id, :credentials, :name, :type, :has_mfa, :mfa
4
4
 
5
5
  def initialize(fields = {})
6
6
  @id = fields['id']
7
+ @credentials = fields['credentials']
7
8
  @name = fields['name']
8
9
  @type = fields['type']
9
10
  @has_mfa = fields['has_mfa']
@@ -10,7 +10,7 @@ module Plaid
10
10
  @name = fields['name']
11
11
  @location = fields['meta'].nil? ? {} : fields['meta']['location']
12
12
  @pending = fields['pending']
13
- @pendingTransaction = fields['_pendingTransaction']
13
+ @pending_transaction = fields['_pendingTransaction']
14
14
  @score = fields['score']
15
15
  @cat = Category.new({ 'id' => fields['category_id'], 'hierarchy' => fields['category'], 'type' => fields['type'] })
16
16
 
@@ -83,7 +83,7 @@ module Plaid
83
83
  set_mfa_request!(res)
84
84
  end
85
85
 
86
- return self
86
+ self
87
87
  end
88
88
 
89
89
  # Internal helper methods
data/lib/plaid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plaid
2
- VERSION = '1.5.3'
2
+ VERSION = '1.6.0'
3
3
  end
data/plaid.gemspec CHANGED
@@ -11,7 +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.0'
14
+ spec.required_ruby_version = '>= 1.9.3'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
data/spec/account_spec.rb CHANGED
@@ -1,6 +1,4 @@
1
- require 'spec_helper.rb'
2
-
3
- RSpec.describe Plaid::Account do
1
+ describe Plaid::Account do
4
2
  # API: semi-private
5
3
  describe '.new' do
6
4
  subject { Plaid::Account.new(results) }
@@ -1,6 +1,4 @@
1
- require 'spec_helper.rb'
2
-
3
- RSpec.describe Plaid::Category do
1
+ describe Plaid::Category do
4
2
  context 'when a single category is found' do
5
3
  let(:category) { Plaid.category('17001013') }
6
4
  it { expect(category).to be_kind_of(Plaid::Category) }
data/spec/config_spec.rb CHANGED
@@ -1,6 +1,4 @@
1
- require 'spec_helper.rb'
2
-
3
- RSpec.describe 'Plaid.config' do
1
+ describe 'Plaid.config' do
4
2
  around(:each) do |example|
5
3
  old_customer_id = Plaid.customer_id
6
4
  old_secret = Plaid.secret
@@ -27,19 +25,19 @@ RSpec.describe 'Plaid.config' do
27
25
  let(:prod_url) { 'https://api.plaid.com/' }
28
26
 
29
27
 
30
- let(:user) { Plaid.add_user('connect','plaid_test','plaid_good','wells') }
28
+ let(:user) { Plaid.add_user('connect', 'plaid_test', 'plaid_good', 'wells') }
31
29
 
32
30
  context ':environment_location' do
33
31
  context 'with trailing slash' do
34
32
  let(:environment_location) { 'http://example.org/' }
35
- it 'should leave it as-is' do
33
+ it 'leaves it as-is' do
36
34
  expect(Plaid.environment_location).to eql(environment_location)
37
35
  end
38
36
  end
39
37
 
40
38
  context 'without trailing slash' do
41
39
  let(:environment_location) { 'http://example.org' }
42
- it 'should add a trailing slash' do
40
+ it 'adds a trailing slash' do
43
41
  expect(Plaid.environment_location).to eql(environment_location + '/')
44
42
  end
45
43
  end
@@ -1,7 +1,4 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Plaid::Connection do
4
-
1
+ describe Plaid::Connection do
5
2
  let(:stub_url) { "https://tartan.plaid.com/testing" }
6
3
  let(:bad_req_response) { {"code" => 1005, "message" => "invalid credentials", "resolve" => "The username or password provided is not correct."}.to_json }
7
4
  let(:unauth_response) { {"code" => 1105, "message" => "bad access_token", "resolve" => "This access_token appears to be corrupted."}.to_json }
@@ -9,80 +6,80 @@ RSpec.describe Plaid::Connection do
9
6
  let(:req_not_found) { {"code" => 1600, "message" => "product not found", "resolve" => "This product doesn't exist yet, we're actually not sure how you reached this error..."}.to_json }
10
7
 
11
8
  describe "#post" do
12
- it "should send a post request" do
9
+ it "sends a post request" do
13
10
  stub = stub_request(:post, stub_url).to_return({:body => {"response" => "OK"}.to_json})
14
11
  Plaid::Connection.post("testing")
15
12
  expect(stub).to have_requested(:post, stub_url)
16
13
  end
17
14
 
18
- it "should return response on 200 response" do
15
+ it "returns response on 200 response" do
19
16
  stub = stub_request(:post, stub_url).to_return({:body => {"response" => "OK"}.to_json})
20
17
  response = Plaid::Connection.post("testing")
21
18
  expect(response).to eq({"response" => "OK"})
22
19
  end
23
20
 
24
- it "should return message on 201 response" do
21
+ it "returns message on 201 response" do
25
22
  stub = stub_request(:post, stub_url).to_return(status: 201, body: {"response" => "OK"}.to_json)
26
23
  response = Plaid::Connection.post("testing")
27
24
  expect(response).to eq({:msg => "Requires further authentication", :body => {"response" => "OK"}})
28
25
  end
29
26
 
30
- it "should throw Plaid::BadRequest on 400 response" do
27
+ it "throws Plaid::BadRequest on 400 response" do
31
28
  stub = stub_request(:post, stub_url).to_return(status: 400, body: bad_req_response)
32
29
  expect { Plaid::Connection.post("testing") }.to raise_error(Plaid::BadRequest, "invalid credentials")
33
30
  end
34
31
 
35
- it "should throw Plaid::Unauthorized on 401 response" do
32
+ it "throws Plaid::Unauthorized on 401 response" do
36
33
  stub = stub_request(:post, stub_url).to_return(status: 401, body: unauth_response)
37
34
  expect { Plaid::Connection.post("testing") }.to raise_error(Plaid::Unauthorized, "bad access_token")
38
35
  end
39
36
 
40
- it "should throw Plaid::RequestFailed on 402 response" do
37
+ it "throws Plaid::RequestFailed on 402 response" do
41
38
  stub = stub_request(:post, stub_url).to_return(status: 402, body: req_fail_response)
42
39
  expect { Plaid::Connection.post("testing") }.to raise_error(Plaid::RequestFailed, "invalid credentials")
43
40
  end
44
41
 
45
- it "should throw a Plaid::NotFound on 404 response" do
42
+ it "throws a Plaid::NotFound on 404 response" do
46
43
  stub = stub_request(:post, stub_url).to_return(status: 404, body: req_not_found)
47
44
  expect { Plaid::Connection.post("testing") }.to raise_error(Plaid::NotFound, "product not found")
48
45
  end
49
46
  end
50
47
 
51
48
  describe "#get" do
52
- it "should send a get request" do
49
+ it "sends a get request" do
53
50
  stub = stub_request(:get, stub_url).to_return({:body => {"response" => "OK"}.to_json})
54
51
  Plaid::Connection.get("testing")
55
52
  expect(stub).to have_requested(:get, stub_url)
56
53
  end
57
-
58
- it "should return response when no code available" do
54
+
55
+ it "returns response when no code available" do
59
56
  stub = stub_request(:get, stub_url).to_return({:body => {"response" => "OK"}.to_json})
60
57
  response = Plaid::Connection.get("testing")
61
58
  expect(response).to eq({"response" => "OK"})
62
59
  end
63
-
64
- it "should return response when code not [1301, 1401, 1501, 1601]" do
60
+
61
+ it "returns response when code not [1301, 1401, 1501, 1601]" do
65
62
  stub = stub_request(:get, stub_url).to_return({:body => {"code" => 1502, "response" => "OK"}.to_json})
66
63
  response = Plaid::Connection.get("testing")
67
64
  expect(response).to eq({"code" => 1502, "response" => "OK"})
68
65
  end
69
66
 
70
- it "should throw 404 for 1301 code" do
67
+ it "throws 404 for 1301 code" do
71
68
  stub = stub_request(:get, stub_url).to_return({:body => {"code" => 1301, "message" => "Doesn't matter", "resolve" => "Yep."}.to_json})
72
69
  expect { Plaid::Connection.get("testing")}.to raise_error(Plaid::NotFound, "Doesn't matter")
73
70
  end
74
-
75
- it "should throw 404 for 1401 code" do
71
+
72
+ it "throws 404 for 1401 code" do
76
73
  stub = stub_request(:get, stub_url).to_return({:body => {"code" => 1401, "message" => "Doesn't matter", "resolve" => "Yep."}.to_json})
77
74
  expect { Plaid::Connection.get("testing")}.to raise_error(Plaid::NotFound, "Doesn't matter")
78
75
  end
79
-
80
- it "should throw 404 for 1501 code" do
76
+
77
+ it "throws 404 for 1501 code" do
81
78
  stub = stub_request(:get, stub_url).to_return({:body => {"code" => 1501, "message" => "Doesn't matter", "resolve" => "Yep."}.to_json})
82
79
  expect { Plaid::Connection.get("testing")}.to raise_error(Plaid::NotFound, "Doesn't matter")
83
80
  end
84
-
85
- it "should throw 404 for 1601 code" do
81
+
82
+ it "throws 404 for 1601 code" do
86
83
  stub = stub_request(:get, stub_url).to_return({:body => {"code" => 1601, "message" => "Doesn't matter", "resolve" => "Yep."}.to_json})
87
84
  expect { Plaid::Connection.get("testing")}.to raise_error(Plaid::NotFound, "Doesn't matter")
88
85
  end
@@ -90,91 +87,90 @@ RSpec.describe Plaid::Connection do
90
87
  end
91
88
 
92
89
  describe "#secure_get" do
93
- it "should send a secure get request" do
90
+ it "sends a secure get request" do
94
91
  stub = stub_request(:get, stub_url).to_return({:body => {"response" => "OK"}.to_json})
95
92
  Plaid::Connection.secure_get("testing", "test_wells")
96
- expect(stub).to have_requested(:get, stub_url).with(:body => {:access_token => "test_wells"})
93
+ expect(stub).to have_requested(:get, stub_url).with(:body => {:access_token => "test_wells"})
97
94
  end
98
95
 
99
- it "should return response on 200 response" do
96
+ it "returns response on 200 response" do
100
97
  stub = stub_request(:get, stub_url).to_return({:body => {"response" => "OK"}.to_json})
101
98
  response = Plaid::Connection.secure_get("testing", "test_wells")
102
99
  expect(response).to eq({"response" => "OK"})
103
100
  end
104
101
 
105
- it "should return message on 201 response" do
102
+ it "returns message on 201 response" do
106
103
  stub = stub_request(:get, stub_url).to_return(status: 201, body: {"response" => "OK"}.to_json)
107
104
  response = Plaid::Connection.secure_get("testing", "test_wells")
108
105
  expect(response).to eq({:msg => "Requires further authentication", :body => {"response" => "OK"}})
109
106
  end
110
107
 
111
- it "should throw Plaid::BadRequest on 400 response" do
108
+ it "throws Plaid::BadRequest on 400 response" do
112
109
  stub = stub_request(:get, stub_url).to_return(status: 400, body: bad_req_response)
113
110
  expect { Plaid::Connection.secure_get("testing", "test_wells") }.to raise_error(Plaid::BadRequest, "invalid credentials")
114
111
  end
115
112
 
116
- it "should throw Plaid::Unauthorized on 401 response" do
113
+ it "throws Plaid::Unauthorized on 401 response" do
117
114
  stub = stub_request(:get, stub_url).to_return(status: 401, body: unauth_response)
118
115
  expect { Plaid::Connection.secure_get("testing", "test_wells") }.to raise_error(Plaid::Unauthorized, "bad access_token")
119
116
  end
120
117
 
121
- it "should throw Plaid::RequestFailed on 402 response" do
118
+ it "throws Plaid::RequestFailed on 402 response" do
122
119
  stub = stub_request(:get, stub_url).to_return(status: 402, body: req_fail_response)
123
120
  expect { Plaid::Connection.secure_get("testing", "test_wells") }.to raise_error(Plaid::RequestFailed, "invalid credentials")
124
121
  end
125
122
 
126
- it "should throw a Plaid::NotFound on 404 response" do
123
+ it "throws a Plaid::NotFound on 404 response" do
127
124
  stub = stub_request(:get, stub_url).to_return(status: 404, body: req_not_found)
128
125
  expect { Plaid::Connection.secure_get("testing", "test_wells") }.to raise_error(Plaid::NotFound, "product not found")
129
126
  end
130
127
  end
131
128
 
132
129
  describe "#patch" do
133
- it "should send a patch request" do
130
+ it "sends a patch request" do
134
131
  stub = stub_request(:patch, stub_url).to_return({:body => {"response" => "OK"}.to_json})
135
132
  Plaid::Connection.patch("testing")
136
133
  expect(stub).to have_requested(:patch, stub_url)
137
134
  end
138
-
139
- it "should return response on 200 response" do
135
+
136
+ it "returns response on 200 response" do
140
137
  stub = stub_request(:patch, stub_url).to_return({:body => {"response" => "OK"}.to_json})
141
138
  response = Plaid::Connection.patch("testing")
142
139
  expect(response).to eq({"response" => "OK"})
143
140
  end
144
141
 
145
- it "should return message on 201 response" do
142
+ it "returns message on 201 response" do
146
143
  stub = stub_request(:patch, stub_url).to_return(status: 201, body: {"response" => "OK"}.to_json)
147
144
  response = Plaid::Connection.patch("testing")
148
145
  expect(response).to eq({:msg => "Requires further authentication", :body => {"response" => "OK"}})
149
146
  end
150
147
 
151
- it "should throw Plaid::BadRequest on 400 response" do
148
+ it "throws Plaid::BadRequest on 400 response" do
152
149
  stub = stub_request(:patch, stub_url).to_return(status: 400, body: bad_req_response)
153
150
  expect { Plaid::Connection.patch("testing") }.to raise_error(Plaid::BadRequest, "invalid credentials")
154
151
  end
155
152
 
156
- it "should throw Plaid::Unauthorized on 401 response" do
153
+ it "throws Plaid::Unauthorized on 401 response" do
157
154
  stub = stub_request(:patch, stub_url).to_return(status: 401, body: unauth_response)
158
155
  expect { Plaid::Connection.patch("testing") }.to raise_error(Plaid::Unauthorized, "bad access_token")
159
156
  end
160
157
 
161
- it "should throw Plaid::RequestFailed on 402 response" do
158
+ it "throws Plaid::RequestFailed on 402 response" do
162
159
  stub = stub_request(:patch, stub_url).to_return(status: 402, body: req_fail_response)
163
160
  expect { Plaid::Connection.patch("testing") }.to raise_error(Plaid::RequestFailed, "invalid credentials")
164
161
  end
165
162
 
166
- it "should throw a Plaid::NotFound on 404 response" do
163
+ it "throws a Plaid::NotFound on 404 response" do
167
164
  stub = stub_request(:patch, stub_url).to_return(status: 404, body: req_not_found)
168
165
  expect { Plaid::Connection.patch("testing") }.to raise_error(Plaid::NotFound, "product not found")
169
166
  end
170
167
  end
171
168
 
172
169
  describe "#delete" do
173
- it "should send a delete request" do
170
+ it "sends a delete request" do
174
171
  stub = stub_request(:delete, stub_url)
175
172
  Plaid::Connection.delete("testing")
176
173
  expect(stub).to have_requested(:delete, stub_url)
177
174
  end
178
175
  end
179
-
180
176
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper.rb'
2
-
3
- RSpec.describe Plaid::Institution do
1
+ describe Plaid::Institution do
4
2
  context 'when a single institution is found' do
5
3
  let(:institution) { Plaid.institution('5301a93ac140de84910000e0') }
6
4
  it { expect(institution).to be_kind_of(Plaid::Institution) }
@@ -1,8 +1,6 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Plaid::PlaidError do
1
+ describe Plaid::PlaidError do
4
2
  describe "#new" do
5
- it "should allow code, message and resolution" do
3
+ it "allows code, message and resolution" do
6
4
  error = Plaid::PlaidError.new 1, "testing", "fix it"
7
5
  expect(error.code).to eq(1)
8
6
  expect(error.message).to eq("testing")
data/spec/plaid_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
- require 'spec_helper.rb'
2
1
  # Authentication flow specs - returns Plaid::User
3
- RSpec.describe Plaid do
2
+
3
+ describe Plaid do
4
4
  let(:api_level) { raise "Define let(:api_level)" }
5
5
  let(:username) { raise "Define let(:username)" }
6
6
  let(:password) { raise "Define let(:password)" }
@@ -34,7 +34,7 @@ RSpec.describe Plaid do
34
34
  expect(error.code).to eq(1205)
35
35
  }
36
36
  end
37
-
37
+
38
38
  end
39
39
 
40
40
  context 'with connection options' do
@@ -195,7 +195,7 @@ RSpec.describe Plaid do
195
195
  end
196
196
 
197
197
  context 'gets a fully validated user with all access granted' do
198
- let(:user) { Plaid.set_user('test_wells',['connect','info','auth']) }
198
+ let(:user) { Plaid.set_user('test_wells', ['connect', 'info', 'auth']) }
199
199
  it { expect(user.transactions).to be_truthy}
200
200
  end
201
201
  end
@@ -213,24 +213,24 @@ RSpec.describe Plaid do
213
213
  let(:options) { nil }
214
214
 
215
215
  context 'without options' do
216
- it 'should return all accounts' do
216
+ it 'returns all accounts' do
217
217
  expect(subject.accounts).not_to be_empty
218
218
  end
219
219
 
220
- it 'should return all transactions' do
220
+ it 'returns all transactions' do
221
221
  expect(subject.transactions).not_to be_empty
222
222
  end
223
223
  end
224
224
 
225
- context 'when filering by account' do
225
+ context 'when filtering by account' do
226
226
  let(:options) { { account: account } }
227
227
  let(:account) { 'QPO8Jo8vdDHMepg41PBwckXm4KdK1yUdmXOwK' }
228
228
 
229
- it 'should return a subset of transactions' do
229
+ it 'returns a subset of transactions' do
230
230
  expect(subject.transactions.size).to eql(2)
231
231
  end
232
232
 
233
- it 'should only return transactions from the requested account' do
233
+ it 'return only transactions from the requested account' do
234
234
  expect(subject.transactions.map(&:account).uniq).to eql([account])
235
235
  end
236
236
  end
@@ -238,11 +238,11 @@ RSpec.describe Plaid do
238
238
  context 'when filtering by date' do
239
239
  let(:options) { { gte: "2014-07-24", lte: "2014-07-25" } }
240
240
 
241
- it 'should return a subset of transactions' do
241
+ it 'returns a subset of transactions' do
242
242
  expect(subject.transactions.size).to eql(1)
243
243
  end
244
244
 
245
- it 'should only return transactions from the requested date range' do
245
+ it 'return only transactions from the requested date range' do
246
246
  expect(subject.transactions.map(&:date).uniq).to eql(['2014-07-24'])
247
247
  end
248
248
  end
@@ -251,11 +251,11 @@ RSpec.describe Plaid do
251
251
  let(:options) { { account: account , gte: "2014-07-24", lte: "2014-07-25" } }
252
252
  let(:account) { 'XARE85EJqKsjxLp6XR8ocg8VakrkXpTXmRdOo' }
253
253
 
254
- it 'should return a subset of transactions' do
254
+ it 'returns a subset of transactions' do
255
255
  expect(subject.transactions.size).to eql(1)
256
256
  end
257
257
 
258
- it 'should only return transactions from the requested account and date range' do
258
+ it 'returns only transactions from the requested account and date range' do
259
259
  expect(subject.transactions.map(&:date).uniq).to eql(['2014-07-24'])
260
260
  expect(subject.transactions.map(&:account).uniq).to eql([account])
261
261
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper.rb'
2
-
3
- RSpec.describe Plaid::Transaction do
1
+ describe Plaid::Transaction do
4
2
  # API: semi-private
5
3
  describe '.new' do
6
4
  # The reason this looks weird is because it is. This will be refactored for 2.0
data/spec/user_spec.rb CHANGED
@@ -1,26 +1,23 @@
1
- require 'spec_helper.rb'
2
-
3
- RSpec.describe Plaid::User do
4
- let(:auth_user) { Plaid.add_user('auth', 'plaid_test', 'plaid_good', 'wells') }
5
- let(:connect_user) { Plaid.add_user('connect','plaid_test', 'plaid_good', 'wells') }
6
- let(:info_user) { Plaid.add_user('info', 'plaid_test', 'plaid_good', 'wells') }
1
+ describe Plaid::User do
2
+ let(:auth_user) { Plaid.add_user('auth', 'plaid_test', 'plaid_good', 'wells') }
3
+ let(:connect_user) { Plaid.add_user('connect', 'plaid_test', 'plaid_good', 'wells') }
4
+ let(:info_user) { Plaid.add_user('info', 'plaid_test', 'plaid_good', 'wells') }
7
5
 
8
6
  context 'user vars' do
9
-
10
7
  context 'valid user has accounts and accounts contain id attribute' do
11
- let(:user) { Plaid.add_user('connect','plaid_test','plaid_good','wells') }
8
+ let(:user) { Plaid.add_user('connect', 'plaid_test', 'plaid_good', 'wells') }
12
9
  it { expect(user.accounts.first.id).not_to be_nil }
13
10
  end
14
11
 
15
12
  context 'valid user has accounts and accounts contain type attribute' do
16
- let(:user) { Plaid.add_user('connect','plaid_test','plaid_good','wells') }
13
+ let(:user) { Plaid.add_user('connect', 'plaid_test', 'plaid_good', 'wells') }
17
14
  it { expect(user.accounts.first.type).to eq('depository') }
18
15
  end
19
16
  end
20
17
 
21
18
  # MFA specs - after user is instantiated,
22
19
  describe '#mfa_authentication' do
23
- let(:user) { Plaid.add_user('connect','plaid_test', 'plaid_good','bofa') }
20
+ let(:user) { Plaid.add_user('connect', 'plaid_test', 'plaid_good', 'bofa') }
24
21
  let(:new_mfa_user) { user.mfa_authentication('tomato') }
25
22
 
26
23
  context 'enters correct credentials for MFA auth and authenticates' do
@@ -39,7 +36,7 @@ RSpec.describe Plaid::User do
39
36
 
40
37
  context 'enters incorrect credentials for MFA auth' do
41
38
  let(:mfa_user) { user.mfa_authentication('tomato') }
42
- let(:mfa_bad) { mfa_user; Plaid.add_user('connect','plaid_test', 'plaid_good','bofa') }
39
+ let(:mfa_bad) { mfa_user; Plaid.add_user('connect', 'plaid_test', 'plaid_good', 'bofa') }
43
40
  it { expect { mfa_bad.mfa_authentication('bad') }.to raise_error }
44
41
  end
45
42
 
@@ -59,7 +56,7 @@ RSpec.describe Plaid::User do
59
56
  end
60
57
 
61
58
  context 'selects MFA method and returns successful response' do
62
- let(:user) { Plaid.add_user('auth','plaid_test','plaid_good','chase',nil,'{"list":true}') }
59
+ let(:user) { Plaid.add_user('auth', 'plaid_test', 'plaid_good', 'chase', nil, '{"list":true}') }
63
60
  let(:new_mfa_user) { user.select_mfa_method({mask: 'xxx-xxx-5309' }, 'chase') }
64
61
  let(:expected_pending_questions) do
65
62
  {
@@ -72,7 +69,7 @@ RSpec.describe Plaid::User do
72
69
  end
73
70
 
74
71
  context 'selects MFA method, and delivers correct payload to authenticate user' do
75
- let(:user) { Plaid.add_user('auth','plaid_test','plaid_good','chase',nil,'{"list":true}') }
72
+ let(:user) { Plaid.add_user('auth', 'plaid_test', 'plaid_good', 'chase', nil, '{"list":true}') }
76
73
  let(:user_select_method) { user.select_mfa_method({mask:'xxx-xxx-5309'}) }
77
74
  let(:new_mfa_user) { user_select_method.mfa_authentication(1234) }
78
75
 
@@ -118,14 +115,14 @@ RSpec.describe Plaid::User do
118
115
 
119
116
  describe '#get_balance' do
120
117
  subject { user.tap(&:update_balance) }
121
- let(:user) { Plaid.add_user('info','plaid_test','plaid_good','wells') }
118
+ let(:user) { Plaid.add_user('info', 'plaid_test', 'plaid_good', 'wells') }
122
119
 
123
120
  context 'updates user accounts' do
124
121
  it { expect(subject.accounts).not_to be_empty }
125
122
  end
126
123
 
127
124
  # TODO: This test needs to be rewritten better, such as using #uniq instead of this
128
- context 'should not double up accounts or transactions' do
125
+ context 'does not double up accounts or transactions' do
129
126
  let(:total_duplicates) { duplicate_accounts.length + duplicate_transactions.length }
130
127
  let(:duplicate_accounts) { subject.accounts.select {|element| user.accounts.count(element) > 1} }
131
128
  let(:duplicate_transactions) { subject.transactions.select {|element| user.transactions.count(element) > 1} }
@@ -137,7 +134,7 @@ RSpec.describe Plaid::User do
137
134
  let(:info_user) { Plaid.add_user('info', 'plaid_test', 'plaid_good', 'wells') }
138
135
  context 'updates information correctly' do
139
136
  # TODO: This test needs to pass, currently test credentials are failing
140
- pending { expect { info_user.update_info('plaid_test','plaid_good') }.to_not raise_error }
137
+ pending { expect { info_user.update_info('plaid_test', 'plaid_good') }.to_not raise_error }
141
138
  end
142
139
  end
143
140
 
@@ -168,7 +165,7 @@ RSpec.describe Plaid::User do
168
165
  end
169
166
  end
170
167
 
171
- # This stuff needs to be tested and rewritten. Have alredy
168
+ # This stuff needs to be tested and rewritten. Have already
172
169
  # surfaced up a bug in it
173
170
  pending "#populate_user"
174
171
 
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plaid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.6.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-07-13 00:00:00.000000000 Z
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.7'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry-stack_explorer
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  description: Ruby gem wrapper for the Plaid API. Read more at the homepage, the wiki,
@@ -102,8 +102,9 @@ executables: []
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
- - .gitignore
106
- - .travis.yml
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
107
108
  - Gemfile
108
109
  - LICENSE.txt
109
110
  - README.md
@@ -141,17 +142,17 @@ require_paths:
141
142
  - lib
142
143
  required_ruby_version: !ruby/object:Gem::Requirement
143
144
  requirements:
144
- - - ! '>='
145
+ - - ">="
145
146
  - !ruby/object:Gem::Version
146
- version: '2.0'
147
+ version: 1.9.3
147
148
  required_rubygems_version: !ruby/object:Gem::Requirement
148
149
  requirements:
149
- - - ! '>='
150
+ - - ">="
150
151
  - !ruby/object:Gem::Version
151
152
  version: '0'
152
153
  requirements: []
153
154
  rubyforge_project:
154
- rubygems_version: 2.4.8
155
+ rubygems_version: 2.4.7
155
156
  signing_key:
156
157
  specification_version: 4
157
158
  summary: Ruby bindings for Plaid