View Source Swoosh.ApiClient behaviour (Swoosh v1.17.3)

Specification for a Swoosh API client.

It can be set to your own client with:

config :swoosh, :api_client, MyAPIClient

Swoosh comes with Swoosh.ApiClient.Hackney, Swoosh.ApiClient.Finch, and Swoosh.ApiClient.Req.

Summary

Callbacks

Callback to initializes the given api client.

Callback invoked when posting to a given URL.

Functions

API used by adapters to post to a given URL with headers, body, and email.

Types

body()

@type body() :: binary()

headers()

@type headers() :: [{binary(), binary()}]

status()

@type status() :: pos_integer()

url()

@type url() :: binary()

Callbacks

init()

(optional)
@callback init() :: :ok

Callback to initializes the given api client.

post(url, headers, body, t)

@callback post(url(), headers(), body(), Swoosh.Email.t()) ::
  {:ok, status(), headers(), body()} | {:error, term()}

Callback invoked when posting to a given URL.

Functions

post(url, headers, body, email)

API used by adapters to post to a given URL with headers, body, and email.