sendr_lettermint

sendr_lettermint — Lettermint email backend for sendr.

Builds HTTP Request values for the Lettermint send API and parses Response values returned by it.

Types

Configuration for the Lettermint API backend.

pub opaque type LettermintConfig

Errors that can occur when interacting with the Lettermint API.

pub type LettermintError {
  InvalidUri(String)
  InvalidResponse(status: Int, error: json.DecodeError)
  ApiError(
    status: Int,
    code: option.Option(String),
    message: String,
  )
}

Constructors

  • InvalidUri(String)

    The base URI could not be parsed (internal error).

  • InvalidResponse(status: Int, error: json.DecodeError)

    The API response body could not be decoded.

  • ApiError(
      status: Int,
      code: option.Option(String),
      message: String,
    )

    The API returned a non-202 status with error details.

Values

pub fn config(token token: String) -> LettermintConfig

Create a new LettermintConfig with the given API token.

pub fn request(
  message message: message.Message,
  config config: LettermintConfig,
) -> Result(
  request.Request(String),
  sendr.SendrError(LettermintError),
)

Build an HTTP Request for the Lettermint send API from a sendr Message.

Validates the message (from, reply-to, recipients, subject, attachments) and returns Error(SendrError(LettermintError)) on validation failure.

pub fn response(
  response response: response.Response(String),
) -> Result(String, sendr.SendrError(LettermintError))

Parse a Response from the Lettermint send API.

On HTTP 202 the response body is decoded and the message_id value is returned. On HTTP 422 the detail array is decoded into ApiErrorDetail entries. All other statuses are treated as generic API errors.

pub fn set_route(
  config config: LettermintConfig,
  route route: String,
) -> LettermintConfig

Set the route for this config.

Routes control deliverability settings in your Lettermint account.

Search Document