# `Noizu.Comms.Config`
[🔗](https://github.com/noizu-labs-sdks/elixir-comms/blob/main/lib/lib/noizu/comms/config.ex#L1)

Targets file: named aliases and webhook env-var indirection.

Loaded from `COMMS_TARGETS_FILE` (default `~/.config/noizu-comms/targets.yaml`;
precedence: `load/1` `:file` opt > app env `:noizu_comms, :targets_file` >
env var > default).

    targets:
      ops-alerts:   { uri: "discord://channel/123456789012345678", allow_write: true }
      releases:     { uri: "slack://channel/C0123456", allow_write: true }
      keith-phone:  { uri: "whatsapp://15551234567", allow_write: false }
    webhooks:        # alias -> env var NAME holding the URL (never the URL itself)
      discord:
        deploys: DISCORD_WEBHOOK_DEPLOYS

Token env vars (`DISCORD_BOT_TOKEN`, `SLACK_BOT_TOKEN`, `TELEGRAM_BOT_TOKEN`,
`WHATSAPP_ACCESS_TOKEN`, `WHATSAPP_PHONE_NUMBER_ID`) belong to the SDKs and
are never stored in the targets file.

# `t`

```elixir
@type t() :: %Noizu.Comms.Config{
  path: String.t() | nil,
  targets: %{required(String.t()) =&gt; target_entry()},
  webhooks: %{required(String.t()) =&gt; %{required(String.t()) =&gt; String.t()}}
}
```

# `target_entry`

```elixir
@type target_entry() :: %{uri: String.t(), allow_write: boolean()}
```

# `empty`

```elixir
@spec empty() :: t()
```

An empty config (used when the targets file is absent/unreadable).

# `load`

```elixir
@spec load(keyword()) :: {:ok, t()} | {:error, Noizu.Comms.Error.t()}
```

Loads and parses the targets YAML. A missing file is an error here —

# `lookup`

```elixir
@spec lookup(t(), String.t()) ::
  {:ok, target_entry()} | {:error, Noizu.Comms.Error.t()}
```

Looks up an alias -> `{:ok, entry}` or `{:error, %Error{kind: :not_configured}}`.

# `targets_file`

```elixir
@spec targets_file(keyword()) :: String.t()
```

Targets file path (see precedence in the moduledoc).

# `webhook_url`

```elixir
@spec webhook_url(t() | nil, atom(), String.t()) ::
  {:ok, String.t()} | {:error, Noizu.Comms.Error.t()}
```

Resolves a webhook URL for `channel` + `alias`. The config stores the env
var NAME; the URL itself is read from the environment at call time.

---

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