Investec Open API v0.1.0 InvestecOpenApi.Accounts.Balance View Source

This module deals with the get_account_balance api endpoint.

Link to this section Summary

Functions

Outputs the balance for a given user and account. This needs an authenticated client and account_id (or %InvestecOpenApi.Accounts{} object) as input parameters.

Link to this section Types

Specs

t() :: %InvestecOpenApi.Accounts.Balance{
  account_id: binary(),
  available_balance: number(),
  currency: binary(),
  current_balance: number()
}

Link to this section Functions

Link to this function

call_get_balance(client, account_id)

View Source

Specs

Link to this function

create_balance_object(balance)

View Source

Specs

create_balance_object(nil | map()) :: t()
Link to this function

get_balance(client, account_id)

View Source

Specs

get_balance(InvestecOpenApi.Client.t(), binary() | InvestecOpenApi.Accounts.t()) ::
  {:error, any()} | {:ok, t(), InvestecOpenApi.Client.t()}

Outputs the balance for a given user and account. This needs an authenticated client and account_id (or %InvestecOpenApi.Accounts{} object) as input parameters.

It will an %InvestecOpenApi.Accounts.Balance{} object.

With this it also returns an authenticated %InvestecOpenApi.Client{} again, because if the previous access_token has expired, a new one woule automatically be created again

Example

iex> {:ok, client} = InvestecOpenApi.new()
...> {:ok, [account | _], client} = InvestecOpenApi.Accounts.list_accounts(client)
...> {:ok, balance, client} = InvestecOpenApi.Accounts.Balance.get_balance(client, account)
...> balance
%InvestecOpenApi.Accounts.Balance{
  account_id: "172878438321553632224",
  available_balance: 98857.76,
  currency: "ZAR",
  current_balance: 28857.76
}