A class encapsulating information about a Financial Institution supported by Plaid.
[R] | credentials | The Hash with credential labels, how they are exactly named by the institution. E.g. {“username”: “Online ID”, “password”: “Password”}. |
[R] | has_mfa | The Boolean flag telling if the institution requires MFA. |
[R] | has_mfa? | The Boolean flag telling if the institution requires MFA. |
[R] | id | The String institution ID. E.g. “5301a93ac140de84910000e0”. |
[R] | mfa | The Hash with MFA options available. E.g. [“code”, “list”, “questions(3)”]. In this case you are allowed to request a list of possible MFA options, use code-based MFA and questions MFA (there are 3 questions). |
[R] | name | The String institution name. E.g. “Bank of America”. |
[R] | products | An Array with Symbol product names supported by the institution. E.g. [:connect, :auth, :balance, :info, :income, :risk]. See Plaid::PRODUCTS. |
[R] | type | The String institution shortname, or “type” per Plaid API docs. E.g. “bofa”. |
Get information about the Financial Institutions currently supported by Plaid.
Does a POST /institutions/all call. The result is paginated (count, offset params) and filtered by products. If the products param is specified, only institutions which support all of the products mentioned will be returned.
- count
-
The Integer number of results to retrieve (default: 50).
- offset
-
The Integer number of results to skip forward from the beginning of the list (default: 0).
- products
-
The Array of product Symbols (see Plaid::PRODUCTS) or nil. E.g. [:connect, :auth]. Default: nil.
- client
-
The Plaid::Client instance used to connect (default: Plaid.client).
Returns
Returns an Array of Institution instances.
Source: show
# File lib/plaid/institution.rb, line 77 def self.all(count: 50, offset: 0, products: nil, client: nil) conn = Connector.new(:institutions, :all, auth: true, client: client) payload = { count: count, offset: offset } if products payload[:products] = MultiJson.encode(Array(products)) end resp = conn.post(payload) Page.new(resp['total_count'], resp['results'].map { |item| new(item) }) end
Get information about a given Financial Institution.
Does a GET /institutions/all/:id call.
- id
-
the String institution ID (e.g. “5301a93ac140de84910000e0”, or “ins_109263”).
- client
-
The Plaid::Client instance used to connect (default: Plaid.client).
Returns
Returns an Institution instance or raises Plaid::NotFoundError if institution with given id is not found.
Source: show
# File lib/plaid/institution.rb, line 105 def self.get(id, client: nil) new Connector.new('institutions/all', id, client: client).get end
Search Financial Institutions.
- query
-
The String search query to match against the full list of institutions. Partial matches are returned making this useful for autocompletion purposes.
- product
-
The Symbol product name to filter by, one of Plaid::PRODUCTS (e.g. :info, :connect, etc.). Only valid when query is specified. If nil, results are not filtered by product (default: nil).
- client
-
The Plaid::Client instance used to connect (default: Plaid.client).
Returns
Returns an Array of SearchResultInstitution.
Source: show
# File lib/plaid/institution.rb, line 122 def self.search(query: nil, product: nil, client: nil) raise ArgumentError, 'query must be specified' unless query.is_a?(String) && !query.empty? payload = { q: query } payload[:p] = product.to_s if product resp = Connector.new('institutions/all', :search, client: client).get(payload) resp.map { |inst| SearchResultInstitution.new(inst) } end
Lookup a Financial Institution by ID.
Does a GET /institutions/all/search call with id param.
- id
-
the String institution ID (e.g. 'bofa').
- client
-
The Plaid::Client instance used to connect (default: Plaid.client).
Returns
Returns an SearchResultInstitution instance or nil if institution with given id is not found.
Source: show
# File lib/plaid/institution.rb, line 143 def self.search_by_id(id, client: nil) client ||= Plaid.client # If client_id is set, use it, no authentication otherwise auth = client && !client.client_id.nil? conn = Connector.new('institutions/all', :search, auth: auth, client: client) resp = conn.get(id: id) case resp when Hash SearchResultInstitution.new resp when Array raise 'Non-empty array returned by /institutions/all/search with id' unless resp.empty? nil else raise 'Unexpected result returned by /institutions/all/search with id: ' "#{resp.inspect}" end end
Get a String representation of the institution.
Returns
Returns a String.
Source: show
# File lib/plaid/institution.rb, line 50 def inspect "#<Plaid::Institution id=#{id.inspect}, type=#{type.inspect}, " "name=#{name.inspect}>" end
Get a String representation of the institution.
Returns
Returns a String.
Initialize an Institution with given fields.
Source: show
# File lib/plaid/institution.rb, line 37 def initialize(fields) @id = fields['id'] @name = fields['name'] @type = fields['type'] @has_mfa = fields['has_mfa'] @mfa = fields['mfa'] @credentials = fields['credentials'] @products = fields['products'].map(&:to_sym) end