Skip to main content
zerotal

Documentation


Documentation / @zerotal/notifications / Notifiable

Interface: Notifiable

Defined in: notifications/src/Notifiable.ts:50

A model composed with the Notifiable mixin. Declared here so Notifiable is both a value (the mixin) and a type (the contract) — it merges with the function above. Extends the base notifiable contract, so instances pass anywhere a notifiable is expected.

Extends

  • Notifiable

Properties

id

id: string | number

Defined in: notifications/src/types.ts:3

Inherited from

NotifiableContract.id


email?

optional email?: string

Defined in: notifications/src/types.ts:4

Inherited from

NotifiableContract.email


name?

optional name?: string

Defined in: notifications/src/types.ts:5

Inherited from

NotifiableContract.name


phone?

optional phone?: string

Defined in: notifications/src/types.ts:7

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

Inherited from

NotifiableContract.phone

Methods

receivesBroadcastNotificationsOn()?

optional receivesBroadcastNotificationsOn(): string

Defined in: notifications/src/types.ts:12

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

Returns

string

Inherited from

NotifiableContract.receivesBroadcastNotificationsOn


routeNotificationFor()?

optional routeNotificationFor(channel): string | undefined

Defined in: notifications/src/types.ts:26

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

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

Inherited from

NotifiableContract.routeNotificationFor