DripDrop.ChannelAdapters (DripDrop v0.1.0)

Copy Markdown View Source

Context for creating, updating, and selecting channel adapters.

Summary

Functions

Creates a channel adapter and atomically promotes it when is_default is true.

Gets an active channel adapter by id.

Returns the active default adapter for a channel, preferring the tenant default.

Lists channel adapters using optional tenant, channel, and active filters.

Selects the adapter for a step using explicit, rotation, sequence, and default fallbacks.

Selects the pinned outbound adapter, allowing a per-step override.

Updates a channel adapter and demotes the previous scoped default when needed.

Returns webhook routes exposed by active provider adapters.

Types

list_filters()

@type list_filters() :: %{
  optional(:tenant_key) => binary() | nil,
  optional(:channel) => binary(),
  optional(:active) => boolean()
}

Functions

create_channel_adapter(attrs)

@spec create_channel_adapter(map()) ::
  {:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}

Creates a channel adapter and atomically promotes it when is_default is true.

get_active_adapter(adapter_id)

@spec get_active_adapter(Ecto.UUID.t() | binary()) :: Ecto.Schema.t() | nil

Gets an active channel adapter by id.

get_default_adapter(channel, tenant_key)

@spec get_default_adapter(binary() | atom(), binary() | nil) :: Ecto.Schema.t() | nil

Returns the active default adapter for a channel, preferring the tenant default.

list_channel_adapters(filters \\ %{})

@spec list_channel_adapters(list_filters()) :: [Ecto.Schema.t()]

Lists channel adapters using optional tenant, channel, and active filters.

select(step, sequence, step_execution)

@spec select(term(), term(), term()) ::
  {:ok, Ecto.Schema.t()} | {:error, %{kind: :permanent, reason: :no_adapter}}

Selects the adapter for a step using explicit, rotation, sequence, and default fallbacks.

select_outbound(step, enrollment)

@spec select_outbound(term(), term()) ::
  {:ok, Ecto.Schema.t()}
  | {:error, %{kind: :permanent, reason: :no_outbound_pin | :no_adapter}}

Selects the pinned outbound adapter, allowing a per-step override.

update_channel_adapter(adapter, attrs)

@spec update_channel_adapter(Ecto.Schema.t(), map()) ::
  {:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}

Updates a channel adapter and demotes the previous scoped default when needed.

webhook_routes()

@spec webhook_routes() :: [DripDrop.Channel.webhook_route()]

Returns webhook routes exposed by active provider adapters.