Mercury.Transactions (mercury_client v1.0.0)

Copy Markdown View Source

The Mercury Transactions API for cross-account transaction lookups, updates, and attachments.

Sending money and listing an individual account's transactions live on Mercury.Accounts (send_money/3, list_transactions/3), matching the reference API's routing (/account/{id}/transactions).

Summary

Functions

Returns a single transaction by ID. GET /transaction/{id}

Same as get/2 but raises on error.

Returns one page of transactions across every account. GET /transactions

Same as list/2 but raises on error.

A lazy, auto-paginating stream of every transaction across every account.

Updates a transaction's note and/or category. POST /transaction/{id}

Uploads a file attachment (e.g. a receipt) to a transaction. POST /transaction/{id}/attachment

Functions

get(client, transaction_id)

@spec get(client :: Mercury.Client.t(), transaction_id :: String.t()) ::
  {:ok, Mercury.Transaction.t()} | {:error, Exception.t()}

Returns a single transaction by ID. GET /transaction/{id}

get!(client, transaction_id)

@spec get!(client :: Mercury.Client.t(), transaction_id :: String.t()) ::
  Mercury.Transaction.t()

Same as get/2 but raises on error.

list(client, opts \\ [])

@spec list(client :: Mercury.Client.t(), opts :: keyword()) ::
  {:ok, Mercury.Page.t(Mercury.Transaction.t())} | {:error, Exception.t()}

Returns one page of transactions across every account. GET /transactions

Accepts :account_id, :limit, :order, :start_after, :end_before, :status, :kind filters.

list!(client, opts \\ [])

@spec list!(client :: Mercury.Client.t(), opts :: keyword()) ::
  Mercury.Page.t(Mercury.Transaction.t())

Same as list/2 but raises on error.

stream(client, opts \\ [])

@spec stream(client :: Mercury.Client.t(), opts :: keyword()) :: Enumerable.t()

A lazy, auto-paginating stream of every transaction across every account.

update(client, transaction_id, attrs)

@spec update(
  client :: Mercury.Client.t(),
  transaction_id :: String.t(),
  attrs :: map() | keyword()
) ::
  {:ok, Mercury.Transaction.t()} | {:error, Exception.t()}

Updates a transaction's note and/or category. POST /transaction/{id}

Mercury.Transactions.update(client, transaction_id, %{note: "Client lunch"})

update!(client, transaction_id, attrs)

@spec update!(
  client :: Mercury.Client.t(),
  transaction_id :: String.t(),
  attrs :: map() | keyword()
) ::
  Mercury.Transaction.t()

upload_attachment(client, transaction_id, filename, content)

@spec upload_attachment(
  client :: Mercury.Client.t(),
  transaction_id :: String.t(),
  filename :: String.t(),
  content :: binary()
) :: {:ok, term()} | {:error, Exception.t()}

Uploads a file attachment (e.g. a receipt) to a transaction. POST /transaction/{id}/attachment

upload_attachment!(client, transaction_id, filename, content)

@spec upload_attachment!(
  client :: Mercury.Client.t(),
  transaction_id :: String.t(),
  filename :: String.t(),
  content :: binary()
) :: term()