IafNotification
Use the IafNotification API to create and manage notifications and associated resources
createDevice
Creates a notification device
| Parameter | Required | Type | Description |
|---|---|---|---|
| device | Yes | NotificationDevice | Pass the device to create |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcCreateOptions | Service specific options. |
Promise<NotificationDevice> - Created device
const subscriber =
await IafNotification.createDevice(
{
_owner: {
_irn: "passportsvc:user:myuserid"
},
_transport: "EMAIL",
_address: "test@example.com"
},
ctx
);
createGroup
Creates a notification group
| Parameter | Required | Type | Description |
|---|---|---|---|
| group | Yes | NotificationGroup | Pass the group to create |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcCreateOptions | Service specific options. |
Promise<NotificationGroup> - Created group
const group =
await IafNotification.createGroup(
{
_name: "System",
_description: "System notification group"
_namespaces: project._namespaces
},
ctx
);
createSender
Creates a notification sender
| Parameter | Required | Type | Description |
|---|---|---|---|
| sender | Yes | NotificationSender | Pass the sender to create |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcCreateOptions | Service specific options. |
Promise<NotificationSender> - Created sender
const sender =
await IafNotification.createSender(
{
_name: "System",
_description: "System notification sender"
_namespaces: project._namespaces
},
ctx
);
createSubscription
Creates a notification subscription
| Parameter | Required | Type | Description |
|---|---|---|---|
| subscription | Yes | NotificationSubscription | Pass the subscription to create |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcCreateOptions | Service specific options. |
Promise<NotificationSubscription> - Created subscription
const subscription =
await IafNotification.createSubscription(
{
_namespaces: project._namespaces,
_group: {
_id: "<group id>"
},
_device: {
_id: "<device id>"
}
},
ctx
);
createTemplate
Creates a notification template
| Parameter | Required | Type | Description |
|---|---|---|---|
| template | Yes | NotificationTemplate | Pass the template to create |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcCreateOptions | Service specific options. |
Promise<NotificationTemplate> - Created template
const template =
await IafNotification.createTemplate(
{
_namespaces: project._namespaces,
_transport: "EMAIL",
_format: "VELOCITY",
},
ctx
);
createTrigger
Creates a notification trigger
| Parameter | Required | Type | Description |
|---|---|---|---|
| trigger | Yes | NotificationTrigger | Pass the template to create |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcCreateOptions | Service specific options. |
Promise<NotificationTrigger> - Created trigger
const trigger =
await IafNotification.createTrigger(
{
_namespaces: project._namespaces,
_type: "EVENT"
},
ctx
);
deleteDevice
Deletes a notification device
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the device to delete |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcDeleteOptions | Service specific options. |
await IafNotification.deleteDevice(
deviceId,
ctx
);
deleteGroup
Deletes a notification group
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the group to delete |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcDeleteOptions | Service specific options. |
await IafNotification.deleteGroup(
groupId,
ctx
);
deleteSender
Deletes a notification sender
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the sender to delete |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcDeleteOptions | Service specific options. |
await IafNotification.deleteSender(
senderId,
ctx
);
deleteSubscription
Deletes a notification subscription
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the subscription to delete |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcDeleteOptions | Service specific options. |
await IafNotification.deleteSubscription(
subscriptionId,
ctx
);
deleteTemplate
Deletes a notification template
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the template to delete |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcDeleteOptions | Service specific options. |
await IafNotification.deleteTemplate(
templateId,
ctx
);
deleteTrigger
Deletes a notification trigger
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the trigger to delete |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcDeleteOptions | Service specific options. |
await IafNotification.deleteTrigger(
triggerId,
ctx
);
getDevice
Gets a notification device
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the device to get |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcGetOptions | Service specific options. |
Promise<NotificationDevice> - The subscriber
const subscriber =
await IafNotification.getDevice(
deviceId,
ctx
);
getGroup
Gets a notification group
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the group to get |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcGetOptions | Service specific options. |
Promise<NotificationGroup> - Updated group
const group =
await IafNotification.getGroup(
groupId,
ctx
);
getSender
Gets a notification sender
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the sender to get |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcGetOptions | Service specific options. |
Promise<NotificationSender> - The sender
const sender =
await IafNotification.getSender(
senderId,
ctx
);
getSubscription
Gets a notification subscription
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the subscription to get |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcGetOptions | Service specific options. |
Promise<NotificationSubscription> - The subscription
const subscription =
await IafNotification.getSubscription(
subscriptionId,
ctx
);
getTemplate
Gets a notification template
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the template to get |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcGetOptions | Service specific options. |
Promise<NotificationTemplate> - The template
const template =
await IafNotification.getTemplate(
templateId,
ctx
);
getTrigger
Gets a notification trigger
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the trigger to get |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcGetOptions | Service specific options. |
Promise<NotificationTrigger> - The template
const trigger =
await IafNotification.getTrigger(
triggerId,
ctx
);
listDevices
List notification devices
| Parameter | Required | Type | Description |
|---|---|---|---|
| query | No | NotificationDeviceQuery | The query. |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcListOptions | Service specific options. |
Promise<Page<NotificationDevice>> - Matched devices
const subscribers =
await IafNotification.listDevices(
{
owner: {
irn: "passportsvc:user:myuserid"
},
},
ctx
);
listGroups
List notification groups
| Parameter | Required | Type | Description |
|---|---|---|---|
| query | No | NotificationGroupQuery | The query. |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcListOptions | Service specific options. |
Promise<Page<NotificationGroup>> - Updated group
const groups =
await IafNotification.listGroups(
{
namespaces: ["ns1"]
},
ctx
);
listNotifications
List notification history
| Parameter | Required | Type | Description |
|---|---|---|---|
| query | No | NotificationNotificationQuery | The query. |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcListOptions | Service specific options. |
Promise<Page<NotificationNotification>> - Matched triggers
const notifications =
await IafNotification.listNotifications(
{
namespaces: ["ns1"],
owner: {
irn: "passportsvc:user:myuserid"
},
},
ctx
);
listSenders
List notification senders
| Parameter | Required | Type | Description |
|---|---|---|---|
| query | No | NotificationSenderQuery | The query. |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcListOptions | Service specific options. |
Promise<Page<NotificationSender>> - Matched senders
const senders =
await IafNotification.listSenders(
{
namespaces: ["ns1"]
},
ctx
);
listSubscriptions
List notification subscriptions
| Parameter | Required | Type | Description |
|---|---|---|---|
| query | No | NotificationSubscriptionQuery | The query. |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcListOptions | Service specific options. |
Promise<Page<NotificationSubscription>> - Matched subscriptions
const subscriptions =
await IafNotification.listSubscriptions(
{
namespaces: ["ns1"]
},
ctx
);
listTemplates
List notification templates
| Parameter | Required | Type | Description |
|---|---|---|---|
| query | No | NotificationTemplateQuery | The query. |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcListOptions | Service specific options. |
Promise<Page<NotificationTemplate>> - Matched templates
const templates =
await IafNotification.listTemplates(
{
namespaces: ["ns1"]
},
ctx
);
listTriggers
List notification triggers
| Parameter | Required | Type | Description |
|---|---|---|---|
| query | No | NotificationTriggerQuery | The query. |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcListOptions | Service specific options. |
Promise<Page<NotificationTrigger>> - Matched triggers
const triggers =
await IafNotification.listTriggers(
{
namespaces: ["ns1"]
},
ctx
);
updateGroup
Updates a notification group
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the group to update |
| group | Yes | NotificationGroup | Values to update |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcUpdateOptions | Service specific options. |
Promise<NotificationGroup> - Updated group
const group =
await IafNotification.updateGroup(
groupId,
{
_description: "System notification group"
},
ctx
);
updateSender
Updates a notification sender
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the sender to update |
| sender | Yes | NotificationSender | Values to update |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcUpdateOptions | Service specific options. |
Promise<NotificationSender> - Updated sender
const sender =
await IafNotification.updateSender(
senderId,
{
_description: "System notification sender"
},
ctx
);
updateTemplate
Updates a notification template
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the template to update |
| template | Yes | NotificationTemplate | Values to update |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcUpdateOptions | Service specific options. |
Promise<NotificationTemplate> - Updated template
const template =
await IafNotification.updateTemplate(
templateId,
{
_body: "template body"
},
ctx
);
updateTrigger
Updates a notification trigger
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the trigger to update |
| trigger | Yes | NotificationTrigger | Values to update |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcUpdateOptions | Service specific options. |
Promise<NotificationTrigger> - Updated trigger
const trigger =
await IafNotification.updateTrigger(
triggerId,
{
},
ctx
);