# `Ussd.Context`
[🔗](https://github.com/spesohq/ussd/blob/main/lib/ussd/context.ex#L1)

The per-request context for a USSD interaction: who is dialing in (`uid`), which
group/session the request belongs to (`gid`), what they typed (`input`), and any
extra values the caller wants states/actions to see (`bag`).

# `t`

```elixir
@type t() :: %Ussd.Context{
  bag: map(),
  gid: String.t(),
  input: String.t(),
  uid: String.t()
}
```

# `get`

```elixir
@spec get(t(), term()) :: term()
```

Reads a value out of the bag set via `with_bag/2`, or `nil` if `key` isn't present.

# `gid`

```elixir
@spec gid(t()) :: String.t()
```

The identifier shared across a caller's redials (typically their phone number).

# `input`

```elixir
@spec input(t()) :: String.t()
```

What the caller typed for this request. An empty string on the very first request of a session.

# `new`

```elixir
@spec new(String.t(), String.t(), String.t()) :: t()
```

Builds a new context. Raises if `uid` or `gid` is empty, mirroring the guarantees
callers need: every session must be uniquely and group-addressable.

# `uid`

```elixir
@spec uid(t()) :: String.t()
```

The unique identifier for this specific dial-in (changes on every redial).

# `with_bag`

```elixir
@spec with_bag(t(), map()) :: t()
```

Attaches arbitrary extra values (e.g. the phone's network, a request header) that
`render/1`, `c:Ussd.Action.execute/1` and `transition`/`back`/`paginate` callbacks
can read back via `get/2`. Replaces any bag set previously - it isn't merged.

---

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