Skip to main content
Version: v5.1

IafNotification

Use the IafNotification API to create and manage notifications and associated resources

createAuthorization#

Creates a notification authorization

ParameterRequiredTypeDescription
authorizationYesNotificationAuthorizationPass the authorization to create
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcCreateOptionsService specific options.
Returns

Promise<NotificationAuthorization> - Created authorization

Examples
const authorization =  await IafNotification.createAuthorization(    {      _namespaces: project._namespaces,      _name: "HMAC authorization",      _type: "HMAC",      _hmac: {        _apiKey: apiKey,        _secretKey: {            _name: "MY_HMAC_SECRET"        }      }    },    ctx  );

createDevice#

Creates a notification device

ParameterRequiredTypeDescription
deviceYesNotificationDevicePass the device to create
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcCreateOptionsService specific options.
Returns

Promise<NotificationDevice> - Created device

Examples
const subscriber =  await IafNotification.createDevice(    {      _owner: {          _irn: "passportsvc:user:myuserid"      },      _transport: "EMAIL",      _address: "[email protected]"    },    ctx  );

createGroup#

Creates a notification group

ParameterRequiredTypeDescription
groupYesNotificationGroupPass the group to create
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcCreateOptionsService specific options.
Returns

Promise<NotificationGroup> - Created group

Examples
const group =  await IafNotification.createGroup(    {      _name: "System",      _description: "System notification group"      _namespaces: project._namespaces    },    ctx  );

createPermissions#

Creates an array of Permission class objects for Notification service objects.

ParameterRequiredTypeDescription
permissionsYesArray<Permission>Pass an array of Permission objects you define
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage
Returns

Promise<CreatePermissionsResponse> - A CreatePermissionsResponse object with an array of successful permissions and an array of failed permissions

Examples
// Permissions with mandatory fieldslet permissions = [{  _actions: [  IafPermission.PermConst.Action.Read, IafPermission.PermConst.Action.Share, IafPermission.PermConst.Action.Delete],  _namespace: "ProjA_HEpftR8X",  _resourceDesc:{    _irn": IafPermission.NotificationTemplateIrnAll  },  _user:{    _id: "75b2a3d6-a3e8-498d-99dc-23538bc9a389", // Either user or usergroup id, specify respective _type    _type: IafPermission.PermConst.UserType.User // Either user or usergroup, specify respective _id  }}];

createSender#

Creates a notification sender

ParameterRequiredTypeDescription
senderYesNotificationSenderPass the sender to create
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcCreateOptionsService specific options.
Returns

Promise<NotificationSender> - Created sender

Examples
const sender =  await IafNotification.createSender(    {      _name: "System",      _description: "System notification sender"      _namespaces: project._namespaces    },    ctx  );

createSubscription#

Creates a notification subscription

ParameterRequiredTypeDescription
subscriptionYesNotificationSubscriptionPass the subscription to create
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcCreateOptionsService specific options.
Returns

Promise<NotificationSubscription> - Created subscription

Examples
const subscription =  await IafNotification.createSubscription(    {      _namespaces: project._namespaces,      _group: {          _id: "<group id>"      },      _device: {          _id: "<device id>"      }    },    ctx  );

createTemplate#

Creates a notification template

ParameterRequiredTypeDescription
templateYesNotificationTemplatePass the template to create
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcCreateOptionsService specific options.
Returns

Promise<NotificationTemplate> - Created template

Examples
const template =  await IafNotification.createTemplate(    {      _namespaces: project._namespaces,      _transport: "EMAIL",      _format: "VELOCITY",    },    ctx  );

createTrigger#

Creates a notification trigger

ParameterRequiredTypeDescription
triggerYesNotificationTriggerPass the template to create
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcCreateOptionsService specific options.
Returns

Promise<NotificationTrigger> - Created trigger

Examples
const trigger =  await IafNotification.createTrigger(    {      _namespaces: project._namespaces,      _type: "EVENT"    },    ctx  );

deleteAuthorization#

Deletes a notification authorization

ParameterRequiredTypeDescription
idYesStringThe id of the authorization to delete
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcDeleteOptionsService specific options.
Returns

Promise<void> - Empty promise

Examples
await IafNotification.deleteAuthorization(  authorizationId,  ctx);

deleteDevice#

Deletes a notification device

ParameterRequiredTypeDescription
idYesStringThe id of the device to delete
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcDeleteOptionsService specific options.
Returns

Promise<void> - Empty promise

Examples
await IafNotification.deleteDevice(  deviceId,  ctx);

deleteGroup#

Deletes a notification group

ParameterRequiredTypeDescription
idYesStringThe id of the group to delete
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcDeleteOptionsService specific options.
Returns

