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

Internal facade for the built-in WhatsApp session engine.

The GenServer implementation lives in `ExWapp.Session.Worker`. This module is
used by `ExWapp.Client.Transport.Session`; it is documented for maintainers
and custom transport authors, but it is not part of ExWapp's stable public
API. Applications should use the `%ExWapp.Client{}` API through `ExWapp`.

# `qr_event`

```elixir
@type qr_event() ::
  {:code, String.t()}
  | {:pairing_code, String.t()}
  | :success
  | {:error, term()}
```

Human readable events emitted during the pairing flow.

# `status`

```elixir
@type status() ::
  :idle | :connecting | :handshaking | :syncing | :connected | :disconnected
```

Session status

# `t`

```elixir
@opaque t()
```

# `archive_chat`

```elixir
@spec archive_chat(GenServer.server(), String.t()) :: :ok | {:error, term()}
```

# `child_spec`

```elixir
@spec child_spec(term()) :: Supervisor.child_spec()
```

# `connect`

```elixir
@spec connect(GenServer.server()) :: :ok
```

# `create_contact`

```elixir
@spec create_contact(GenServer.server(), String.t(), String.t()) ::
  :ok | {:error, term()}
```

# `delete_chat`

```elixir
@spec delete_chat(GenServer.server(), String.t()) :: :ok | {:error, term()}
```

# `delete_contact`

```elixir
@spec delete_contact(GenServer.server(), String.t()) :: :ok | {:error, term()}
```

# `disconnect`

```elixir
@spec disconnect(GenServer.server()) :: :ok
```

# `download_media`

```elixir
@spec download_media(GenServer.server(), ExWapp.Media.Ref.t(), keyword()) ::
  {:ok, ExWapp.Media.Download.t()} | {:error, term()}
```

# `export_snapshot`

```elixir
@spec export_snapshot(GenServer.server()) :: {:ok, map()} | {:error, term()}
```

Flushes the session store and exports its complete local snapshot.

The result includes decoded `:data`, the serialized `:blob`, and a SHA-256
`:checksum`. This is useful for backups or wrapper-level database imports.
It reflects local state only and does not request additional server history.

# `flush_store`

```elixir
@spec flush_store(GenServer.server()) :: :ok | {:error, term()}
```

# `get_chat_info`

```elixir
@spec get_chat_info(GenServer.server(), String.t()) ::
  {:ok, ExWapp.Chat.chat()} | {:error, :not_found}
```

# `get_contact`

```elixir
@spec get_contact(GenServer.server(), String.t()) :: ExWapp.Contact.t() | nil
```

Gets one contact from the session store, or `nil` when it is unknown.

# `get_session_id`

```elixir
@spec get_session_id(GenServer.server()) :: term() | nil
```

# `health_status`

```elixir
@spec health_status(GenServer.server()) :: map()
```

# `list_contacts`

```elixir
@spec list_contacts(GenServer.server()) :: [ExWapp.Contact.t()]
```

Lists contacts currently present in the session store.

# `message_stream`

```elixir
@spec message_stream(GenServer.server()) :: Enumerable.t()
```

# `pause_sends`

```elixir
@spec pause_sends(GenServer.server()) :: :ok
```

# `policy_status`

```elixir
@spec policy_status(GenServer.server()) :: map()
```

# `qr_stream`

```elixir
@spec qr_stream(GenServer.server()) :: Enumerable.t()
```

# `request_pairing_code`

```elixir
@spec request_pairing_code(GenServer.server(), String.t(), keyword()) ::
  {:ok, String.t()} | {:error, term()}
```

Requests an eight-character phone-number pairing code.

Call this after `connect/1`, once the Noise transport has entered the
handshaking state. `:custom_code` may be supplied and must contain exactly
eight bytes.

# `resume_sends`

```elixir
@spec resume_sends(GenServer.server()) :: :ok
```

# `retry_media`

```elixir
@spec retry_media(GenServer.server(), String.t(), keyword()) ::
  {:ok, ExWapp.Media.Ref.t()} | {:error, term()}
```

Asks the sender's phone to re-upload an expired media object.

The message must still exist in the local message store so its media key and
conversation envelope can be authenticated on the wire.

# `runtime_config`

```elixir
@spec runtime_config(GenServer.server()) :: map()
```

# `send_app_state`

```elixir
@spec send_app_state(GenServer.server(), map()) ::
  {:ok, map(), map()} | {:error, term()}
```

# `send_audio`

```elixir
@spec send_audio(GenServer.server(), binary(), ExWapp.Media.source(), keyword()) ::
  {:ok, String.t()} | {:error, term()}
```

# `send_contact`

```elixir
@spec send_contact(GenServer.server(), binary(), String.t(), String.t(), keyword()) ::
  {:ok, String.t()} | {:error, term()}
```

# `send_document`

```elixir
@spec send_document(GenServer.server(), binary(), ExWapp.Media.source(), keyword()) ::
  {:ok, String.t()} | {:error, term()}
```

# `send_event`

```elixir
@spec send_event(
  GenServer.server(),
  binary(),
  String.t(),
  integer() | DateTime.t(),
  keyword()
) :: {:ok, String.t()} | {:error, term()}
```

# `send_image`

```elixir
@spec send_image(GenServer.server(), binary(), ExWapp.Media.source(), keyword()) ::
  {:ok, String.t()} | {:error, term()}
```

# `send_location`

```elixir
@spec send_location(GenServer.server(), binary(), number(), number(), keyword()) ::
  {:ok, String.t()} | {:error, term()}
```

# `send_message`

```elixir
@spec send_message(GenServer.server(), ExWapp.Message.t()) ::
  {:ok, String.t()} | {:error, term()}
```

Sends a canonical outbound message through the session engine.

The message ID, when present, is preserved through encryption and transport.

# `send_text`

```elixir
@spec send_text(GenServer.server(), binary(), iodata(), keyword()) ::
  {:ok, String.t()} | {:error, term()}
```

# `send_typing`

```elixir
@spec send_typing(GenServer.server(), binary(), boolean()) :: :ok | {:error, term()}
```

# `start_link`

```elixir
@spec start_link(keyword() | ExWapp.Session.Options.t()) :: GenServer.on_start()
```

# `state`

```elixir
@spec state(GenServer.server()) :: status()
```

# `stats`

```elixir
@spec stats(GenServer.server()) :: map()
```

# `stop_worker`

```elixir
@spec stop_worker(GenServer.server()) :: :ok
```

# `subscribe_qr`

```elixir
@spec subscribe_qr(GenServer.server()) :: {:ok, reference()}
```

# `sync_contacts`

```elixir
@spec sync_contacts(GenServer.server()) :: :ok | {:error, term()}
```

Refreshes contact-related app-state data from the server.

This operation updates contacts only; it does not request complete chat
history.

# `unarchive_chat`

```elixir
@spec unarchive_chat(GenServer.server(), String.t()) :: :ok | {:error, term()}
```

# `unsubscribe_qr`

```elixir
@spec unsubscribe_qr(GenServer.server(), reference()) :: :ok
```

---

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