View Source Plaid.Client behaviour (elixir_plaid v1.2.1)
Make API calls to plaid and convert the responses from JSON -> well typed elixir structs.
To use a different HTTP client, create a new module like MyApp.PlaidClient
which implements
post/3
and implements the @behaviour Plaid.Client
behaviour. The success response of those functions must return a :body
key with a JSON string value
and a :status_code
key with an integer HTTP status. For an example, see the Plaid.Client.HTTPoison
module.
For network errors where you don't get a body or status code, you may return an error tuple with any error value, but the error value is not currently utilized.
Link to this section Summary
Callbacks
Callback to POST the data to the Plaid API.
Functions
Make a Plaid API call.
Link to this section Callbacks
Specs
post( url :: String.t(), payload :: String.t(), headers :: [{String.t(), String.t()}] ) :: {:ok, %{body: String.t(), status_code: integer()}} | {:error, any()}
Callback to POST the data to the Plaid API.
Will be called with the full URL, payload, and headers. Simply take these values execute the HTTP request.
headers
passed in will be a list of two item tuples where the first item is the header key and the second is the value. e.g.[{"content-type", "application/json"}]
examples
Examples
iex> post("https://production.plaid.com/categories/get", ~s<{"thing": "stuff"}>, [{"content-type", "application/json"}])
{:ok, %{body: ~s<{"foo": "bar"}>, status_code: 200}}
Link to this section Functions
Specs
call(String.t(), map(), module(), Plaid.config()) :: {:ok, any()} | {:error, Plaid.Error.t()}
Make a Plaid API call.
Takes in everything needed to complete the request and return a well formed struct of the response.
examples
Examples
call(
"/categories/get",
%{},
Plaid.Categories.GetResponse,
client_id: "123",
secret: "abc"
)
{:ok, %Plaid.Categories.GetResponse{}}