Promise<void> - Empty promise

Examples
await IafNotification.deleteGroup(  groupId,  ctx);

deletePermission#

Deletes a Permission class object.

ParameterRequiredTypeDescription
idYesStringThe Permission object's id
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage
Returns

Promise<String> - Ok:204

Examples
const res = await IafItemSvc.deletePermission(permisssion._id, ctx);

deleteSender#

Deletes a notification sender

ParameterRequiredTypeDescription
idYesStringThe id of the sender to delete
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcDeleteOptionsService specific options.
Returns

Promise<void> - Empty promise

Examples
await IafNotification.deleteSender(  senderId,  ctx);

deleteSubscription#

Deletes a notification subscription

ParameterRequiredTypeDescription
idYesStringThe id of the subscription to delete
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcDeleteOptionsService specific options.
Returns

Promise<void> - Empty promise

Examples
await IafNotification.deleteSubscription(  subscriptionId,  ctx);

deleteTemplate#

Deletes a notification template

ParameterRequiredTypeDescription
idYesStringThe id of the template to delete
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcDeleteOptionsService specific options.
Returns

Promise<void> - Empty promise

Examples
await IafNotification.deleteTemplate(  templateId,  ctx);

deleteTrigger#

Deletes a notification trigger

ParameterRequiredTypeDescription
idYesStringThe id of the trigger to delete
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcDeleteOptionsService specific options.
Returns

Promise<void> - Empty promise

Examples
await IafNotification.deleteTrigger(  triggerId,  ctx);

getAuthorization#

Gets a notification authorization

ParameterRequiredTypeDescription
idYesStringThe id of the authorization to get
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcGetOptionsService specific options.
Returns

Promise<NotificationAuthorization> - The authorization

Examples
const authorization =  await IafNotification.getAuthorization(    authorizationId,    ctx  );

getDevice#

Gets a notification device

ParameterRequiredTypeDescription
idYesStringThe id of the device to get
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcGetOptionsService specific options.
Returns

Promise<NotificationDevice> - The subscriber

Examples
const subscriber =  await IafNotification.getDevice(    deviceId,    ctx  );

getGroup#

Gets a notification group

ParameterRequiredTypeDescription
idYesStringThe id of the group to get
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcGetOptionsService specific options.
Returns

Promise<NotificationGroup> - Updated group

Examples
const group =  await IafNotification.getGroup(    groupId,    ctx  );

getPermissions#

Gets permissions for File Service resources.

ParameterRequiredTypeDescription
criteriaYesPermissionCriteriaPass a PermissionCriteria object that contains your simple query
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage
Returns

Promise<Page<Permission>> - A promise with a Page object that contains the Permission objects that match your query

Examples
criteria = {  _userType: "Project_Setup_Config"};
const permissions = await IafItemSvc.getPermissions(criteria, ctx);

getSender#

Gets a notification sender

ParameterRequiredTypeDescription
idYesStringThe id of the sender to get
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcGetOptionsService specific options.
Returns

Promise<NotificationSender> - The sender

Examples
const sender =  await IafNotification.getSender(    senderId,    ctx  );

getSubscription#

Gets a notification subscription

ParameterRequiredTypeDescription
idYesStringThe id of the subscription to get
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcGetOptionsService specific options.
Returns

Promise<NotificationSubscription> - The subscription

Examples
const subscription =  await IafNotification.getSubscription(    subscriptionId,    ctx  );

getTemplate#

Gets a notification template

ParameterRequiredTypeDescription
idYesStringThe id of the template to get
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcGetOptionsService specific options.
Returns

Promise<NotificationTemplate> - The template

Examples
const template =  await IafNotification.getTemplate(    templateId,    ctx  );

getTrigger#

Gets a notification trigger

ParameterRequiredTypeDescription
idYesStringThe id of the trigger to get
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcGetOptionsService specific options.
Returns

Promise<NotificationTrigger> - The trigger

Examples
const trigger =  await IafNotification.getTrigger(    triggerId,    ctx  );

listAuthorizations#

List notification authorizations

ParameterRequiredTypeDescription
queryNoNotificationAuthorizationQueryThe query.
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcListOptionsService specific options.
Returns

Promise<Page<NotificationAuthorization>> - Matched authorizations

Examples
const authorizations =  await IafNotification.listAuthorizations(    {       namespaces: ["ns1"]    },    ctx  );

listDevices#

List notification devices

ParameterRequiredTypeDescription
queryNoNotificationDeviceQueryThe query.
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcListOptionsService specific options.
Returns

Promise<Page<NotificationDevice>> - Matched devices

