# AccountPhones

> AccountPhones: the phone numbers your account's owner messages and calls NoClick from, each proven theirs.

## noclick.AccountPhones

```python
class AccountPhones
```

The numbers linked to your account. A linked number reaches the account: texts and calls from it go to its
owner's NoClick, and the web's phone sign-in signs in to the account with it. So these are the signed-in owner's,
or a key of your account's own that names the `account:phones` scope (a key with `*` doesn't hold it unless
it's named too); any other caller raises `noclick.PermissionDenied`. Refusals carry their kind in
`error.details["reason"]` (`invalid_code`, `expired`, `already_linked`, `linked_elsewhere`,
`last_way_in`, ...).

| Attribute | Type | Description |
| --- | --- | --- |
| `configured` | `bool` |  |
| `max_phones` | `int` |  |
| `phones` | `list[LinkedPhone]` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

### AccountPhones.get

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

Read the numbers linked to the account.

Parameters:

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

Returns: `AccountPhones` The linked numbers (`phones`), whether this NoClick sends codes to link one (`configured`) and how
many an account may link (`max_phones`).

Usage:

```python
linked = noclick.AccountPhones.get()
print([p.phone for p in linked.phones])
```

### AccountPhones.link

```python
noclick.AccountPhones.link(phone, *, client=None) -> PhoneChallenge
```

Text a code to `phone` (with its country code, like `+14155550123`) to link it.

Parameters:

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

Returns: `PhoneChallenge` The challenge the code is checked against with `AccountPhones.verify`, within ten minutes.

Usage:

```python
challenge = noclick.AccountPhones.link("+14155550123")
```

### AccountPhones.verify

```python
noclick.AccountPhones.verify(challenge_id, code, *, client=None) -> LinkedPhone
```

Link the challenge's number with the code texted to it. A wrong code raises `noclick.InvalidRequest`
(`reason` `invalid_code`) and can be tried again; an expired challenge (`noclick.Expired`) or too many
tries (`noclick.RateLimited`) needs a new code.

Parameters:

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

Returns: `LinkedPhone` The number, linked: proven by a code (`source` `verify`), and when.

Usage:

```python
noclick.AccountPhones.verify(challenge.id, "123456")
```

### AccountPhones.unlink

```python
noclick.AccountPhones.unlink(phone, *, client=None) -> None
```

Unlink a number: texts and calls from it no longer reach the account, at once. The only number of an
account with no email raises `noclick.Conflict` (`reason` `last_way_in`).

Parameters:

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

Usage:

```python
noclick.AccountPhones.unlink("+14155550123")
```

## noclick.LinkedPhone

```python
class LinkedPhone
```

One number linked to the account: how it was proven (`verify`, a code texted to it; `whatsapp` or
`imessage`, it texted NoClick) and when.

| Attribute | Type | Description |
| --- | --- | --- |
| `phone` | `str` |  |
| `source` | `str` |  |
| `verified_at` | `datetime | None` |  |

## noclick.PhoneChallenge

```python
class PhoneChallenge
```

A code texted to a number to link it: check it with `AccountPhones.verify` before `expires_at`.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `phone` | `str` |  |
| `expires_at` | `datetime | None` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
