plaid 2.2.0 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23f868bb29f987801f40bb8666471898caa9a51b
4
- data.tar.gz: 2acc57e2e3f6e7df16b336078b26c0f85032f1c6
3
+ metadata.gz: 4f8aeb4ddef4c58a7a03b9902450a8b87fc82296
4
+ data.tar.gz: d9b2daf9205549d39fa5a4f25700ddfae73cf6d7
5
5
  SHA512:
6
- metadata.gz: 76a97718db8ed7e5072c5ed55ccaf0bc9c281d412d6806b6f1da972bd0b3f46e86fde3fb62eebb6e511e568241f38d6b3fa0fc6ec488f0183cbc3688113439f1
7
- data.tar.gz: 50a9f87dd4fb6f77cd6af0ebefaec70c20ef9d2d0b3266bb4e00da7f03a7b3e19d91b7e46fe98799fb22aab506d5f6e6307ec166369e150569c90721b10621aa
6
+ metadata.gz: 51e64249b4daad06dd8dd03d648b721204d3383ae493289b1dccf85e80ec2fe5892a83b388d4ec8ac2b417dd47732dafb1f3658a3cfb790947cb94b1866d2aaa
7
+ data.tar.gz: 2ab1e1bb607cb87ddaaa3a0adc52946b18dbac5e4112f8db945226985fafd2b93ef10d763eba101cd0ac2fea688c8cec455e660caacab9b8f0972a307d1135f2
@@ -1,3 +1,7 @@
1
+ # 3.0.0. 17-Jan-2017
2
+
3
+ * Add `/institutions/all` and `/institutions/all/search` endpoints, see [UPGRADING.md](UPGRADING.md#upgrading-from-2xx-to-300)
4
+
1
5
  # 2.2.0. 03-Nov-2016
2
6
 
3
7
  * Add `Transaction#reference_number` (@ericbirdsall).
data/README.md CHANGED
@@ -199,15 +199,13 @@ cat = Plaid::Category.get('17001013') # A single category by its ID
199
199
 
200
200
  ### Institutions
201
201
 
202
- Financial institution information is available via `Plaid::Institution` and `Plaid::LongTailInstitution`:
202
+ Financial institution information is available via `Plaid::Institution`.
203
203
 
204
204
  ```ruby
205
- insts = Plaid::Institution.all # Array of all major financial institutions
205
+ insts = Plaid::Institution.all(count: 20, offset: 20) # A page
206
206
  inst = Plaid::Institution.get('5301a93ac140de84910000e0') # A single institution by its ID
207
207
 
208
- lti = Plaid::LongTailInstitution.get('bofa') # A single one
209
- ltis = Plaid::LongTailInstitution.all(count: 20, offset: 20) # A page
210
- res = Plaid::LongTailInstitution.search(query: 'c') # Lookup by name
208
+ res = Plaid::Institution.search(query: 'c') # Lookup by name
211
209
  ```
212
210
 
213
211
  ### Webhooks
@@ -281,8 +279,8 @@ user1 = Plaid::User.create(:connect, 'wells', 'plaid_test', 'plaid_good')
281
279
  # Api user (using api client)
282
280
  user2 = Plaid::User.create(:connect, 'wells', 'plaid_test', 'plaid_good', client: api)
283
281
 
284
- # Lookup a long tail institution in production
285
- res = Plaid::LongTailInstitution.search(query: 'c', client: api)
282
+ # Lookup an institution in production
283
+ res = Plaid::Institution.search(query: 'c', client: api)
286
284
  ```
287
285
 
288
286
  The `client` option can be passed to the following methods:
@@ -294,9 +292,8 @@ The `client` option can be passed to the following methods:
294
292
  * `Category.get`
295
293
  * `Institution.all`
296
294
  * `Institution.get`
297
- * `LongTailInstitution.all`
298
- * `LongTailInstitution.search`
299
- * `LongTailInstitution.get`
295
+ * `Institution.search`
296
+ * `Institution.search_by_id`
300
297
 
301
298
  ### Errors
302
299
 
@@ -1,3 +1,18 @@
1
+ ## Upgrading from 2.x.x to 3.0.0
2
+
3
+ Version 3.0.0 makes `Plaid::Institution` use new `institutions/all` endpoint
4
+ of Plaid API which unites "native" and "long tail" institutions.
5
+ `Plaid::LongTailInstitution` class is removed, its functionality is
6
+ concentrated in `Plaid::Institution`.
7
+
8
+ Use `Plaid::Institution.all` instead of `Plaid::LongTailInstitution.all` (the
9
+ semantics is the same, with added products param).
10
+
11
+ Use `Plaid::Institution.search` instead of `Plaid::LongTailInstitution.search`.
12
+
13
+ Use `Plaid::Institution.search_by_id` instead of `Plaid::LongTailInstitution.get`.
14
+
15
+
1
16
  ## Upgrading from 1.x to 2.0.0
2
17
 
3
18
  Make sure you use Ruby 2.0 or higher.
@@ -19,7 +19,7 @@ module Plaid
19
19
  alias has_mfa? has_mfa
20
20
 
21
21
  # Public: The Hash with MFA options available. E.g. ["code", "list",
22
- # "questions(3)"]. This means that you are allowed to request a list of
22
+ # "questions(3)"]. In this case you are allowed to request a list of
23
23
  # possible MFA options, use code-based MFA and questions MFA (there are 3
24
24
  # questions).
25
25
  attr_reader :mfa
@@ -60,38 +60,123 @@ module Plaid
60
60
  # Public: Get information about the Financial Institutions currently
61
61
  # supported by Plaid.
62
62
  #
63
- # Does a GET /institutions call.
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.
64
67
  #
65
- # client - The Plaid::Client instance used to connect
66
- # (default: Plaid.client).
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).
67
75
  #
68
76
  # Returns an Array of Institution instances.
69
- def self.all(client: nil)
70
- Connector.new(:institutions, client: client).get.map do |idata|
71
- new(idata)
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))
72
86
  end
87
+
88
+ resp = conn.post(payload)
89
+
90
+ Page.new(resp['total_count'],
91
+ resp['results'].map { |item| new(item) })
73
92
  end
74
93
 
75
94
  # Public: Get information about a given Financial Institution.
76
95
  #
77
- # Does a GET /institutions/:id call.
96
+ # Does a GET /institutions/all/:id call.
78
97
  #
79
- # id - the String institution ID (e.g. "5301a93ac140de84910000e0").
98
+ # id - the String institution ID (e.g. "5301a93ac140de84910000e0", or
99
+ # "ins_109263").
80
100
  # client - The Plaid::Client instance used to connect
81
101
  # (default: Plaid.client).
82
102
  #
83
103
  # Returns an Institution instance or raises Plaid::NotFoundError if
84
104
  # institution with given id is not found.
85
105
  def self.get(id, client: nil)
86
- new Connector.new(:institutions, id, client: client).get
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
87
163
  end
88
164
  end
89
165
 
90
- ##############################################################################
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
91
176
 
92
- # Public: A class encapsulating information about a "long tail" Financial
93
- # Institution supported by Plaid.
94
- class LongTailInstitution
177
+ # Public: A class encapsulating information about a Financial Institution
178
+ # supported by Plaid.
179
+ class SearchResultInstitution
95
180
  # Public: The String ID of the institution. Same as type. E.g. "bofa".
96
181
  attr_reader :id
97
182
 
@@ -137,7 +222,7 @@ module Plaid
137
222
  # Public: ???.
138
223
  attr_reader :name_break
139
224
 
140
- # Internal: Initialize the LongTailInstitution instance.
225
+ # Internal: Initialize the SearchResultInstitution instance.
141
226
  def initialize(hash)
142
227
  %w(id type name video logo).each do |f|
143
228
  instance_variable_set "@#{f}", hash[f]
@@ -156,7 +241,7 @@ module Plaid
156
241
  #
157
242
  # Returns a String.
158
243
  def inspect
159
- "#<Plaid::LongTailInstitution id=#{id.inspect}, name=#{name.inspect}, " \
244
+ "#<Plaid::SearchResultInstitution id=#{id.inspect}, name=#{name.inspect}, " \
160
245
  '...>'
161
246
  end
162
247
 
@@ -164,77 +249,5 @@ module Plaid
164
249
  #
165
250
  # Returns a String.
166
251
  alias to_s inspect
167
-
168
- # Public: Lookup a "long tail" Financial Institution by ID.
169
- #
170
- # Does a GET /institutions/search call with id param.
171
- #
172
- # id - the String institution ID (e.g. 'bofa').
173
- # client - The Plaid::Client instance used to connect
174
- # (default: Plaid.client).
175
- #
176
- # Returns an Institution instance or nil if institution with given id is not
177
- # found.
178
- def self.get(id, client: nil)
179
- client ||= Plaid.client
180
-
181
- # If client_id is set, use it, no authentication otherwise
182
- auth = client && !client.client_id.nil?
183
- conn = Connector.new(:institutions, :search, auth: auth, client: client)
184
- resp = conn.get(id: id)
185
-
186
- case resp
187
- when Hash
188
- new resp
189
- when Array
190
- raise 'Non-empty array returned by /institutions/search with id' \
191
- unless resp.empty?
192
-
193
- nil
194
- else
195
- raise 'Unexpected result returned by /institutions/search with id: ' \
196
- "#{resp.inspect}"
197
- end
198
- end
199
-
200
- # Public: Get information about the "long tail" institutions supported
201
- # by Plaid via partnerships.
202
- #
203
- # Does a POST /institutions/longtail call.
204
- #
205
- # count - The Integer number of results to retrieve (default: 50).
206
- # offset - The Integer number of results to skip forward from the
207
- # beginning of the list (default: 0).
208
- # client - The Plaid::Client instance used to connect
209
- # (default: Plaid.client).
210
- #
211
- # Returns an Array of LongTailInstitution instances.
212
- def self.all(count: 50, offset: 0, client: nil)
213
- conn = Connector.new(:institutions, :longtail, auth: true, client: client)
214
- resp = conn.post(count: count, offset: offset)
215
- resp.map { |lti_data| new(lti_data) }
216
- end
217
-
218
- # Public: Search "long tail" institutions.
219
- #
220
- # query - The String search query to match against the full list of
221
- # institutions. Partial matches are returned making this useful
222
- # for autocompletion purposes.
223
- # product - The Symbol product name to filter by, one of Plaid::PRODUCTS
224
- # (e.g. :info, :connect, etc.). Only valid when query is
225
- # specified. If nil, results are not filtered by product
226
- # (default: nil).
227
- # client - The Plaid::Client instance used to connect
228
- # (default: Plaid.client).
229
- def self.search(query: nil, product: nil, client: nil)
230
- raise ArgumentError, 'query must be specified' \
231
- unless query.is_a?(String) && !query.empty?
232
-
233
- payload = { q: query }
234
- payload[:p] = product.to_s if product
235
-
236
- resp = Connector.new(:institutions, :search, client: client).get(payload)
237
- resp.map { |lti_data| new(lti_data) }
238
- end
239
252
  end
240
253
  end
@@ -1,3 +1,3 @@
1
1
  module Plaid
2
- VERSION = '2.2.0'.freeze
2
+ VERSION = '3.0.0'.freeze
3
3
  end
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: 2.2.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Dashevskii
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-03 00:00:00.000000000 Z
11
+ date: 2017-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  requirements: []
162
162
  rubyforge_project:
163
- rubygems_version: 2.4.5.1
163
+ rubygems_version: 2.5.1
164
164
  signing_key:
165
165
  specification_version: 4
166
166
  summary: Ruby bindings for Plaid