MoneyHub.Connections (MoneyHub v1.0.0)

Copy Markdown View Source

Connection lifecycle management: listing a user's bank connections, checking sync status, and removing connections.

A "connection" represents one instance of a user linking a single financial institution. See Connection Lifecycle, Connection Status, and Connections Management.

To create a connection, drive the user through MoneyHub.Auth with AIS scopes - there is no direct "create connection" API call, since establishing a connection requires user interaction with their bank. To refresh an existing connection's data, see MoneyHub.Claims.put_connection_id/2 combined with MoneyHub.Auth.

Summary

Functions

Lists connections available to be made (bank/provider catalog), without requiring a user token - this is a client-credentials-only endpoint.

Lists only API-based (live, non-screen-scraping) connections.

Lists only legacy (screen-scraping) connections.

Lists only connections that support payment initiation (PIS).

Lists only test/mock connections, for use in sandbox development.

Removes a connection and its associated accounts/transactions.

Fetches a single connection by id.

Lists all connections for the user identified by token.

Fetches the sync status of a connection - useful for polling after initiating an asynchronous connection or a refresh.

Triggers an immediate sync of an existing connection, refreshing its accounts/transactions outside of Moneyhub's normal background schedule. Requires accounts:read plus either accounts:write or accounts:write:all.

Types

connection()

@type connection() :: map()

Functions

available(config, token)

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

Lists connections available to be made (bank/provider catalog), without requiring a user token - this is a client-credentials-only endpoint.

See Available Connections.

available_api(config, token)

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

Lists only API-based (live, non-screen-scraping) connections.

available_legacy(config, token)

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

Lists only legacy (screen-scraping) connections.

available_payments(config, token)

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

Lists only connections that support payment initiation (PIS).

available_test(config, token)

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

Lists only test/mock connections, for use in sandbox development.

delete(config, token, connection_id)

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

Removes a connection and its associated accounts/transactions.

get(config, token, connection_id)

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

Fetches a single connection by id.

list(config, token)

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

Lists all connections for the user identified by token.

status(config, token, connection_id)

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

Fetches the sync status of a connection - useful for polling after initiating an asynchronous connection or a refresh.

sync(config, token, connection_id)

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

Triggers an immediate sync of an existing connection, refreshing its accounts/transactions outside of Moneyhub's normal background schedule. Requires accounts:read plus either accounts:write or accounts:write:all.