Karta. Webhooks. MailgunSettings
(Karta v1.0.0)
A server's webhooks in Mailgun's format as Mailgun's webhooks API sees
them (/v3/domains/<domain>/webhooks, KartaWeb.Mailgun.WebhookController):
for each of Mailgun's webhook names, the URLs its events go to.
Mailgun's names and Karta's event types:
accepted-message.accepted;delivered-message.delivered;permanent_fail-message.bouncedandmessage.suppressed;temporary_fail-message.deferred;opened,clicked-message.opened,message.clicked;unsubscribed-message.unsubscribed;complained-message.complained.
The same webhooks. These are the server's webhooks in Mailgun's
format, however they were made (the v2 API, the admin interface, or
here), switched on or off: a name's URLs are those of the webhooks that
receive at least one of its types. Setting a name's URLs (put/3)
gives each URL's webhook the name's types (the first one with that URL;
a new webhook, "Mailgun webhook", when there is none) and takes them
from the webhooks not listed; a webhook left without types is removed
(delete/2 does that for every URL of the name). A URL keeps or
replaces the user name and password it is given with, as a webhook's URL
does (Karta.Webhooks.Webhook); it is shown without them. Mailgun's
webhooks are per domain, Karta's per server: the URLs serve every domain
of the server.
One signing key. Mailgun signs every webhook of an account with one
key; so a webhook made here takes the signing key of the server's
oldest webhook in Mailgun's format, and a rotation of that key
(Karta.Webhooks.rotate_secret/2) changes it for every webhook that
shares it. The first one gets a new key, shown to nobody: its owners
learn it by rotating it.
Summary
Functions
Takes the name's types from every webhook that has them; returns the URLs it had.
The URLs of a name; {:error, :not_found} when it has none.
The names that have URLs, with their URLs (oldest webhook first).
Mailgun's webhook names Karta has, in order.
Makes urls (one to three) the name's URLs, and returns them. Giving
the URLs it has changes nothing.
Types
Functions
@spec delete(Karta.Servers.Server.t(), String.t()) :: {:ok, [String.t()]} | {:error, error()}
Takes the name's types from every webhook that has them; returns the URLs it had.
@spec get(Karta.Servers.Server.t(), String.t()) :: {:ok, [String.t()]} | {:error, error()}
The URLs of a name; {:error, :not_found} when it has none.
@spec list(Karta.Servers.Server.t()) :: %{required(String.t()) => [String.t()]}
The names that have URLs, with their URLs (oldest webhook first).
@spec names() :: [String.t()]
Mailgun's webhook names Karta has, in order.
@spec put(Karta.Servers.Server.t(), String.t(), [String.t()]) :: {:ok, [String.t()]} | {:error, error() | Ecto.Changeset.t()}
Makes urls (one to three) the name's URLs, and returns them. Giving
the URLs it has changes nothing.