Longbridge.AssetContext (longbridge v0.1.0)

Copy Markdown View Source

Account statement context.

Provides access to Longbridge account statement data (daily and monthly statements) and statement file download URLs.

All functions accept a Longbridge.Config struct and return {:ok, data} | {:error, reason} tuples.

Usage

config = Longbridge.Config.new(...)

{:ok, statements} = Longbridge.AssetContext.statements(config, :daily)
{:ok, url} = Longbridge.AssetContext.download_url(config, "file-key-abc")

Summary

Functions

Gets a presigned download URL for a statement file.

Types

statement_type()

@type statement_type() :: :daily | :monthly

Functions

download_url(config, file_key, opts \\ [])

@spec download_url(Longbridge.Config.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Gets a presigned download URL for a statement file.

file_key comes from the statements/2 response (the "file_key" field of each list entry).

Endpoint: GET /v1/statement/download?file_key=<key>. The returned URL is short-lived and points at the Longbridge file store; fetch it with a regular HTTP client (not Longbridge.HTTPClient) before it expires.

Returns {:ok, %{"url" => url, "expire_at" => unix_seconds}} or {:error, reason}.

statements(config, opts \\ [], http_opts \\ [])

@spec statements(Longbridge.Config.t(), keyword(), keyword()) ::
  {:ok, map()} | {:error, term()}

Lists account statements.

Options

  • :type:daily (default) or :monthly
  • :page — page cursor for pagination (integer)
  • :page_size — results per page (default: 20)

Returns {:ok, %{"list" => [%{"dt" => date_int, "file_key" => key}]}} or {:error, reason}.