# `WardrikChannel.Channel`

One chat app Wardrik runs, under the name it's given.

Holds the adapter, the adapter's own options, and the installations that say where it's added.
Wardrik passes it the rest:

  * `:server` - the `Wardrik.Server` that runs operations.
  * `:wardrik` - the instance.
  * `:events` - where events are followed and recorded.
  * `:store` - Wardrik's store.
  * `:vault` - where tokens are sealed. `nil` without Wardrik's `:keys`.

# `t`

```elixir
@type t() :: %WardrikChannel.Channel{
  adapter: module(),
  approvers: [String.t()] | :anyone,
  deciding: String.t(),
  events: atom(),
  installations: {module(), term()},
  name: String.t(),
  offering: String.t(),
  options: keyword(),
  server: module(),
  store: WardrikStore.t(),
  vault: atom() | nil,
  wardrik: atom()
}
```

# `install`

```elixir
@spec install(t(), Wardrik.Channel.Installation.t()) :: :ok | {:error, String.t()}
```

Saves `installation`, replacing any for the same workspace.

# `installation`

```elixir
@spec installation(t(), String.t()) ::
  {:ok, Wardrik.Channel.Installation.t()} | :error
```

Returns the channel's installation in `workspace`, as the chat app names it.

# `nearest`

```elixir
@spec nearest(t(), String.t()) :: {:ok, Wardrik.Channel.Installation.t()} | :error
```

Returns the installation nearest the owner of agent `id`.

Looks first for one owned by the user, as `acme/@jon`, then by the org, as `acme`. Returns
`:error` if there's neither.

# `new`

```elixir
@spec new(module(), keyword()) :: t()
```

Builds `adapter`'s channel from the options Wardrik passes it. See `WardrikChannel` for the
options.

Raises `ArgumentError` if the name isn't lower-case letters, digits and `-`, starting with a
letter, or if the options give neither or both of `:token` and `:installations`.

# `uninstall`

```elixir
@spec uninstall(t(), String.t()) :: :ok
```

Forgets the channel's installation in `workspace`.

---

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