# AccountPush

> AccountPush: the browsers that show the signed-in person NoClick's notifications (Web Push).

## noclick.AccountPush

```python
class AccountPush
```

The browsers that show the signed-in person NoClick's notifications: a DM or @mention of them in a space, a
question or approval that needs them, and work that finished while they weren't watching. Turned on in a browser
from the person's own tap, and off there. The signed-in person's alone, in their own browser: any other caller
raises `noclick.PermissionDenied`.

| Attribute | Type | Description |
| --- | --- | --- |
| `configured` | `bool` |  |
| `public_key` | `str | None` |  |
| `devices` | `list[PushDevice]` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

### AccountPush.get

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

Read the browsers that show the person's notifications.

Parameters:

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

Returns: `AccountPush` The browsers (`devices`), whether this NoClick sends notifications to browsers (`configured`) and the
key a new one subscribes with (`public_key`).

Usage:

```python
push = noclick.AccountPush.get()
print([d.device for d in push.devices])
```

### AccountPush.add

```python
noclick.AccountPush.add(subscription, *, device=None, client=None) -> PushDevice
```

Turn notifications on in a browser, with its push subscription (`endpoint` and `keys`, as the browser's
`PushSubscription.toJSON()` gives them): the same browser again is updated, never added twice.

Parameters:

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

Returns: `PushDevice` The browser, as it's kept.

Usage:

```python
added = noclick.AccountPush.add(subscription, device="iPhone")
```

### AccountPush.remove

```python
noclick.AccountPush.remove(device_id, *, client=None) -> None
```

Turn notifications off in one browser.

Parameters:

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

Returns: Nothing.

Usage:

```python
noclick.AccountPush.remove(added.id)
```

## noclick.PushDevice

```python
class PushDevice
```

One browser that shows the person's notifications, as its push service names it (`endpoint`).

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `device` | `str | None` |  |
| `endpoint` | `str` |  |
| `created_at` | `datetime | None` |  |
| `last_sent_at` | `datetime | None` |  |
