# `Alternera.Plugins.AnypointMq.Wire`
[🔗](https://github.com/10e-ab/alternera-anypoint-mq/blob/v0.9.0/lib/alternera/plugins/anypoint_mq/wire.ex#L1)

What the Anypoint MQ step (`AnypointMq.Broker`) and the Anypoint MQ
source (`AnypointMq.Source`) share about the broker's REST API: the
broker URL's check, a path segment's encoding and limit, the token of the
tenant's auth profile for a call (`Plugin.Provisional.Credentials`), and
reading and decoding the broker's answers.

# `body_text`

```elixir
@spec body_text(term()) :: binary()
```

A received message's body as text: the JSON of one the broker sent as a value.

# `check_url`

```elixir
@spec check_url(String.t()) :: {:ok, String.t()} | {:error, String.t()}
```

`url` as a broker URL: `http` or `https`, a host, no query or fragment,
without a trailing `/`; `{:error, message}` otherwise.

# `decode`

```elixir
@spec decode(binary()) :: {:ok, term()} | {:error, String.t()}
```

An answer's text as JSON: `{:ok, nil}` when empty, `{:error, message}`
(a fragment after "the broker's answer to …") when it is not JSON.

# `encode`

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

`value` as one URL path segment.

# `integer`

```elixir
@spec integer(term()) :: integer() | nil
```

An integer, or one written as text; nil otherwise.

# `max_segment`

```elixir
@spec max_segment() :: pos_integer()
```

The longest a value that goes into the URL as one path segment may be, in bytes.

# `read_body`

```elixir
@spec read_body(term()) :: binary()
```

An answer's body read whole and released.

# `receive_cap`

```elixir
@spec receive_cap() :: pos_integer()
```

The most bytes of a receive's answer a call reads (`Outbound.call/3`'s
`cap`), whatever the batch: room for one of the broker's largest
messages, escaped, about 30 MiB, more than the 16 MiB default
(`Outbound.max_response_bytes/0`). A batch whose answer is larger fails
`response_too_large`: a source trigger then asks for fewer messages,
a consume step's author lowers its `batch_size`. Sized for the batch
instead, ten messages would be read whole at about 300 MiB.

# `settleable?`

```elixir
@spec settleable?(term()) :: boolean()
```

Whether a received entry can be settled: an object whose `headers` carry
its `messageId` and its `lockId`.

# `shown`

```elixir
@spec shown(term()) :: String.t()
```

The start of an answer's text for a message, after a `: `; empty when there is none.

# `stringy`

```elixir
@spec stringy(term()) :: map()
```

A map's keys as text; an empty map for anything else.

# `token`

```elixir
@spec token(map(), String.t(), String.t() | nil) ::
  {:ok, String.t(), non_neg_integer()} | {:error, String.t(), non_neg_integer()}
```

The `Authorization` value of the tenant's auth profile for a call to
`url` (`Credentials.for_call/3`), `renew` the value a first call was
answered `401` with (nil for a first call): `{:ok, value, outbound_us}`,
or `{:error, message, outbound_us}` naming what to set up.

---

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