# Referral

> Your account's invite link: each person who joins NoClick through it, and starts using it, adds `reward_usd` to your balance. A user of your account has none of its own.

## noclick.Referral

```python
class Referral
```

Your account's invite link and what it has earned.

| Attribute | Type | Description |
| --- | --- | --- |
| `code` | `str` |  |
| `url` | `str` |  |
| `share_text` | `str` | What a friend reads, then the link. |
| `reward_usd` | `float` | What each friend who starts using NoClick adds to your balance. |
| `joined` | `int` | How many joined through it. |
| `earned` | `int` | How many of them earned the reward, and what it came to. |
| `earned_usd` | `float` |  |
| `joined_through` | `dict[str, Any] | None` | Whose link your account joined through (`{"name", "channel"}`), if it did. |
| `can_apply_until` | `Any` | Until when your account can still apply an invite code (a day after it joined, once); `None` once it can't. |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

### Referral.get

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

Your account's invite link, how many joined and earned through it, and whose link your account joined
through.

Parameters:

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

Returns: `Referral` The link (`url`), the line to send it with (`share_text`) and what it has earned.

Usage:

```python
referral = noclick.Referral.get()
print(referral.share_text, referral.joined, referral.earned_usd)
```

### Referral.apply

```python
noclick.Referral.apply(code, *, client=None) -> Referral
```

Apply a friend's invite `code` (or their join link) to your account, as the person they invited: only
within a day of your account's creation, and once. An unknown code raises `noclick.NotFound`; a second one
`noclick.Conflict`.

Parameters:

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

Returns: `Referral` Your account's invite link, now naming whose link it joined through.

Usage:

```python
noclick.Referral.apply("ana-k3x9")
```
