1.0.4 • Published 3 years ago

terra-notification v1.0.4

Weekly downloads
9
License
ISC
Repository
github
Last release
3 years ago

notification-builder

library basically provides two classes Notification and NotificationBuilder to create, update and fetch notification workers on terra.

Install

npm i terra-notification

NotificationBuilder

this class process the data in json format and also provides function to get Notification objects.

Import

const builder = require("terra-notification").NotificationBuilder;

Usage

var obj = new builder();
//first parameter is type of notification and second parameter is no of notifications
let list = await obj.getNotifications("mail", 5); // get first 5 pending notifications as list of Notification Object

var json = await obj.create("mail", { email: "shilpa@terra.do", templateId: "T1" }); //creates a new notication and returns the same.

other methods are :

  • setDone(id)
  • setProcessing(id)
  • setFailed(id)
  • get(type,noOfNotifications) // will return list of json objects

TaskNotification

this class processes the data within the class.

Import

const notification = require("terra-notification").TaskNotification;

Usage

//first parameter is type of notification and second parameter is input json
var task = new Notification("mail", { email: "shilpa@terra.do", templateId: "T1" });
let result = await task.create(); //returns true if notification is created

methods are :

  • create()
  • markAsInitiated()
  • markAsDone()
  • markAsFailed()
  • setAll(json) // set all values from json

sample json :

{ id: 1836,notificationType: 'mail', status: 'created',inputJson: '{"email":"shilpa@terra.do","templateId":"T1"}' }

* Note : input json can be any json as per task need. To test worker use --experimental-worker flag with server.js like as follow :

node --experimental-worker server.js
1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago