# `WardrikSlack.API`

Calls Slack's Web API.

Each call merges in the channel's `:req_options`, so tests can point it at `Req.Test`.
Rate-limited, 5xx and dropped requests are retried up to five times, with backoff or as long as
Slack says to wait.

# `call`

```elixir
@spec call(String.t(), keyword()) :: {:ok, map()} | {:error, term()}
```

Calls `method` with `Req` options.

Returns `{:ok, reply}` when Slack answers `"ok": true`, `{:error, error}` with Slack's `error`,
`{:error, {:status, status}}` for any other status, or Req's error.

# `post`

```elixir
@spec post(String.t(), String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Calls `method` with `body` as JSON. Returns Slack's reply, or its `error`.

# `post_in`

```elixir
@spec post_in(WardrikChannel.Workspace.t(), String.t(), map()) ::
  {:ok, map()} | {:error, term()}
```

Like `post/4`, with the bot token and `:req_options` of `workspace`.

# `read`

```elixir
@spec read(String.t(), String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Calls `method` with `params` as a form, as Slack's read methods expect. Drops `nil` params.

# `read_in`

```elixir
@spec read_in(WardrikChannel.Workspace.t(), String.t(), map()) ::
  {:ok, map()} | {:error, term()}
```

Like `read/4`, with the bot token and `:req_options` of `workspace`.

# `req_options`

```elixir
@spec req_options(WardrikChannel.Channel.t()) :: keyword()
```

Returns the channel's `:req_options`. `[]` unless set.

# `respond`

```elixir
@spec respond(String.t() | nil, map(), keyword()) :: :ok
```

Posts `reply` to a button press's `response_url`.

The reply replaces the message, or is shown only to the person who pressed. Always returns `:ok`.
A failure is logged, since the press was already acted on.

---

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