ExPlain.Webhooks (ExPlain v0.3.0)

Copy Markdown View Source

Operations for managing webhook targets in Plain.

Summary

Functions

Creates a new webhook target.

Deletes a webhook target.

Fetches a webhook target by its Plain ID. Returns {:ok, nil} if not found.

Returns a paginated list of webhook targets.

Updates a webhook target.

Functions

create(client, input)

@spec create(ExPlain.Client.t(), map()) ::
  {:ok, ExPlain.Webhooks.WebhookTarget.t()} | {:error, ExPlain.Error.t()}

Creates a new webhook target.

The input map must include :url and :event_subscriptions (list of %{event_type: "..."} maps). Optional: :description, :is_enabled.

delete(client, webhook_target_id)

@spec delete(ExPlain.Client.t(), String.t()) ::
  {:ok, :deleted} | {:error, ExPlain.Error.t()}

Deletes a webhook target.

get_by_id(client, webhook_target_id)

@spec get_by_id(ExPlain.Client.t(), String.t()) ::
  {:ok, ExPlain.Webhooks.WebhookTarget.t() | nil} | {:error, ExPlain.Error.t()}

Fetches a webhook target by its Plain ID. Returns {:ok, nil} if not found.

list(client, opts \\ [])

@spec list(
  ExPlain.Client.t(),
  keyword()
) ::
  {:ok,
   %{
     nodes: [ExPlain.Webhooks.WebhookTarget.t()],
     page_info: ExPlain.PageInfo.t()
   }}
  | {:error, ExPlain.Error.t()}

Returns a paginated list of webhook targets.

update(client, input)

@spec update(ExPlain.Client.t(), map()) ::
  {:ok, ExPlain.Webhooks.WebhookTarget.t()} | {:error, ExPlain.Error.t()}

Updates a webhook target.