ExWapp.Message.Content (ExWapp v0.1.2)

Copy Markdown View Source

Canonical content contract for inbound WhatsApp messages.

The struct is intentionally independent from transport and Signal details. Legacy message-map fields remain available at the publishing boundary while wrappers can consume this single typed value.

Summary

Functions

Adapts an already-normalized legacy message map to the canonical contract.

Builds a canonical content value from one supported kind and its fields.

Converts canonical content to the existing message-map fields.

Types

kind()

@type kind() ::
  :text | :media | :location | :contact | :event | :protocol | :unsupported

t()

@type t() :: %ExWapp.Message.Content{
  contact: map() | nil,
  diagnostics: map(),
  event: map() | nil,
  kind: kind(),
  location: map() | nil,
  media: ExWapp.Media.Ref.t() | nil,
  media_type: atom() | nil,
  protocol_payload: binary() | nil,
  text: binary() | nil
}

Functions

from_legacy(message_data)

@spec from_legacy(map()) :: t()

Adapts an already-normalized legacy message map to the canonical contract.

new(kind, attrs \\ [])

@spec new(
  kind(),
  keyword()
) :: t()

Builds a canonical content value from one supported kind and its fields.

to_legacy(content)

@spec to_legacy(t()) :: map()

Converts canonical content to the existing message-map fields.