MoneyHub.SavingsGoals (MoneyHub v1.0.0)

Copy Markdown View Source

Savings goals: user-defined targets tracked against the combined balance of one or more accounts, surfacing progress as both an amount and a percentage.

See Spending and Income Goals and the savings-goals recipe.

Summary

Functions

Creates a savings goal. attrs typically includes "name", "targetAmount", and "accountIds" (the account(s) whose combined balance counts toward the goal).

Deletes a savings goal.

Fetches a single savings goal, including current progress.

Lists savings goals for the user identified by token.

Updates a savings goal's attributes (e.g. target amount, name, accounts).

Types

goal()

@type goal() :: map()

Functions

create(config, token, attrs)

@spec create(MoneyHub.Config.t(), String.t(), map()) ::
  {:ok, goal()} | {:error, MoneyHub.Error.t()}

Creates a savings goal. attrs typically includes "name", "targetAmount", and "accountIds" (the account(s) whose combined balance counts toward the goal).

delete(config, token, goal_id)

@spec delete(MoneyHub.Config.t(), String.t(), String.t()) ::
  :ok | {:error, MoneyHub.Error.t()}

Deletes a savings goal.

get(config, token, goal_id)

@spec get(MoneyHub.Config.t(), String.t(), String.t()) ::
  {:ok, goal()} | {:error, MoneyHub.Error.t()}

Fetches a single savings goal, including current progress.

list(config, token)

@spec list(MoneyHub.Config.t(), String.t()) ::
  {:ok, [goal()]} | {:error, MoneyHub.Error.t()}

Lists savings goals for the user identified by token.

update(config, token, goal_id, attrs)

@spec update(MoneyHub.Config.t(), String.t(), String.t(), map()) ::
  {:ok, goal()} | {:error, MoneyHub.Error.t()}

Updates a savings goal's attributes (e.g. target amount, name, accounts).