[**Documentation**](../../../README)

***

[Documentation](../../../README) / [@zerotal/notifications](../README) / OnDemandNotifiable

# Class: OnDemandNotifiable

Defined in: [notifications/src/OnDemandNotifiable.ts:26](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/OnDemandNotifiable.ts#L26)

A recipient addressed directly rather than looked up — `Notify.route({ mail:
"ops@acme.test" })`.

It satisfies `Notifiable` without being a model, so every channel works
unchanged. The `database` channel is the exception worth knowing about: rows
it writes are keyed to a random id nothing can query back, which is why an
on-demand notification normally declares only transport channels.

## Implements

- `Notifiable`

## Constructors

### Constructor

> **new OnDemandNotifiable**(`_routes`): `OnDemandNotifiable`

Defined in: [notifications/src/OnDemandNotifiable.ts:31](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/OnDemandNotifiable.ts#L31)

#### Parameters

##### \_routes

[`OnDemandRoutes`](../interfaces/OnDemandRoutes)

#### Returns

`OnDemandNotifiable`

## Properties

### id

> `readonly` **id**: `string`

Defined in: [notifications/src/OnDemandNotifiable.ts:27](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/OnDemandNotifiable.ts#L27)

#### Implementation of

`Notifiable.id`

***

### email?

> `readonly` `optional` **email?**: `string`

Defined in: [notifications/src/OnDemandNotifiable.ts:28](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/OnDemandNotifiable.ts#L28)

#### Implementation of

`Notifiable.email`

***

### phone?

> `readonly` `optional` **phone?**: `string`

Defined in: [notifications/src/OnDemandNotifiable.ts:29](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/OnDemandNotifiable.ts#L29)

Phone number in E.164 format, required when using the sms channel.

#### Implementation of

`Notifiable.phone`

## Methods

### routeNotificationFor()

> **routeNotificationFor**(`channel`): `string` \| `undefined`

Defined in: [notifications/src/OnDemandNotifiable.ts:39](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/OnDemandNotifiable.ts#L39)

Per-channel destination override, consulted before the default field.

Return the address a channel should deliver to — an email for `"mail"`, an
E.164 number for `"sms"`, a webhook URL for `"slack"` — or `undefined` to
fall back. Lets one model route differently per channel without every
notification having to know how.

#### Parameters

##### channel

`string`

#### Returns

`string` \| `undefined`

#### Example

```ts
routeNotificationFor(channel: string) {
  return channel === "mail" ? this.billingEmail : undefined;
}
```

#### Implementation of

`Notifiable.routeNotificationFor`

***

### receivesBroadcastNotificationsOn()

> **receivesBroadcastNotificationsOn**(): `string`

Defined in: [notifications/src/OnDemandNotifiable.ts:43](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/OnDemandNotifiable.ts#L43)

Override the channel this notifiable receives broadcast notifications on.
Default: `notifications.{id}` (broadcast as a private channel). Used by the 'broadcast' channel.

#### Returns

`string`

#### Implementation of

`Notifiable.receivesBroadcastNotificationsOn`