Examples
const subscribers =  await IafNotification.listDevices(    {      owner: {          irn: "passportsvc:user:myuserid"      },    },    ctx  );

listGroups#

List notification groups

ParameterRequiredTypeDescription
queryNoNotificationGroupQueryThe query.
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcListOptionsService specific options.
Returns

Promise<Page<NotificationGroup>> - Updated group

Examples
const groups =  await IafNotification.listGroups(    {       namespaces: ["ns1"]    },    ctx  );

listNotifications#

List notification history

ParameterRequiredTypeDescription
queryNoNotificationNotificationQueryThe query.
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcListOptionsService specific options.
Returns

Promise<Page<NotificationNotification>> - Matched notifications

Examples
const notifications =  await IafNotification.listNotifications(    {      namespaces: ["ns1"],      owner: {          irn: "passportsvc:user:myuserid"      },    },    ctx  );

listSenders#

List notification senders

ParameterRequiredTypeDescription
queryNoNotificationSenderQueryThe query.
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcListOptionsService specific options.
Returns

Promise<Page<NotificationSender>> - Matched senders

Examples
const senders =  await IafNotification.listSenders(    {       namespaces: ["ns1"]    },    ctx  );

listSubscriptions#

List notification subscriptions

ParameterRequiredTypeDescription
queryNoNotificationSubscriptionQueryThe query.
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcListOptionsService specific options.
Returns

Promise<Page<NotificationSubscription>> - Matched subscriptions

Examples
const subscriptions =  await IafNotification.listSubscriptions(    {       namespaces: ["ns1"]    },    ctx  );

listTemplates#

List notification templates

ParameterRequiredTypeDescription
queryNoNotificationTemplateQueryThe query.
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcListOptionsService specific options.
Returns

Promise<Page<NotificationTemplate>> - Matched templates

Examples
const templates =  await IafNotification.listTemplates(    {       namespaces: ["ns1"]    },    ctx  );

listTriggers#

List notification triggers

ParameterRequiredTypeDescription
queryNoNotificationTriggerQueryThe query.
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcListOptionsService specific options.
Returns

Promise<Page<NotificationTrigger>> - Matched triggers

Examples
const triggers =  await IafNotification.listTriggers(    {       namespaces: ["ns1"]    },    ctx  );

updateAuthorization#

Updates a notification authorization

ParameterRequiredTypeDescription
idYesStringThe id of the authorization to update
authorizationYesNotificationAuthorizationValues to update
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcUpdateOptionsService specific options.
Returns

Promise<NotificationAuthorization> - Updated authorization

Examples
const authorization =  await IafNotification.updateAuthorization(    authorizationId,    {    },    ctx  );

updateGroup#

Updates a notification group

ParameterRequiredTypeDescription
idYesStringThe id of the group to update
groupYesNotificationGroupValues to update
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcUpdateOptionsService specific options.
Returns

Promise<NotificationGroup> - Updated group

Examples
const group =  await IafNotification.updateGroup(    groupId,    {      _description: "System notification group"    },    ctx  );

updatePermissions#

Updates Permission class objects for Notification Service resources such as the following: Template, Trigger, Notification, Subscription, Group. If a permission doesn't exist, this method creates the permission. To check if a permission exists or not, the method checks one of the following fields of a permission object: _resourceDesc, _namespace, _user.

ParameterRequiredTypeDescription
permissionsYesArray<Permission>Pass an array of updated Permission objects with the properties and the updated values
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage
Returns

Promise<CreatePermissionsResponse> - A promise with a CreatePermissionsResponse object with an array of successful permissions and an array of failed permissions

updateSender#

Updates a notification sender

ParameterRequiredTypeDescription
idYesStringThe id of the sender to update
senderYesNotificationSenderValues to update
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcUpdateOptionsService specific options.
Returns

Promise<NotificationSender> - Updated sender

Examples
const sender =  await IafNotification.updateSender(    senderId,    {      _description: "System notification sender"    },    ctx  );

updateTemplate#

Updates a notification template

ParameterRequiredTypeDescription
idYesStringThe id of the template to update
templateYesNotificationTemplateValues to update
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcUpdateOptionsService specific options.
Returns

Promise<NotificationTemplate> - Updated template

Examples
const template =  await IafNotification.updateTemplate(    templateId,    {     _body: "template body"    },    ctx  );

updateTrigger#

Updates a notification trigger

ParameterRequiredTypeDescription
idYesStringThe id of the trigger to update
triggerYesNotificationTriggerValues to update
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsNoNotificationSvcUpdateOptionsService specific options.
Returns

Promise<NotificationTrigger> - Updated trigger

Examples
const trigger =  await IafNotification.updateTrigger(    triggerId,    {    },    ctx  );