# Notifications

> Notifications: the email alerts NoClick sends your account's owner, one switch for each kind.

## noclick.Notifications

```python
class Notifications
```

Which kinds of email alert NoClick sends your account's owner: `categories` maps each kind
(`run_failure`, `credits`, `spend_cap`, `digest`, ...) to whether it's on. A kind never
turned off is on. They're what Settings → Notifications in the NoClick app shows, and every alert
email carries a one-click link that turns its own kind off.

| Attribute | Type | Description |
| --- | --- | --- |
| `categories` | `dict[str, bool]` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

### Notifications.get

```python
noclick.Notifications.get(*, client=None) -> Notifications
```

Read which kinds of email alert your account's owner gets. Any of your account's own keys may,
but one held to one of your users, which raises `noclick.PermissionDenied`: they're the owner's.

Parameters:

- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Notifications` Every kind NoClick sends, each `True` (on) or `False` (off).

Usage:

```python
alerts = noclick.Notifications.get()
print(alerts.categories["digest"])   # True until it's turned off
off = [kind for kind, on in alerts.categories.items() if not on]
```

### Notifications.update

```python
noclick.Notifications.update(categories, *, client=None) -> Notifications
```

Turn kinds of email alert to your account's owner on (`True`) or off (`False`), in one
change; a kind you leave out stays as it is. A kind NoClick doesn't send, or a value that isn't
`True` or `False`, raises `noclick.InvalidRequest` and changes nothing.

Parameters:

- `categories` (`Mapping[str, bool]`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Notifications` Every kind, as it stands after the change.

Usage:

```python
noclick.Notifications.update({"digest": False, "run_failure": True})
```
