sendr_scaleway

sendr_scaleway — Scaleway Transactional Email backend for sendr.

Builds HTTP Request values for the Scaleway Transactional Email API and parses Response values returned by it.

Types

A single error detail from the Scaleway API error response.

pub type ApiErrorDetail {
  ApiErrorDetail(msg: String, error_type: String)
}

Constructors

  • ApiErrorDetail(msg: String, error_type: String)

Configuration for the Scaleway Transactional Email API backend.

pub opaque type ScalewayConfig

Errors that can occur when interacting with the Scaleway API.

pub type ScalewayError {
  InvalidUri(String)
  InvalidResponse(status: Int, error: json.DecodeError)
  ApiError(status: Int, details: List(ApiErrorDetail))
}

Constructors

  • InvalidUri(String)

    The URI could not be parsed (internal error).

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

    The API response body could not be decoded.

  • ApiError(status: Int, details: List(ApiErrorDetail))

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

Values

pub fn config(
  api_key api_key: String,
  region region: String,
  project_id project_id: String,
) -> ScalewayConfig

Create a new ScalewayConfig.

api_key is your Scaleway secret key (used for the X-Auth-Token header). region is the Scaleway region (e.g. "fr-par"). project_id is your Scaleway Project UUID.

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

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

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

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

Parse a Response from the Scaleway send API.

On HTTP 200 the response body is decoded and the message_id of the first email is returned. All other statuses are treated as API errors.

Search Document