StarlingBank.SavingsGoals (StarlingBank v1.0.0)

Copy Markdown View Source

Savings Goals — create, fund, withdraw from, and delete savings pots attached to an account.

Required scopes: savings-goal:read, savings-goal:create, savings-goal:delete, savings-goal-transfer:read, savings-goal-transfer:create, savings-goal-transfer:delete.

Summary

Functions

Adds money to a savings goal (a 'top-up'). transfer_uid is an idempotency key you generate.

Creates a new savings goal.

Fetches a single savings goal.

Lists all savings goals on an account.

Sets/replaces the photo for a savings goal.

Withdraws money from a savings goal back into the main account.

Types

t()

@type t() :: %StarlingBank.SavingsGoals{
  name: String.t(),
  saved_percentage: integer() | nil,
  savings_goal_uid: String.t(),
  state: String.t(),
  target_currency: String.t() | nil,
  target_minor_units: integer() | nil,
  total_saved_currency: String.t(),
  total_saved_minor_units: integer()
}

Functions

add_money(account_uid, savings_goal_uid, transfer_uid, attrs, client \\ nil)

@spec add_money(
  String.t(),
  String.t(),
  String.t(),
  map(),
  StarlingBank.Client.t() | keyword() | nil
) ::
  {:ok, map()} | {:error, StarlingBank.Error.t()}

Adds money to a savings goal (a 'top-up'). transfer_uid is an idempotency key you generate.

create(account_uid, attrs, client \\ nil)

@spec create(String.t(), map(), StarlingBank.Client.t() | keyword() | nil) ::
  {:ok, map()} | {:error, StarlingBank.Error.t()}

Creates a new savings goal.

StarlingBank.SavingsGoals.create(account_uid, %{
  name: "Holiday",
  currency: "GBP",
  target: %{currency: "GBP", minorUnits: 100_000}
})

delete(account_uid, savings_goal_uid, client \\ nil)

@spec delete(String.t(), String.t(), StarlingBank.Client.t() | keyword() | nil) ::
  {:ok, nil} | {:error, StarlingBank.Error.t()}

Deletes a savings goal.

get(account_uid, savings_goal_uid, client \\ nil)

@spec get(String.t(), String.t(), StarlingBank.Client.t() | keyword() | nil) ::
  {:ok, t()} | {:error, StarlingBank.Error.t()}

Fetches a single savings goal.

list(account_uid, client \\ nil)

@spec list(String.t(), StarlingBank.Client.t() | keyword() | nil) ::
  {:ok, [t()]} | {:error, StarlingBank.Error.t()}

Lists all savings goals on an account.

set_photo(account_uid, savings_goal_uid, image_binary, client \\ nil)

@spec set_photo(
  String.t(),
  String.t(),
  binary(),
  StarlingBank.Client.t() | keyword() | nil
) ::
  {:ok, nil} | {:error, StarlingBank.Error.t()}

Sets/replaces the photo for a savings goal.

withdraw_money(account_uid, savings_goal_uid, transfer_uid, attrs, client \\ nil)

@spec withdraw_money(
  String.t(),
  String.t(),
  String.t(),
  map(),
  StarlingBank.Client.t() | keyword() | nil
) :: {:ok, map()} | {:error, StarlingBank.Error.t()}

Withdraws money from a savings goal back into the main account.