# Brand

> Brand: how your product appears on the pages and emails NoClick sends for you, and the OAuth apps your users connect with.

## noclick.Brand

```python
class Brand
```

One per account; rendered on `/h/` pages and human emails. `oauth_apps` names your
own OAuth app per provider, as `{provider: secret id}`. `oauth_redirect_urls` has the
redirect URI to register with your app at every provider you can bring one for, as
`{provider: url}`: you need it to create the app, before it is named here.

| Attribute | Type | Description |
| --- | --- | --- |
| `name` | `str | None` |  |
| `logo_url` | `str | None` |  |
| `color` | `str | None` |  |
| `support_url` | `str | None` |  |
| `email_from_name` | `str | None` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
| `is_default` | `bool` | True while nothing is set (the defaults are shown). |
| `domain` | `str | None` | The host your approval, question and hand-off pages are served from; None: NoClick's. |
| `oauth_apps` | `dict[str, str]` |  |
| `oauth_redirect_urls` | `dict[str, str]` |  |

### Brand.reset

```python
noclick.Brand.reset(*, client=None) -> Brand
```

Remove the account's brand: pages and emails go back to the defaults.

Parameters:

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

Returns: `Brand` NoClick's default brand, with `is_default` `True`.

Usage:

```python
brand = noclick.Brand.reset()
print(brand.is_default)   # True
```

### Brand.get

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

Read the account's brand.

Parameters:

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

Returns: `Brand` The brand your pages and emails show now; `is_default` is `True` while you haven't set one.

Usage:

```python
brand = noclick.Brand.get()
print(brand.name, brand.color, brand.is_default)
```

### Brand.set

```python
noclick.Brand.set(
    *, name=None, logo_url=None, color=None, support_url=None, email_from_name=None,
    domain=None, oauth_apps=None, client=None
) -> Brand
```

Replace the account's brand with these fields (`color` as `"#RRGGBB"`, or `"#RGB"`);
a field left out is cleared. To change one field and keep the rest, use `update`.

`oauth_apps` maps a provider (`google`, `slack`, `box`, ...) to an account
`Secret` (or its id or name) holding `CLIENT_ID` and `CLIENT_SECRET` of your own
OAuth app there, so the consent screen your users see names you; register the
provider's `oauth_redirect_urls` entry as the app's redirect URI. Connect links made
after it is set sign in with that app, and each connection keeps the app it was made
with, refreshing on it too: connections made before keep NoClick's until they're
reconnected. A provider NoClick can't sign in to with your own app yet raises
`noclick.InvalidRequest` naming those it can.

`domain` (a `Domain` your account holds, or its name, such as `connect.acme.com`)
serves the approval, question and hand-off pages NoClick shows your users from your own
host, and the emails that bring people there link to it and name only your brand (they come
from NoClick's address under `email_from_name`; connect links stay on NoClick's host for
now). A bought domain gets its CNAME at once; a connected one lists the records to add in
its `records`: the CNAME, and a TXT that proves the name is yours. The domain's
`serves` then includes `brand`. `None` moves the pages back to NoClick's host.

Parameters:

- `name` (`str | None`, default `None`)
- `logo_url` (`str | None`, default `None`)
- `color` (`str | None`, default `None`)
- `support_url` (`str | None`, default `None`)
- `email_from_name` (`str | None`, default `None`)
- `domain` (`Any`, default `None`)
- `oauth_apps` (`Mapping[str, Any] | None`, default `None`)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Brand` The saved brand, with `color` lowercased and `is_default` `False`. A field you left out is now empty.

Usage:

Show your name, logo and colour:

```python
noclick.Brand.set(
    name="Acme",
    logo_url="https://acme.com/logo.png",
    color="#FF5500",
    support_url="https://acme.com/help",
    email_from_name="Acme Support",
)
```

Ask for Google access with your own app. Create it with the redirect URI from
`Brand.get().oauth_redirect_urls["google"]`, put its client id and secret in a
secret, then name it:

```python
noclick.Brand.set(
    name="Acme",
    logo_url="https://acme.com/logo.png",
    oauth_apps={"google": noclick.Secret.from_name("google-oauth-app")},
)
```

Serve the pages from your own host:

```python
noclick.Brand.set(name="Acme", domain="connect.acme.com")
```

### Brand.update

```python
noclick.Brand.update(
    *, name=..., logo_url=..., color=..., support_url=..., email_from_name=...,
    domain=..., oauth_apps=..., client=None
) -> Brand
```

Change only the fields you pass; the rest stay as they are. `None` clears a field.
`set` replaces the whole brand instead. `oauth_apps` changes only the providers it
names (links made after for a provider mapped to `None` sign in with NoClick's app), and
`oauth_apps=None` removes them all. `domain` is as in `set`.
Before you've set a brand, it changes NoClick's default one: the name stays `NoClick`
until you give it yours.

Parameters:

- `name` (`Any`, default: unchanged)
- `logo_url` (`Any`, default: unchanged)
- `color` (`Any`, default: unchanged)
- `support_url` (`Any`, default: unchanged)
- `email_from_name` (`Any`, default: unchanged)
- `domain` (`Any`, default: unchanged)
- `oauth_apps` (`Any`, default: unchanged)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Brand` The saved brand. A field you left out is unchanged.

Usage:

```python
noclick.Brand.update(color="#FF5500")    # the name, logo and the rest are kept
noclick.Brand.update(support_url=None)   # no support link from now on
noclick.Brand.update(oauth_apps={"slack": noclick.Secret.from_name("slack-oauth-app")})   # Google's stays
noclick.Brand.update(oauth_apps={"google": None})   # new Google links use NoClick's app
```
