Lettermint.Client (Lettermint v2.0.0)

Copy Markdown View Source

The client configuration: tokens, base URL, timeout and HTTP adapter.

Create it with Lettermint.new/1 or Lettermint.new/2 and pass it as the first argument to every SDK function. The struct is immutable, holds no message state and is safe to share between processes; create it once.

The tokens are kept inside closures, so they appear in no debug output: inspect/2 (also with structs: false), :io_lib.format("~p", ...), Jason.encode/1 and crash reports show "[redacted]" or a function reference instead.

Summary

Types

A token, wrapped in a closure so that it is never printed.

t()

Functions

Classifies a token by its format: lm_team_ followed by letters and digits is a team token, lm_ followed by letters and digits a sending token. The team pattern is checked first, because every team token also starts with lm_. Raises Lettermint.ConfigError for any other format; the message never contains the token.

Types

secret()

@opaque secret()

A token, wrapped in a closure so that it is never printed.

t()

@type t() :: %Lettermint.Client{
  adapter: module() | {module(), keyword()},
  base_url: String.t(),
  sending_token: secret() | nil,
  team_token: secret() | nil,
  timeout: pos_integer()
}

Functions

detect(token)

@spec detect(term()) :: :team | :sending

Classifies a token by its format: lm_team_ followed by letters and digits is a team token, lm_ followed by letters and digits a sending token. The team pattern is checked first, because every team token also starts with lm_. Raises Lettermint.ConfigError for any other format; the message never contains the token.