# terra-notification

> build notifications and retrieve

Latest version **1.0.4** (published 2021-04-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install terra-notification
pnpm add terra-notification
yarn add terra-notification
bun add terra-notification
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2021-04-20 |
| First published | 2020-12-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 36.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | shilpa |
| Maintainers | schavda |
| Keywords | notification, terra |

## Links

- npm: https://www.npmjs.com/package/terra-notification
- Repository: https://github.com/Terra-do/notification-builder
- Homepage: https://github.com/Terra-do/notification-builder#readme
- Issues: https://github.com/Terra-do/notification-builder/issues
- npm.io page: https://npm.io/package/terra-notification

## Dependencies (1)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.1

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2021-04-20
- 1.0.3 — 2021-01-13
- 1.0.2 — 2021-01-13
- 1.0.1 — 2020-12-16
- 1.0.0 — 2020-12-15

## README

# notification-builder

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

### Install

```sh
npm i terra-notification
```

## NotificationBuilder

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

### Import

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

### Usage

```js
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

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

### Usage

```js
//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 :

```sh
{ 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 :

```sh
node --experimental-worker server.js
```

---
_Source: https://npm.io/package/terra-notification · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
