plaid 3.0.0 → 4.0.0
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 +4 -4
- data/CONTRIBUTING.md +7 -1
- data/Gemfile +0 -1
- data/LICENSE.txt +21 -0
- data/README.md +233 -206
- data/Rakefile +1 -2
- data/bin/console +8 -7
- data/circle.yml +3 -0
- data/lib/plaid.rb +15 -60
- data/lib/plaid/client.rb +120 -52
- data/lib/plaid/connect.rb +75 -0
- data/lib/plaid/errors.rb +60 -24
- data/lib/plaid/products/accounts.rb +60 -0
- data/lib/plaid/products/auth.rb +29 -0
- data/lib/plaid/products/categories.rb +18 -0
- data/lib/plaid/products/credit_details.rb +21 -0
- data/lib/plaid/products/identity.rb +20 -0
- data/lib/plaid/products/income.rb +20 -0
- data/lib/plaid/products/institutions.rb +51 -0
- data/lib/plaid/products/item.rb +230 -0
- data/lib/plaid/products/processor.rb +48 -0
- data/lib/plaid/products/sandbox.rb +32 -0
- data/lib/plaid/products/transactions.rb +74 -0
- data/lib/plaid/version.rb +1 -1
- data/plaid.gemspec +13 -8
- metadata +21 -61
- data/CHANGELOG.md +0 -34
- data/LICENSE +0 -20
- data/UPGRADING.md +0 -60
- data/lib/plaid/account.rb +0 -144
- data/lib/plaid/category.rb +0 -62
- data/lib/plaid/connector.rb +0 -172
- data/lib/plaid/income.rb +0 -106
- data/lib/plaid/info.rb +0 -65
- data/lib/plaid/institution.rb +0 -253
- data/lib/plaid/risk.rb +0 -34
- data/lib/plaid/transaction.rb +0 -128
- data/lib/plaid/user.rb +0 -507
- data/lib/plaid/webhook.rb +0 -153
data/lib/plaid/info.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
module Plaid
|
2
|
-
# Public: Representation of user information.
|
3
|
-
class Info
|
4
|
-
# Public: The Array of String user names.
|
5
|
-
#
|
6
|
-
# E.g. ["Frodo Baggins", "Samwise Gamgee"].
|
7
|
-
attr_reader :names
|
8
|
-
|
9
|
-
# Public: The Array of Hash user emails information.
|
10
|
-
#
|
11
|
-
# E.g. [{data: "frodo.baggins@plaid.com", type: :primary}, ...]
|
12
|
-
attr_reader :emails
|
13
|
-
|
14
|
-
# Public: The Array of Hash user phone number information.
|
15
|
-
#
|
16
|
-
# E.g. [{data: "111-222-3456", type: :work, primary: false},
|
17
|
-
# {data: "123-456-7891", type: :mobile, primary: true}]
|
18
|
-
attr_reader :phone_numbers
|
19
|
-
|
20
|
-
# Public: The Array of Hash user address information.
|
21
|
-
#
|
22
|
-
# E.g. [{ primary: true, data: {
|
23
|
-
# "street" => "1 Hobbit Way",
|
24
|
-
# "city" => "The Shire",
|
25
|
-
# "state" => "CA",
|
26
|
-
# "zip" => "94108"}}]
|
27
|
-
attr_reader :addresses
|
28
|
-
|
29
|
-
# Internal: Construct the Info object.
|
30
|
-
def initialize(fields)
|
31
|
-
@names = fields['names']
|
32
|
-
@emails = fields['emails'].map do |h|
|
33
|
-
symbolize_values Plaid.symbolize_hash(h), :type
|
34
|
-
end
|
35
|
-
|
36
|
-
@phone_numbers = fields['phone_numbers'].map do |h|
|
37
|
-
symbolize_values Plaid.symbolize_hash(h), :type
|
38
|
-
end
|
39
|
-
|
40
|
-
@addresses = fields['addresses'].map do |h|
|
41
|
-
Plaid.symbolize_hash(h)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# Public: Get a String representation of Info object.
|
46
|
-
#
|
47
|
-
# Returns a String.
|
48
|
-
def inspect
|
49
|
-
"#<Plaid::Info names=#{names.inspect}, ...>"
|
50
|
-
end
|
51
|
-
|
52
|
-
# Public: Get a String representation of Info object.
|
53
|
-
#
|
54
|
-
# Returns a String.
|
55
|
-
alias to_s inspect
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
def symbolize_values(hash, *keys)
|
60
|
-
hash.each do |k, v|
|
61
|
-
hash[k] = v.to_sym if keys.include?(k)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
data/lib/plaid/institution.rb
DELETED
@@ -1,253 +0,0 @@
|
|
1
|
-
module Plaid
|
2
|
-
# Public: A class encapsulating information about a Financial Institution
|
3
|
-
# supported by Plaid.
|
4
|
-
class Institution
|
5
|
-
# Public: The String institution ID. E.g. "5301a93ac140de84910000e0".
|
6
|
-
attr_reader :id
|
7
|
-
|
8
|
-
# Public: The String institution name. E.g. "Bank of America".
|
9
|
-
attr_reader :name
|
10
|
-
|
11
|
-
# Public: The String institution shortname, or "type" per Plaid API docs.
|
12
|
-
# E.g. "bofa".
|
13
|
-
attr_reader :type
|
14
|
-
|
15
|
-
# Public: The Boolean flag telling if the institution requires MFA.
|
16
|
-
attr_reader :has_mfa
|
17
|
-
|
18
|
-
# Public: Returns true if the institution requires MFA.
|
19
|
-
alias has_mfa? has_mfa
|
20
|
-
|
21
|
-
# Public: The Hash with MFA options available. E.g. ["code", "list",
|
22
|
-
# "questions(3)"]. In this case you are allowed to request a list of
|
23
|
-
# possible MFA options, use code-based MFA and questions MFA (there are 3
|
24
|
-
# questions).
|
25
|
-
attr_reader :mfa
|
26
|
-
|
27
|
-
# Public: The Hash with credential labels, how they are exactly named by
|
28
|
-
# the institution. E.g. {"username": "Online ID", "password": "Password"}.
|
29
|
-
attr_reader :credentials
|
30
|
-
|
31
|
-
# Public: An Array with Symbol product names supported by the institution.
|
32
|
-
# E.g. [:connect, :auth, :balance, :info, :income, :risk]. See
|
33
|
-
# Plaid::PRODUCTS.
|
34
|
-
attr_reader :products
|
35
|
-
|
36
|
-
# Internal: Initialize an Institution with given fields.
|
37
|
-
def initialize(fields)
|
38
|
-
@id = fields['id']
|
39
|
-
@name = fields['name']
|
40
|
-
@type = fields['type']
|
41
|
-
@has_mfa = fields['has_mfa']
|
42
|
-
@mfa = fields['mfa']
|
43
|
-
@credentials = fields['credentials']
|
44
|
-
@products = fields['products'].map(&:to_sym)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Public: Get a String representation of the institution.
|
48
|
-
#
|
49
|
-
# Returns a String.
|
50
|
-
def inspect
|
51
|
-
"#<Plaid::Institution id=#{id.inspect}, type=#{type.inspect}, " \
|
52
|
-
"name=#{name.inspect}>"
|
53
|
-
end
|
54
|
-
|
55
|
-
# Public: Get a String representation of the institution.
|
56
|
-
#
|
57
|
-
# Returns a String.
|
58
|
-
alias to_s inspect
|
59
|
-
|
60
|
-
# Public: Get information about the Financial Institutions currently
|
61
|
-
# supported by Plaid.
|
62
|
-
#
|
63
|
-
# Does a POST /institutions/all call. The result is paginated (count,
|
64
|
-
# offset params) and filtered by products. If the products param is
|
65
|
-
# specified, only institutions which support all of the products mentioned
|
66
|
-
# will be returned.
|
67
|
-
#
|
68
|
-
# count - The Integer number of results to retrieve (default: 50).
|
69
|
-
# offset - The Integer number of results to skip forward from the
|
70
|
-
# beginning of the list (default: 0).
|
71
|
-
# products - The Array of product Symbols (see Plaid::PRODUCTS) or nil.
|
72
|
-
# E.g. [:connect, :auth]. Default: nil.
|
73
|
-
# client - The Plaid::Client instance used to connect
|
74
|
-
# (default: Plaid.client).
|
75
|
-
#
|
76
|
-
# Returns an Array of Institution instances.
|
77
|
-
def self.all(count: 50, offset: 0, products: nil, client: nil)
|
78
|
-
conn = Connector.new(:institutions, :all, auth: true, client: client)
|
79
|
-
payload = {
|
80
|
-
count: count,
|
81
|
-
offset: offset
|
82
|
-
}
|
83
|
-
|
84
|
-
if products
|
85
|
-
payload[:products] = MultiJson.encode(Array(products))
|
86
|
-
end
|
87
|
-
|
88
|
-
resp = conn.post(payload)
|
89
|
-
|
90
|
-
Page.new(resp['total_count'],
|
91
|
-
resp['results'].map { |item| new(item) })
|
92
|
-
end
|
93
|
-
|
94
|
-
# Public: Get information about a given Financial Institution.
|
95
|
-
#
|
96
|
-
# Does a GET /institutions/all/:id call.
|
97
|
-
#
|
98
|
-
# id - the String institution ID (e.g. "5301a93ac140de84910000e0", or
|
99
|
-
# "ins_109263").
|
100
|
-
# client - The Plaid::Client instance used to connect
|
101
|
-
# (default: Plaid.client).
|
102
|
-
#
|
103
|
-
# Returns an Institution instance or raises Plaid::NotFoundError if
|
104
|
-
# institution with given id is not found.
|
105
|
-
def self.get(id, client: nil)
|
106
|
-
new Connector.new('institutions/all', id, client: client).get
|
107
|
-
end
|
108
|
-
|
109
|
-
# Public: Search Financial Institutions.
|
110
|
-
#
|
111
|
-
# query - The String search query to match against the full list of
|
112
|
-
# institutions. Partial matches are returned making this useful
|
113
|
-
# for autocompletion purposes.
|
114
|
-
# product - The Symbol product name to filter by, one of Plaid::PRODUCTS
|
115
|
-
# (e.g. :info, :connect, etc.). Only valid when query is
|
116
|
-
# specified. If nil, results are not filtered by product
|
117
|
-
# (default: nil).
|
118
|
-
# client - The Plaid::Client instance used to connect
|
119
|
-
# (default: Plaid.client).
|
120
|
-
#
|
121
|
-
# Returns an Array of SearchResultInstitution.
|
122
|
-
def self.search(query: nil, product: nil, client: nil)
|
123
|
-
raise ArgumentError, 'query must be specified' \
|
124
|
-
unless query.is_a?(String) && !query.empty?
|
125
|
-
|
126
|
-
payload = { q: query }
|
127
|
-
payload[:p] = product.to_s if product
|
128
|
-
|
129
|
-
resp = Connector.new('institutions/all', :search, client: client).get(payload)
|
130
|
-
resp.map { |inst| SearchResultInstitution.new(inst) }
|
131
|
-
end
|
132
|
-
|
133
|
-
# Public: Lookup a Financial Institution by ID.
|
134
|
-
#
|
135
|
-
# Does a GET /institutions/all/search call with id param.
|
136
|
-
#
|
137
|
-
# id - the String institution ID (e.g. 'bofa').
|
138
|
-
# client - The Plaid::Client instance used to connect
|
139
|
-
# (default: Plaid.client).
|
140
|
-
#
|
141
|
-
# Returns an SearchResultInstitution instance or nil if institution with
|
142
|
-
# given id is not found.
|
143
|
-
def self.search_by_id(id, client: nil)
|
144
|
-
client ||= Plaid.client
|
145
|
-
|
146
|
-
# If client_id is set, use it, no authentication otherwise
|
147
|
-
auth = client && !client.client_id.nil?
|
148
|
-
conn = Connector.new('institutions/all', :search, auth: auth, client: client)
|
149
|
-
resp = conn.get(id: id)
|
150
|
-
|
151
|
-
case resp
|
152
|
-
when Hash
|
153
|
-
SearchResultInstitution.new resp
|
154
|
-
when Array
|
155
|
-
raise 'Non-empty array returned by /institutions/all/search with id' \
|
156
|
-
unless resp.empty?
|
157
|
-
|
158
|
-
nil
|
159
|
-
else
|
160
|
-
raise 'Unexpected result returned by /institutions/all/search with id: ' \
|
161
|
-
"#{resp.inspect}"
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
# Public: A page of results.
|
167
|
-
class Page < Array
|
168
|
-
# Public: The total number of institutions in all pages
|
169
|
-
attr_reader :total_count
|
170
|
-
|
171
|
-
def initialize(total_count, records)
|
172
|
-
@total_count = total_count
|
173
|
-
super records
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
# Public: A class encapsulating information about a Financial Institution
|
178
|
-
# supported by Plaid.
|
179
|
-
class SearchResultInstitution
|
180
|
-
# Public: The String ID of the institution. Same as type. E.g. "bofa".
|
181
|
-
attr_reader :id
|
182
|
-
|
183
|
-
# Public: The String short name ("type") of the institution. E.g. "bofa".
|
184
|
-
attr_reader :type
|
185
|
-
|
186
|
-
# Public: The String institution name. E.g. "Bank of America".
|
187
|
-
attr_reader :name
|
188
|
-
|
189
|
-
# Public: The Hash with supported products as keys and booleans as values.
|
190
|
-
#
|
191
|
-
# E.g. { auth: true, balance: true, connect: true, info: true }.
|
192
|
-
attr_reader :products
|
193
|
-
|
194
|
-
# Public: The String "forgotten password" URL.
|
195
|
-
attr_reader :forgotten_password_url
|
196
|
-
|
197
|
-
# Public: The String "account locked" URL.
|
198
|
-
attr_reader :account_locked_url
|
199
|
-
|
200
|
-
# Public: The String "account setup" URL.
|
201
|
-
attr_reader :account_setup_url
|
202
|
-
|
203
|
-
# Public: The String video (???).
|
204
|
-
attr_reader :video
|
205
|
-
|
206
|
-
# Public: The Array of Hashes with login fields information.
|
207
|
-
#
|
208
|
-
# E.g. [{ name: 'username', label: 'Online ID', type: 'text' },
|
209
|
-
# { name: 'password', label: 'Password', type: 'password' }].
|
210
|
-
attr_reader :fields
|
211
|
-
|
212
|
-
# Public: The Hash with color information for the institution.
|
213
|
-
#
|
214
|
-
# E.g. { primary: 'rgba(220,20,48,1)',
|
215
|
-
# darker: 'rgba(180,11,35,1)',
|
216
|
-
# gradient: ['rgba(250,20,51,1)', 'rgba(227,24,55,1)'] }.
|
217
|
-
attr_reader :colors
|
218
|
-
|
219
|
-
# Public: The String with base64 encoded logo.
|
220
|
-
attr_reader :logo
|
221
|
-
|
222
|
-
# Public: ???.
|
223
|
-
attr_reader :name_break
|
224
|
-
|
225
|
-
# Internal: Initialize the SearchResultInstitution instance.
|
226
|
-
def initialize(hash)
|
227
|
-
%w(id type name video logo).each do |f|
|
228
|
-
instance_variable_set "@#{f}", hash[f]
|
229
|
-
end
|
230
|
-
|
231
|
-
@products = Plaid.symbolize_hash(hash['products'])
|
232
|
-
@forgotten_password_url = hash['forgottenPassword']
|
233
|
-
@account_locked_url = hash['accountLocked']
|
234
|
-
@account_setup_url = hash['accountSetup']
|
235
|
-
@fields = hash['fields'].map { |fld| Plaid.symbolize_hash(fld) }
|
236
|
-
@colors = Plaid.symbolize_hash(hash['colors'])
|
237
|
-
@name_break = hash['nameBreak']
|
238
|
-
end
|
239
|
-
|
240
|
-
# Public: Get a String representation of the institution.
|
241
|
-
#
|
242
|
-
# Returns a String.
|
243
|
-
def inspect
|
244
|
-
"#<Plaid::SearchResultInstitution id=#{id.inspect}, name=#{name.inspect}, " \
|
245
|
-
'...>'
|
246
|
-
end
|
247
|
-
|
248
|
-
# Public: Get a String representation of the institution.
|
249
|
-
#
|
250
|
-
# Returns a String.
|
251
|
-
alias to_s inspect
|
252
|
-
end
|
253
|
-
end
|
data/lib/plaid/risk.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module Plaid
|
2
|
-
# Public: Representation of risk data (per account).
|
3
|
-
class Risk
|
4
|
-
# Public: The Float comprehensive risk score associated with the account,
|
5
|
-
# where 0 is the lowest risk and 1 is the highest. E.g. 0.5.
|
6
|
-
attr_reader :score
|
7
|
-
|
8
|
-
# Public: The Hash with Symbol reasons and associated Float subscores
|
9
|
-
# contributing to the overall risk score.
|
10
|
-
#
|
11
|
-
# E.g. { transaction_amounts: 0.78, foreign_fees: 0.96, ... }.
|
12
|
-
attr_reader :reason
|
13
|
-
|
14
|
-
# Internal: Construct a Risk object.
|
15
|
-
#
|
16
|
-
# fields - The Hash with fields.
|
17
|
-
def initialize(fields)
|
18
|
-
@score = fields['score']
|
19
|
-
@reason = Plaid.symbolize_hash(fields['reason'])
|
20
|
-
end
|
21
|
-
|
22
|
-
# Public: Get a String representation of Risk.
|
23
|
-
#
|
24
|
-
# Returns a String.
|
25
|
-
def inspect
|
26
|
-
"#<Plaid::Risk score=#{score.inspect}, ..."
|
27
|
-
end
|
28
|
-
|
29
|
-
# Public: Get a String representation of Risk.
|
30
|
-
#
|
31
|
-
# Returns a String.
|
32
|
-
alias to_s inspect
|
33
|
-
end
|
34
|
-
end
|
data/lib/plaid/transaction.rb
DELETED
@@ -1,128 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'date'
|
3
|
-
|
4
|
-
module Plaid
|
5
|
-
# Public: Representation of a transaction.
|
6
|
-
class Transaction
|
7
|
-
# Public: The String unique ID of the transaction. E.g.
|
8
|
-
# "0AZ0De04KqsreDgVwM1RSRYjyd8yXxSDQ8Zxn".
|
9
|
-
attr_reader :id
|
10
|
-
|
11
|
-
# Public: The String ID of the account in which this transaction occurred.
|
12
|
-
# E.g. "XARE85EJqKsjxLp6XR8ocg8VakrkXpTXmRdOo".
|
13
|
-
attr_reader :account_id
|
14
|
-
|
15
|
-
# Public: The Date that the transaction took place.
|
16
|
-
# E.g. #<Date: 2016-04-28 ...>
|
17
|
-
attr_reader :date
|
18
|
-
|
19
|
-
# Public: The settled dollar value as Float. Positive values when
|
20
|
-
# money moves out of the account; negative values when money moves
|
21
|
-
# in. E.g. 0.10 (10 cents).
|
22
|
-
attr_reader :amount
|
23
|
-
|
24
|
-
# Public: The String descriptive name of the transaction. E.g.
|
25
|
-
# "Golden Crepes".
|
26
|
-
attr_reader :name
|
27
|
-
|
28
|
-
# Public: The Hash with additional information regarding the
|
29
|
-
# transaction. The keys are Symbols. E.g.
|
30
|
-
# { location: { "city": "San Francisco", "state": "CA" } }
|
31
|
-
attr_reader :meta
|
32
|
-
|
33
|
-
# Public: The Hash with location information obtained from the
|
34
|
-
# meta field. The keys are Strings.
|
35
|
-
#
|
36
|
-
# E.g. {"address" => "262 W 15th St",
|
37
|
-
# "city" => "New York",
|
38
|
-
# "state" => "NY",
|
39
|
-
# "zip" => "10011",
|
40
|
-
# "coordinates" => {
|
41
|
-
# "lat" => 40.740352,
|
42
|
-
# "lon" => -74.001761
|
43
|
-
# }}
|
44
|
-
attr_reader :location
|
45
|
-
|
46
|
-
# Public: The Boolean flag which identifies the transaction as
|
47
|
-
# pending or unsettled.
|
48
|
-
attr_reader :pending
|
49
|
-
|
50
|
-
# Public: The Hash with numeric representation of Plaid confidence
|
51
|
-
# in the meta data attached to the transaction. In the case of a
|
52
|
-
# score <.9 Plaid will default to guaranteed and known
|
53
|
-
# information. E.g.
|
54
|
-
#
|
55
|
-
# {location: {
|
56
|
-
# "address" => 1,
|
57
|
-
# "city" => 1,
|
58
|
-
# "state" => 1
|
59
|
-
# }, name: 0.9}.
|
60
|
-
attr_reader :score
|
61
|
-
|
62
|
-
# Public: The Hash transaction type.
|
63
|
-
#
|
64
|
-
# E.g. {:primary => :place}.
|
65
|
-
attr_reader :type
|
66
|
-
|
67
|
-
# Public: The Array of String category hierarchy.
|
68
|
-
#
|
69
|
-
# E.g. ["Food and Drink", "Restaurants"].
|
70
|
-
attr_reader :category_hierarchy
|
71
|
-
|
72
|
-
# Public: The String Category ID.
|
73
|
-
#
|
74
|
-
# E.g. "13005000".
|
75
|
-
attr_reader :category_id
|
76
|
-
|
77
|
-
# Public: A String attribute that is used by the bank/payment
|
78
|
-
# processor to identify transactions — where applicable.
|
79
|
-
attr_reader :reference_number
|
80
|
-
|
81
|
-
# Public: The String ID of a posted transaction's associated
|
82
|
-
# pending transaction - where applicable.
|
83
|
-
attr_reader :pending_transaction_id
|
84
|
-
|
85
|
-
# Public: Initialize a Transaction instance.
|
86
|
-
#
|
87
|
-
# fields - The Hash with fields.
|
88
|
-
def initialize(fields)
|
89
|
-
@id = fields['_id']
|
90
|
-
@account_id = fields['_account']
|
91
|
-
|
92
|
-
@date = fields['date'] && Date.parse(fields['date'])
|
93
|
-
@amount = fields['amount']
|
94
|
-
@name = fields['name']
|
95
|
-
@meta = Plaid.symbolize_hash(fields['meta'])
|
96
|
-
@location = (@meta && @meta[:location]) || {}
|
97
|
-
@pending = fields['pending']
|
98
|
-
@reference_number = fields['_reference_number']
|
99
|
-
@pending_transaction_id = fields['_pendingTransaction']
|
100
|
-
@score = Plaid.symbolize_hash(fields['score'])
|
101
|
-
|
102
|
-
@type = Plaid.symbolize_hash(fields['type'], values: true)
|
103
|
-
@category_hierarchy = fields['category']
|
104
|
-
@category_id = fields['category_id']
|
105
|
-
end
|
106
|
-
|
107
|
-
# Public: Detect if the transaction is pending or unsettled.
|
108
|
-
#
|
109
|
-
# Returns true if it is.
|
110
|
-
def pending?
|
111
|
-
pending
|
112
|
-
end
|
113
|
-
|
114
|
-
# Public: Get a String representation of the transaction.
|
115
|
-
#
|
116
|
-
# Returns a String.
|
117
|
-
def inspect
|
118
|
-
"#<Plaid::Transaction id=#{id.inspect}, account_id=#{account_id.inspect}, " \
|
119
|
-
"date=#{date}, amount=#{amount.inspect}, name=#{name.inspect}, " \
|
120
|
-
"pending=#{pending.inspect}>"
|
121
|
-
end
|
122
|
-
|
123
|
-
# Public: Get a String representation of the transaction.
|
124
|
-
#
|
125
|
-
# Returns a String.
|
126
|
-
alias to_s inspect
|
127
|
-
end
|
128
|
-
end
|