ExPlain.Events (ExPlain v0.3.0)

Copy Markdown View Source

Operations for creating custom timeline events in Plain.

Summary

Functions

Creates a custom event on a customer's timeline.

Creates a custom event on a thread's timeline.

Functions

create_customer_event(client, input)

@spec create_customer_event(ExPlain.Client.t(), map()) ::
  {:ok, ExPlain.Events.CustomerEvent.t()} | {:error, ExPlain.Error.t()}

Creates a custom event on a customer's timeline.

The input map must include :customer_identifier, :title, and :components.

Example

ExPlain.Events.create_customer_event(client, %{
  customer_identifier: %{customer_id: "c_01HX..."},
  title: "Subscription upgraded",
  components: [ExPlain.Components.text("Upgraded from Free to Pro")]
})

create_thread_event(client, input)

@spec create_thread_event(ExPlain.Client.t(), map()) ::
  {:ok, ExPlain.Events.ThreadEvent.t()} | {:error, ExPlain.Error.t()}

Creates a custom event on a thread's timeline.

The input map must include :thread_id, :title, and :components.

Example

ExPlain.Events.create_thread_event(client, %{
  thread_id: "th_01HX...",
  title: "Webhook sent",
  components: [ExPlain.Components.text("Payload delivered to https://example.com")]
})