Current section

Files

Jump to
elixir_plaid lib plaid auth.ex
Raw

lib/plaid/auth.ex

defmodule Plaid.Auth do
@moduledoc """
[Plaid Auth API](https://plaid.com/docs/api/products/#auth) calls and schema.
"""
@doc """
Get information about account and routing numbers for
checking and savings accounts.
Does a `POST /auth/get` call which returns high level account information
along with account and routing numbers for checking and savings
accounts.
Params:
* `access_token` - Token to fetch accounts for.
Options:
* `account_ids` - Specific account ids to fetch balances for.
## Examples
get("access-sandbox-123xxx", client_id: "123", secret: "abc")
{:ok, %Plaid.Auth.GetResponse{}}
"""
@spec get(String.t(), options, Plaid.config()) ::
{:ok, Plaid.Auth.GetResponse.t()} | {:error, Plaid.Error.t()}
when options: %{optional(:account_ids) => [String.t()]}
def get(access_token, options \\ %{}, config) do
options_payload = Map.take(options, [:account_ids])
payload =
%{}
|> Map.put(:access_token, access_token)
|> Map.put(:options, options_payload)
Plaid.Client.call(
"/auth/get",
payload,
Plaid.Auth.GetResponse,
config
)
end
end