The main interface to Plaid API.

Sections
Methods
A
B
C
L
N
P
Attributes
[R] accounts

The Plaid::Accounts product accessor.

[R] asset_report

The Plaid::AssetReport product accessor.

[R] auth

The Plaid::Auth product accessor.

[R] categories

The Plaid::Categories product accessor.

[R] credit_details

The Plaid::CreditDetails product accessor.

[R] deposit_switch

The Plaid::DepositSwitch product accessor.

[R] identity

The Plaid::Identity product accessor.

[R] income

The Plaid::Income product accessor.

[R] institutions

The Plaid::Institutions product accessor.

[R] investments

The Plaid::Investments product accessor.

[R] item

The Plaid::Item product accessor.

[R] liabilities

The Plaid::Liabilities product accessor.

[R] payment_initiation

The Plaid::PaymentInitiation product accessor.

[R] processor

The Plaid::Processor product accessor.

[R] sandbox

The Plaid::Sandbox product accessor.

[R] transactions

The Plaid::Transactions product accessor.

[R] webhooks

The Plaid::Webhooks endpoint accessor.

Instance Public methods

:attr_reader: Public: The Plaid::LinkToken endpoint accessor.

Public
Constants
ENVIRONMENTS = %i[sandbox development production].freeze
 

All possible environments for the client to use.

Attributes
[R] client_id

The client ID.

[R] env

The current environment in use (one of ENVIRONMENTS).

Class Public methods
build_default_connection(builder)

Set Plaid defaults on the Faraday connection.

builder

The Faraday builder object.

# File lib/plaid/client.rb, line 149
def self.build_default_connection(builder)
  builder.options[: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
new(env:, client_id:, secret:, &block)

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

# File lib/plaid/client.rb, line 22
def initialize(env:, client_id:, secret:, &block)
  @env        = env.to_sym
  @api_host   = api_host
  @client_id  = client_id
  @secret     = secret

  create_connection(&block)
end
Instance Public methods
post(path, payload)

Make a post request

path

Path or URL to make the request to

payload

The payload or data to post

Returns

Returns the resulting parsed JSON of the request

# File lib/plaid/client.rb, line 129
def post(path, payload)
  @connection.post(path, payload).body
end
post_with_auth(path, payload)

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

Returns the resulting parsed JSON of the request

# File lib/plaid/client.rb, line 139
def post_with_auth(path, payload)
  @connection.post(
    path,
    payload.merge(client_id: @client_id, secret: @secret)
  ).body
end
Internal
Instance Protected methods
api_host()

Gets the API hostname for given environment.

env

The Symbol (:sandbox, :development, :production)

Returns

Returns a String representing the environment URL. Raises ArgumentError if environment is unknown.

# File lib/plaid/client.rb, line 171
def api_host
  unless ENVIRONMENTS.include?(@env)
    raise ArgumentError,
          "Invalid value for env (#{@env.inspect}): must be one of " +
          ENVIRONMENTS.map(&:inspect) * ', '
  end

  "https://#{@env}.plaid.com"
end
client()

subproduct-generated methods depend on client method.

# File lib/plaid/client.rb, line 161
def client
  self
end
create_connection()

Initializes a new Plaid connection object via Faraday.

Optionally takes a block to allow overriding the defaults.

# File lib/plaid/client.rb, line 184
def create_connection
  @connection = Faraday.new(url: @api_host) do |builder|
    block_given? ? yield(builder) : Client.build_default_connection(builder)
  end
end