Lithic.Resources.Events (Lithic v1.0.0)

Copy Markdown View Source

Event subscriptions and webhook management.

Subscriptions

{:ok, sub} = Lithic.Events.create_subscription(%{
  url: "https://your-app.com/webhooks/lithic",
  description: "Production webhook",
  event_types: ["card.created", "transaction.settled"]
})

Secret rotation

{:ok, secret} = Lithic.Events.get_subscription_secret(sub["token"])
{:ok, new_secret} = Lithic.Events.rotate_subscription_secret(sub["token"])

Replay / Resend

{:ok, _} = Lithic.Events.resend_event(event_token, sub["token"])
{:ok, _} = Lithic.Events.replay_missing(sub["token"])

Summary

Functions

create_subscription(params, opts \\ [])

@spec create_subscription(
  map(),
  keyword()
) :: {:ok, map()} | {:error, Lithic.Error.t()}

delete_subscription(event_subscription_token, opts \\ [])

@spec delete_subscription(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Lithic.Error.t()}

get_event(event_token, opts \\ [])

@spec get_event(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Lithic.Error.t()}

get_subscription(event_subscription_token, opts \\ [])

@spec get_subscription(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Lithic.Error.t()}

get_subscription_secret(event_subscription_token, opts \\ [])

@spec get_subscription_secret(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Lithic.Error.t()}

list_events(opts \\ [])

@spec list_events(keyword()) ::
  {:ok, Lithic.Page.t(map())} | {:error, Lithic.Error.t()}

list_message_attempts_for_event(event_token, opts \\ [])

@spec list_message_attempts_for_event(
  String.t(),
  keyword()
) :: {:ok, Lithic.Page.t(map())} | {:error, Lithic.Error.t()}

list_message_attempts_for_subscription(event_subscription_token, opts \\ [])

@spec list_message_attempts_for_subscription(
  String.t(),
  keyword()
) :: {:ok, Lithic.Page.t(map())} | {:error, Lithic.Error.t()}

list_subscriptions(opts \\ [])

@spec list_subscriptions(keyword()) ::
  {:ok, Lithic.Page.t(map())} | {:error, Lithic.Error.t()}

replay_missing(event_subscription_token, opts \\ [])

@spec replay_missing(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Lithic.Error.t()}

Replay all failed/missing messages to a subscription.

resend_event(event_token, event_subscription_token, opts \\ [])

@spec resend_event(String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Lithic.Error.t()}

Resend a specific event to a subscription.

resend_failed(event_subscription_token, opts \\ [])

@spec resend_failed(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Lithic.Error.t()}

Resend failed message attempts for a subscription.

rotate_subscription_secret(event_subscription_token, opts \\ [])

@spec rotate_subscription_secret(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Lithic.Error.t()}

send_example(event_subscription_token, event_type, opts \\ [])

@spec send_example(String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Lithic.Error.t()}

Send an example event of a given type to a subscription (for testing).

stream_events(opts \\ [])

@spec stream_events(keyword()) :: Enumerable.t()

update_subscription(event_subscription_token, params, opts \\ [])

@spec update_subscription(String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, Lithic.Error.t()}