# `ExWapp.Message`
[🔗](https://github.com/elchemista/ex_wapp/blob/v0.1.5/lib/ex_wapp/message/message.ex#L1)

User-facing WhatsApp message struct.

This is the high-level value applications pass to ExWapp, similar to how an
email library exposes a mail struct instead of making users call MIME builders
directly.

# `message_type`

```elixir
@type message_type() ::
  :text
  | :typing
  | :read_receipt
  | :image
  | :audio
  | :document
  | :location
  | :contact
  | :event
  | atom()
```

High-level message categories supported by the public API.

# `t`

```elixir
@type t() :: %ExWapp.Message{
  body: term(),
  id: String.t() | nil,
  metadata: map(),
  opts: keyword(),
  to: String.t(),
  type: message_type()
}
```

Runtime-neutral message value passed into transport adapters.

# `audio`

```elixir
@spec audio(String.t(), ExWapp.Media.source(), keyword()) :: t()
```

Builds an audio message from bytes, a filesystem path, or a pre-uploaded reference.

# `contact`

```elixir
@spec contact(String.t(), String.t(), String.t(), keyword()) :: t()
```

Builds a single WhatsApp contact card message.

`vcard` must contain the complete vCard payload (normally vCard 3.0).

# `document`

```elixir
@spec document(String.t(), ExWapp.Media.source(), keyword()) :: t()
```

Builds a document message from bytes, a filesystem path, or a pre-uploaded reference.

# `event`

```elixir
@spec event(String.t(), String.t(), integer() | DateTime.t(), keyword()) :: t()
```

Builds a WhatsApp calendar event message.

This message type exists in WhatsApp Web but is less stable than text,
media, location, and contact messages. `start_time` may be a Unix timestamp
in seconds or a `DateTime`.

# `image`

```elixir
@spec image(String.t(), ExWapp.Media.source(), keyword()) :: t()
```

Builds an image message from bytes, a filesystem path, or a pre-uploaded reference.

# `location`

```elixir
@spec location(String.t(), number(), number(), keyword()) :: t()
```

Builds a static GPS location message.

Latitude and longitude are encoded as protobuf doubles. Optional fields such
as `:name`, `:address`, `:url`, `:comment`, and `:accuracy` are kept in
`opts` until the session transport builds the wire payload.

# `read_receipt`

```elixir
@spec read_receipt(String.t(), [String.t()], keyword()) :: t()
```

Builds a read receipt message for one or more message IDs.

# `text`

```elixir
@spec text(String.t(), iodata(), keyword()) :: t()
```

Builds a plain text message.

This is the simplest outbound message form and maps to WhatsApp's
`conversation` or `extendedTextMessage` protobuf fields depending on options.

# `typing`

```elixir
@spec typing(String.t(), boolean(), keyword()) :: t()
```

Builds a typing indicator message.

The boolean body is interpreted as `true => composing` and `false => paused`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
