A class encapsulating HTTP requests to the Plaid API servers
[R] | body | |
[R] | http | |
[R] | request | |
[R] | response | |
[R] | uri |
DEFAULT_TIMEOUT | = | 120 |
Default read timeout for HTTP calls. |
Prepare to run request.
- path
-
The String path without leading slash. E.g. 'connect'
- subpath
-
The String subpath. E.g. 'get'
- auth
-
The Boolean flag indicating that client_id and secret should be included into the request payload.
- client
-
The Plaid::Client instance used to connect (default: Plaid.client).
Source: show
# File lib/plaid/connector.rb, line 21 def initialize(path, subpath = nil, auth: false, client: nil) @auth = auth @client = client || Plaid.client verify_configuration path = File.join(@client.env, path.to_s) path = File.join(path, subpath.to_s) if subpath @uri = URI.parse(path) @http = Net::HTTP.new(@uri.host, @uri.port) @http.use_ssl = true @http.read_timeout = Plaid.read_timeout || DEFAULT_TIMEOUT end
Run DELETE request.
Adds client_id and secret to the payload if @auth is true.
- payload
-
The Hash with data.
Returns
Returns the parsed JSON response body.
Source: show
# File lib/plaid/connector.rb, line 77 def delete(payload) post_like payload, Net::HTTP::Delete.new(@uri.path) end
Run GET request.
Returns
Returns the parsed JSON response body.
Source: show
# File lib/plaid/connector.rb, line 40 def get(payload = {}) payload = with_credentials(payload) @uri.query = URI.encode_www_form(payload) unless payload.empty? run Net::HTTP::Get.new(@uri) end
Check if MFA response received.
Returns
Returns true if response has code 201.
Source: show
# File lib/plaid/connector.rb, line 84 def mfa? @response.is_a?(Net::HTTPCreated) end