IafNotification
Use the IafNotification API to create and manage notifications and associated resources
createAuthorization
Creates a notification authorization
| Parameter | Required | Type | Description |
|---|---|---|---|
| authorization | Yes | NotificationAuthorization | Pass the authorization to create |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcCreateOptions | Service specific options. |
Promise<NotificationAuthorization> - Created authorization
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
| 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
);
createPermissions
Creates an array of Permission class objects for Notification service objects.
| Parameter | Required | Type | Description |
|---|---|---|---|
| permissions | Yes | Array<Permission> | Pass an array of Permission objects you define |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage |
Promise<CreatePermissionsResponse> - A CreatePermissionsResponse object with an array of successful permissions and an array of failed permissions
// Permissions with mandatory fields
let 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
| 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
);
deleteAuthorization
Deletes a notification authorization
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the authorization to delete |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcDeleteOptions | Service specific options. |
await IafNotification.deleteAuthorization(
authorizationId,
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
);
deletePermission
Deletes a Permission class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The Permission object's id |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage |
const res = await IafItemSvc.deletePermission(permisssion._id, 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
);
getAuthorization
Gets a notification authorization
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the authorization to get |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcGetOptions | Service specific options. |
Promise<NotificationAuthorization> - The authorization
const authorization =
await IafNotification.getAuthorization(
authorizationId,
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
);
getPermissions
Gets permissions for File Service resources.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | PermissionCriteria | Pass a PermissionCriteria object that contains your simple query |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage |
Promise<Page<Permission>> - A promise with a Page object that contains the Permission objects that match your query
criteria = {
_userType: "Project_Setup_Config"
};
const permissions = await IafItemSvc.getPermissions(criteria, 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 trigger
const trigger =
await IafNotification.getTrigger(
triggerId,
ctx
);
listAuthorizations
List notification authorizations
| Parameter | Required | Type | Description |
|---|---|---|---|
| query | No | NotificationAuthorizationQuery | The query. |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcListOptions | Service specific options. |
Promise<Page<NotificationAuthorization>> - Matched authorizations
const authorizations =
await IafNotification.listAuthorizations(
{
namespaces: ["ns1"]
},
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 notifications
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
);
updateAuthorization
Updates a notification authorization
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The id of the authorization to update |
| authorization | Yes | NotificationAuthorization | Values to update |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | No | NotificationSvcUpdateOptions | Service specific options. |
Promise<NotificationAuthorization> - Updated authorization
const authorization =
await IafNotification.updateAuthorization(
authorizationId,
{
},
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
);
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| permissions | Yes | Array<Permission> | Pass an array of updated Permission objects with the properties and the updated values |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage |
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
| 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
);