LoopsEx.TransactionalEmails (LoopsEx v0.1.0)

View Source

Send and list transactional emails.

Summary

Types

Response type returned by Loops API calls

Functions

List published transactional email templates.

Send a transactional email to a contact.

Types

response()

@type response() :: LoopsEx.Client.response()

Response type returned by Loops API calls

Functions

list(params \\ %{})

@spec list(map()) :: response()

List published transactional email templates.

Parameters

  • params (map): optional query params:
    • "perPage" (string): number of items per page (10-50).
    • "cursor" (string): pagination cursor.

Returns

  • {:ok, [map()]} list of templates on success.
  • {:error, {status_code, response_body}} on HTTP error.

Example

iex> LoopsEx.TransactionalEmails.list(%{"perPage" => "20"})
{:ok, [%{"id" => "tid123", "name" => "Welcome", "lastUpdated" => "...", "dataVariables" => ["name"]}, ...]}

send_transactional(params)

@spec send_transactional(map()) :: response()

Send a transactional email to a contact.

Parameters

  • params (map): must include:
    • "email" (string): recipient email address.
    • "transactionalId" (string): ID of the transactional template.
    • Optional "addToAudience" (boolean).
    • Optional "dataVariables" (map) for template variables.
    • Optional "attachments" (list of maps) with keys "filename", "contentType", "data".

Returns

  • {:ok, %{"success" => true}} on success.
  • {:error, {status_code, response_body}} on HTTP error.

Example

iex> LoopsEx.TransactionalEmails.send_transactional(%{
...>   "email" => "john@example.com",
...>   "transactionalId" => "tid123",
...>   "dataVariables" => %{"name" => "John"}
...> })
{:ok, %{"success" => true}}