ClearBank.Accounts.Reporting (ClearBank v1.0.0)

Copy Markdown View Source

Account reporting via camt.053 bank statements.

ClearBank generates ISO 20022 camt.053 statement files on request. Statements are paginated — request generation, then retrieve page-by-page.

Workflow

  1. Call request_statement/2 with your date range and account.
  2. The response includes a messageId.
  3. Poll get_statement_page/3 with the messageId and page numbers until you have all pages (check totalPages in the response).

Examples

{:ok, %{"messageId" => msg_id}} = ClearBank.Accounts.Reporting.request_statement(client,
  account_id: "acct-uuid",
  start_date: "2024-01-01",
  end_date: "2024-01-31"
)

{:ok, page} = ClearBank.Accounts.Reporting.get_statement_page(client, msg_id, 1)

Summary

Functions

Fetches all pages of a statement and returns them as a list.

Downloads a specific page of a generated camt.053 statement.

Requests generation of a camt.053 statement.

Functions

get_all_pages(client, message_id)

@spec get_all_pages(ClearBank.Client.t(), String.t()) ::
  {:ok, [map()]} | {:error, term()}

Fetches all pages of a statement and returns them as a list.

Makes sequential HTTP calls until all pages are retrieved. For large statements, consider streaming page-by-page instead.

Examples

{:ok, all_pages} = ClearBank.Accounts.Reporting.get_all_pages(client, "msg-uuid")

get_statement_page(client, message_id, page_number)

@spec get_statement_page(ClearBank.Client.t(), String.t(), pos_integer()) ::
  ClearBank.HTTP.result()

Downloads a specific page of a generated camt.053 statement.

Examples

{:ok, page_data} = ClearBank.Accounts.Reporting.get_statement_page(client, "msg-uuid", 1)

request_statement(client, params)

@spec request_statement(
  ClearBank.Client.t(),
  keyword()
) :: ClearBank.HTTP.result()

Requests generation of a camt.053 statement.

Required params

  • :account_id - the real account UUID
  • :start_date - ISO 8601 date string, e.g. "2024-01-01"
  • :end_date - ISO 8601 date string, e.g. "2024-01-31"

Optional params

  • :currency - ISO 4217 code (default: "GBP")
  • :include_virtual - boolean, include virtual account transactions

Examples

{:ok, resp} = ClearBank.Accounts.Reporting.request_statement(client,
  account_id: "acct-uuid",
  start_date: "2024-01-01",
  end_date: "2024-01-31",
  currency: "GBP"
)