Holds configuration for talking to the Mercury Banking API and is passed
as the first argument to every function in Mercury.Accounts,
Mercury.Transactions, and the other resource modules.
Build one with new/2:
client = Mercury.Client.new("secret-token:mercury_production_...")Mercury.Client is an immutable struct — it is cheap to build and safe to
share across processes.
Summary
Functions
Builds a new Mercury.Client.
Types
@type response_hook() :: (method :: atom(), url :: String.t(), request_id :: String.t(), status :: pos_integer(), duration_ms :: non_neg_integer() -> any())
@type t() :: %Mercury.Client{ api_key: String.t(), base_url: String.t(), on_request: request_hook() | nil, on_response: response_hook() | nil, req: Req.Request.t(), retry: Mercury.Retry.t(), timeout: pos_integer() }
Functions
Builds a new Mercury.Client.
api_key must include the "secret-token:" prefix, e.g.
"secret-token:mercury_production_...".
Options
:base_url— override the API base URL. Default:"https://api.mercury.com/api/v1".:timeout— per-request timeout in milliseconds. Default:30000.:retry— aMercury.Retrystruct. Default:Mercury.Retry.default/0.:on_request— request hook, seerequest_hook/0.:on_response— response hook, seeresponse_hook/0.:req_options— extra options merged into the underlyingReq.new/1call (e.g.:plugfor tests,:connect_optionsfor proxies).
Examples
Mercury.Client.new("secret-token:mercury_production_...")
Mercury.Client.new("secret-token:mercury_sandbox_...",
base_url: "https://api-sandbox.mercury.com/api/v1",
timeout: 10_000
)