plaid 1.7.1 → 2.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTING.md +15 -0
- data/LICENSE +20 -0
- data/README.md +215 -63
- data/Rakefile +50 -4
- data/UPGRADING.md +45 -0
- data/bin/console +13 -0
- data/bin/setup +8 -0
- data/lib/plaid.rb +51 -88
- data/lib/plaid/account.rb +144 -0
- data/lib/plaid/category.rb +62 -0
- data/lib/plaid/client.rb +67 -0
- data/lib/plaid/connector.rb +168 -0
- data/lib/plaid/errors.rb +24 -14
- data/lib/plaid/income.rb +106 -0
- data/lib/plaid/info.rb +65 -0
- data/lib/plaid/institution.rb +240 -0
- data/lib/plaid/risk.rb +34 -0
- data/lib/plaid/transaction.rb +123 -0
- data/lib/plaid/user.rb +430 -0
- data/lib/plaid/version.rb +1 -1
- data/plaid.gemspec +20 -12
- metadata +58 -62
- data/.gitignore +0 -15
- data/.rspec +0 -2
- data/.travis.yml +0 -5
- data/LICENSE.txt +0 -22
- data/PUBLISHING.md +0 -21
- data/lib/plaid/config.rb +0 -19
- data/lib/plaid/connection.rb +0 -109
- data/lib/plaid/models/account.rb +0 -24
- data/lib/plaid/models/category.rb +0 -17
- data/lib/plaid/models/exchange_token_response.rb +0 -11
- data/lib/plaid/models/info.rb +0 -12
- data/lib/plaid/models/institution.rb +0 -22
- data/lib/plaid/models/transaction.rb +0 -24
- data/lib/plaid/models/user.rb +0 -189
- data/spec/plaid/config_spec.rb +0 -67
- data/spec/plaid/connection_spec.rb +0 -191
- data/spec/plaid/error_spec.rb +0 -10
- data/spec/plaid/models/account_spec.rb +0 -37
- data/spec/plaid/models/category_spec.rb +0 -16
- data/spec/plaid/models/institution_spec.rb +0 -19
- data/spec/plaid/models/transaction_spec.rb +0 -28
- data/spec/plaid/models/user_spec.rb +0 -172
- data/spec/plaid_spec.rb +0 -263
- data/spec/spec_helper.rb +0 -14
data/lib/plaid/version.rb
CHANGED
data/plaid.gemspec
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
lib = File.expand_path('../lib', __FILE__)
|
2
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
4
|
require 'plaid/version'
|
@@ -5,24 +6,31 @@ require 'plaid/version'
|
|
5
6
|
Gem::Specification.new do |spec|
|
6
7
|
spec.name = 'plaid'
|
7
8
|
spec.version = Plaid::VERSION
|
8
|
-
spec.authors = ['
|
9
|
-
spec.email = ['
|
9
|
+
spec.authors = ['Oleg Dashevskii']
|
10
|
+
spec.email = ['olegdashevskii@gmail.com']
|
11
|
+
|
10
12
|
spec.summary = 'Ruby bindings for Plaid'
|
11
|
-
spec.description = 'Ruby gem wrapper for the Plaid API. Read more at the
|
13
|
+
spec.description = 'Ruby gem wrapper for the Plaid API. Read more at the ' \
|
14
|
+
'homepage, the wiki, or in the Plaid documentation.'
|
12
15
|
spec.homepage = 'https://github.com/plaid/plaid-ruby'
|
13
16
|
spec.license = 'MIT'
|
14
|
-
spec.required_ruby_version = '>= 1.9.3'
|
15
17
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
|
18
|
-
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test/|\.gitignore|\.travis)})
|
20
|
+
end
|
21
|
+
|
22
|
+
spec.bindir = 'exe'
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
24
|
spec.require_paths = ['lib']
|
20
25
|
|
26
|
+
spec.required_ruby_version = '>= 2.0.0'
|
27
|
+
|
28
|
+
spec.add_dependency 'multi_json', '~> 1.11.3'
|
29
|
+
|
21
30
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
31
|
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
-
spec.add_development_dependency '
|
24
|
-
spec.add_development_dependency 'pry'
|
25
|
-
spec.add_development_dependency '
|
26
|
-
spec.add_development_dependency '
|
32
|
+
spec.add_development_dependency 'sdoc', '~> 0.4.1'
|
33
|
+
spec.add_development_dependency 'pry', '~> 0.10.3'
|
34
|
+
spec.add_development_dependency 'webmock', '~> 2.0.0'
|
35
|
+
spec.add_development_dependency 'minitest', '~> 5.8'
|
27
36
|
end
|
28
|
-
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plaid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Oleg Dashevskii
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: multi_json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.11.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.11.3
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,100 +53,92 @@ dependencies:
|
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '10.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: sdoc
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: 0.4.1
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: 0.4.1
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: pry
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - "
|
73
|
+
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: 0.10.3
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - "
|
80
|
+
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: 0.10.3
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: webmock
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - "
|
87
|
+
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
89
|
+
version: 2.0.0
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - "
|
94
|
+
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
96
|
+
version: 2.0.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: minitest
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - "
|
101
|
+
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
103
|
+
version: '5.8'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - "
|
108
|
+
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
110
|
+
version: '5.8'
|
97
111
|
description: Ruby gem wrapper for the Plaid API. Read more at the homepage, the wiki,
|
98
|
-
or the
|
112
|
+
or in the Plaid documentation.
|
99
113
|
email:
|
100
|
-
-
|
114
|
+
- olegdashevskii@gmail.com
|
101
115
|
executables: []
|
102
116
|
extensions: []
|
103
117
|
extra_rdoc_files: []
|
104
118
|
files:
|
105
|
-
-
|
106
|
-
-
|
107
|
-
- ".travis.yml"
|
119
|
+
- CHANGELOG.md
|
120
|
+
- CONTRIBUTING.md
|
108
121
|
- Gemfile
|
109
|
-
- LICENSE
|
110
|
-
- PUBLISHING.md
|
122
|
+
- LICENSE
|
111
123
|
- README.md
|
112
124
|
- Rakefile
|
125
|
+
- UPGRADING.md
|
126
|
+
- bin/console
|
127
|
+
- bin/setup
|
113
128
|
- lib/plaid.rb
|
114
|
-
- lib/plaid/
|
115
|
-
- lib/plaid/
|
129
|
+
- lib/plaid/account.rb
|
130
|
+
- lib/plaid/category.rb
|
131
|
+
- lib/plaid/client.rb
|
132
|
+
- lib/plaid/connector.rb
|
116
133
|
- lib/plaid/errors.rb
|
117
|
-
- lib/plaid/
|
118
|
-
- lib/plaid/
|
119
|
-
- lib/plaid/
|
120
|
-
- lib/plaid/
|
121
|
-
- lib/plaid/
|
122
|
-
- lib/plaid/
|
123
|
-
- lib/plaid/models/user.rb
|
134
|
+
- lib/plaid/income.rb
|
135
|
+
- lib/plaid/info.rb
|
136
|
+
- lib/plaid/institution.rb
|
137
|
+
- lib/plaid/risk.rb
|
138
|
+
- lib/plaid/transaction.rb
|
139
|
+
- lib/plaid/user.rb
|
124
140
|
- lib/plaid/version.rb
|
125
141
|
- plaid.gemspec
|
126
|
-
- spec/plaid/config_spec.rb
|
127
|
-
- spec/plaid/connection_spec.rb
|
128
|
-
- spec/plaid/error_spec.rb
|
129
|
-
- spec/plaid/models/account_spec.rb
|
130
|
-
- spec/plaid/models/category_spec.rb
|
131
|
-
- spec/plaid/models/institution_spec.rb
|
132
|
-
- spec/plaid/models/transaction_spec.rb
|
133
|
-
- spec/plaid/models/user_spec.rb
|
134
|
-
- spec/plaid_spec.rb
|
135
|
-
- spec/spec_helper.rb
|
136
142
|
homepage: https://github.com/plaid/plaid-ruby
|
137
143
|
licenses:
|
138
144
|
- MIT
|
@@ -145,26 +151,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
151
|
requirements:
|
146
152
|
- - ">="
|
147
153
|
- !ruby/object:Gem::Version
|
148
|
-
version:
|
154
|
+
version: 2.0.0
|
149
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
156
|
requirements:
|
151
|
-
- - "
|
157
|
+
- - ">"
|
152
158
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
159
|
+
version: 1.3.1
|
154
160
|
requirements: []
|
155
161
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.5.1
|
157
163
|
signing_key:
|
158
164
|
specification_version: 4
|
159
165
|
summary: Ruby bindings for Plaid
|
160
|
-
test_files:
|
161
|
-
- spec/plaid/config_spec.rb
|
162
|
-
- spec/plaid/connection_spec.rb
|
163
|
-
- spec/plaid/error_spec.rb
|
164
|
-
- spec/plaid/models/account_spec.rb
|
165
|
-
- spec/plaid/models/category_spec.rb
|
166
|
-
- spec/plaid/models/institution_spec.rb
|
167
|
-
- spec/plaid/models/transaction_spec.rb
|
168
|
-
- spec/plaid/models/user_spec.rb
|
169
|
-
- spec/plaid_spec.rb
|
170
|
-
- spec/spec_helper.rb
|
166
|
+
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2015 Justin Crites
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/PUBLISHING.md
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# Publishing
|
2
|
-
|
3
|
-
The module is published to the [rubygems.org][1] under the gem name [plaid][2].
|
4
|
-
|
5
|
-
The publishing process is handled by [rake][3].
|
6
|
-
|
7
|
-
After updating the package version, run:
|
8
|
-
|
9
|
-
```console
|
10
|
-
$ rake spec
|
11
|
-
$ rake build
|
12
|
-
$ rake release
|
13
|
-
```
|
14
|
-
|
15
|
-
See the [semantic versioning][4] guidelines to determine what level of release to publish.
|
16
|
-
|
17
|
-
[1]: https://rubygems.org
|
18
|
-
[2]: https://rubygems.org/gems/plaid
|
19
|
-
[3]: https://github.com/ruby/rake
|
20
|
-
[4]: http://semver.org
|
21
|
-
|
data/lib/plaid/config.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Plaid
|
2
|
-
module Configure
|
3
|
-
attr_accessor :customer_id, :secret, :environment_location
|
4
|
-
|
5
|
-
KEYS = [:customer_id, :secret, :environment_location]
|
6
|
-
|
7
|
-
def config
|
8
|
-
yield self
|
9
|
-
|
10
|
-
# Add trailing slash to api url if it is not present
|
11
|
-
if self.environment_location[-1] != '/'
|
12
|
-
self.environment_location += '/'
|
13
|
-
end
|
14
|
-
|
15
|
-
self
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
data/lib/plaid/connection.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
require 'json'
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
module Plaid
|
6
|
-
class Connection
|
7
|
-
class << self
|
8
|
-
# API: semi-private
|
9
|
-
def post(path, options = {})
|
10
|
-
uri = build_uri(path)
|
11
|
-
options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
|
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)
|
17
|
-
parse_response(res)
|
18
|
-
end
|
19
|
-
|
20
|
-
# API: semi-private
|
21
|
-
def get(path, id = nil)
|
22
|
-
uri = build_uri(path,id)
|
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)
|
28
|
-
end
|
29
|
-
|
30
|
-
# API: semi-private
|
31
|
-
def secure_get(path, access_token, options = {})
|
32
|
-
uri = build_uri(path)
|
33
|
-
options.merge!({access_token:access_token})
|
34
|
-
req = Net::HTTP::Get.new(uri.path)
|
35
|
-
req.body = URI.encode_www_form(options) if options
|
36
|
-
req.content_type = 'application/x-www-form-urlencoded'
|
37
|
-
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
|
38
|
-
parse_response(res)
|
39
|
-
end
|
40
|
-
|
41
|
-
# API: semi-private
|
42
|
-
def patch(path, options = {})
|
43
|
-
uri = build_uri(path)
|
44
|
-
options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
|
45
|
-
req = Net::HTTP::Patch.new(uri.path)
|
46
|
-
req.body = URI.encode_www_form(options) if options
|
47
|
-
req.content_type = 'application/x-www-form-urlencoded'
|
48
|
-
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
|
49
|
-
parse_response(res)
|
50
|
-
end
|
51
|
-
|
52
|
-
# API: semi-private
|
53
|
-
def delete(path, options = {})
|
54
|
-
uri = build_uri(path)
|
55
|
-
options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
|
56
|
-
req = Net::HTTP::Delete.new(uri.path)
|
57
|
-
req.body = URI.encode_www_form(options) if options
|
58
|
-
req.content_type = 'application/x-www-form-urlencoded'
|
59
|
-
Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
|
60
|
-
end
|
61
|
-
|
62
|
-
protected
|
63
|
-
|
64
|
-
# API: semi-private
|
65
|
-
def build_uri(path, option = nil)
|
66
|
-
path = path + '/' + option unless option.nil?
|
67
|
-
URI.parse(Plaid.environment_location + path)
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def parse_response(res)
|
73
|
-
# unfortunately, the JSON gem will raise an exception if the response is empty
|
74
|
-
raise Plaid::ServerError.new(res.code, res.msg, '') if res.body.to_s.length < 2
|
75
|
-
# we got a response from the server, so parse it
|
76
|
-
body = JSON.parse(res.body)
|
77
|
-
case res.code.delete('.').to_i
|
78
|
-
when 200 then body
|
79
|
-
when 201 then { msg: 'Requires further authentication', body: body}
|
80
|
-
when 400
|
81
|
-
raise Plaid::BadRequest.new(body['code'], body['message'], body['resolve'])
|
82
|
-
when 401
|
83
|
-
raise Plaid::Unauthorized.new(body['code'], body['message'], body['resolve'])
|
84
|
-
when 402
|
85
|
-
raise Plaid::RequestFailed.new(body['code'], body['message'], body['resolve'])
|
86
|
-
when 404
|
87
|
-
raise Plaid::NotFound.new(body['code'], body['message'], body['resolve'])
|
88
|
-
else
|
89
|
-
raise Plaid::ServerError.new(body['code'], body['message'], body['resolve'])
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def parse_get_response(res)
|
94
|
-
body = JSON.parse(res)
|
95
|
-
return body if body.kind_of?(Array)
|
96
|
-
|
97
|
-
case body['code']
|
98
|
-
when nil
|
99
|
-
body
|
100
|
-
when 1301, 1401, 1501, 1601
|
101
|
-
raise Plaid::NotFound.new(body['code'], body['message'], body['resolve'])
|
102
|
-
else
|
103
|
-
body
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|