Class: Plaid::Client
- Inherits:
-
Object
- Object
- Plaid::Client
- Extended by:
- SubproductMixin
- Defined in:
- lib/plaid/client.rb
Overview
Public: The main interface to Plaid API.
Constant Summary collapse
- ENVIRONMENTS =
Public: All possible environments for the client to use.
%i[sandbox development production].freeze
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Public: The current environment in use (one of ENVIRONMENTS).
Class Method Summary collapse
-
.build_default_connection(builder) ⇒ Object
Public: Set Plaid defaults on the Faraday connection.
Instance Method Summary collapse
-
#accounts ⇒ Object
:attr_reader: Public: The Plaid::Accounts product accessor.
-
#auth ⇒ Object
:attr_reader: Public: The Plaid::Auth product accessor.
-
#categories ⇒ Object
:attr_reader: Public: The Plaid::Categories product accessor.
-
#credit_details ⇒ Object
:attr_reader: Public: The Plaid::CreditDetails product accessor.
-
#identity ⇒ Object
:attr_reader: Public: The Plaid::Identity product accessor.
-
#income ⇒ Object
:attr_reader: Public: The Plaid::Income product accessor.
-
#initialize(env:, client_id:, secret:, public_key:, &block) ⇒ Client
constructor
Public: Construct a Client instance.
-
#institutions ⇒ Object
:attr_reader: Public: The Plaid::Institutions product accessor.
-
#item ⇒ Object
:attr_reader: Public: The Plaid::Item product accessor.
-
#post(path, payload) ⇒ Object
Public: Make a post request.
-
#post_with_auth(path, payload) ⇒ Object
Public: Make a post request with appended authentication fields.
-
#post_with_public_key(path, payload) ⇒ Object
Public: Make a post request with appended public key field.
-
#processor ⇒ Object
:attr_reader: Public: The Plaid::Processor product accessor.
-
#sandbox ⇒ Object
:attr_reader: Public: The Plaid::Sandbox product accessor.
-
#transactions ⇒ Object
:attr_reader: Public: The Plaid::Transactions product accessor.
Methods included from SubproductMixin
Constructor Details
#initialize(env:, client_id:, secret:, public_key:, &block) ⇒ Client
Public: Construct a Client instance
Optionally takes a block to allow overriding the default Faraday connection options.
env - The Symbol (:sandbox, :development, :production) client_id - The String Plaid account client ID to authenticate requests secret - The String Plaid account secret to authenticate requests public_key - The String Plaid account public key to authenticate requests
20 21 22 23 24 25 26 27 28 |
# File 'lib/plaid/client.rb', line 20 def initialize(env:, client_id:, secret:, public_key:, &block) @env = env.to_sym @api_host = api_host @client_id = client_id @secret = secret @public_key = public_key create_connection(&block) end |
Instance Attribute Details
#env ⇒ Object (readonly)
Public: The current environment in use (one of ENVIRONMENTS).
9 10 11 |
# File 'lib/plaid/client.rb', line 9 def env @env end |
Class Method Details
.build_default_connection(builder) ⇒ Object
Public: Set Plaid defaults on the Faraday connection.
builder - The Faraday builder object.
123 124 125 126 127 128 129 130 |
# File 'lib/plaid/client.rb', line 123 def self.build_default_connection(builder) builder.[:timeout] = Plaid::Middleware::NETWORK_TIMEOUT builder.headers = Plaid::Middleware::NETWORK_HEADERS builder.request :json builder.use Plaid::Middleware builder.response :json, content_type: /\bjson$/ builder.adapter Faraday.default_adapter end |
Instance Method Details
#accounts ⇒ Object
:attr_reader: Public: The Plaid::Accounts product accessor.
35 |
# File 'lib/plaid/client.rb', line 35 subproduct :accounts |
#auth ⇒ Object
:attr_reader: Public: The Plaid::Auth product accessor.
40 |
# File 'lib/plaid/client.rb', line 40 subproduct :auth |
#categories ⇒ Object
:attr_reader: Public: The Plaid::Categories product accessor.
45 |
# File 'lib/plaid/client.rb', line 45 subproduct :categories |
#credit_details ⇒ Object
:attr_reader: Public: The Plaid::CreditDetails product accessor.
50 |
# File 'lib/plaid/client.rb', line 50 subproduct :credit_details |
#identity ⇒ Object
:attr_reader: Public: The Plaid::Identity product accessor.
55 |
# File 'lib/plaid/client.rb', line 55 subproduct :identity |
#income ⇒ Object
:attr_reader: Public: The Plaid::Income product accessor.
60 |
# File 'lib/plaid/client.rb', line 60 subproduct :income |
#institutions ⇒ Object
:attr_reader: Public: The Plaid::Institutions product accessor.
65 |
# File 'lib/plaid/client.rb', line 65 subproduct :institutions |
#item ⇒ Object
:attr_reader: Public: The Plaid::Item product accessor.
70 |
# File 'lib/plaid/client.rb', line 70 subproduct :item |
#post(path, payload) ⇒ Object
Public: Make a post request
path - Path or URL to make the request to payload - The payload or data to post
Returns the resulting parsed JSON of the request
93 94 95 |
# File 'lib/plaid/client.rb', line 93 def post(path, payload) @connection.post(path, payload).body end |
#post_with_auth(path, payload) ⇒ Object
Public: Make a post request with appended authentication fields
path - Path or URL to make the request to payload - The payload or data to post
Returns the resulting parsed JSON of the request
103 104 105 106 107 108 |
# File 'lib/plaid/client.rb', line 103 def post_with_auth(path, payload) @connection.post( path, payload.merge(client_id: @client_id, secret: @secret) ).body end |
#post_with_public_key(path, payload) ⇒ Object
Public: Make a post request with appended public key field.
path - Path or URL to make the request to. payload - The payload or data to post.
Returns the resulting parsed JSON of the request.
116 117 118 |
# File 'lib/plaid/client.rb', line 116 def post_with_public_key(path, payload) @connection.post(path, payload.merge(public_key: @public_key)).body end |
#processor ⇒ Object
:attr_reader: Public: The Plaid::Processor product accessor.
75 |
# File 'lib/plaid/client.rb', line 75 subproduct :processor |
#sandbox ⇒ Object
:attr_reader: Public: The Plaid::Sandbox product accessor.
80 |
# File 'lib/plaid/client.rb', line 80 subproduct :sandbox |
#transactions ⇒ Object
:attr_reader: Public: The Plaid::Transactions product accessor.
85 |
# File 'lib/plaid/client.rb', line 85 subproduct :transactions |