npm package: @plasma-platform/service-notifications
Description: Service Notifications Api
Author: Kyrylo Voronoi
Latest version: 2.0.0

![version](https://badgen.net/npm/v/@plasma-platform/service-notifications)
![nextVersion](https://badgen.net/npm/v/@plasma-platform/service-notifications/next)
![downloads](https://badgen.net/npm/dt/@plasma-platform/service-notifications)
![license](https://badgen.net/npm/license/@plasma-platform/service-notifications)
![dependency](https://badgen.net/npm/dependents/@plasma-platform/service-notifications)  

* * *

[Full documentation](https://templatemonster.gitlab.io/PlasmaPlatform/Frontend/plasma-platform/?path=/story/plasma-platform-sdk--service-notifications)  
install:  
`npm i @plasma-platform/service-notifications -S`  

# Short documentation

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

-   [NotificationsService](#notificationsservice)
    -   [messages](#messages)
    -   [getResourceToken](#getresourcetoken)
        -   [Parameters](#parameters)
        -   [Examples](#examples)
    -   [getUserToken](#getusertoken)
        -   [Parameters](#parameters-1)
        -   [Examples](#examples-1)
    -   [addNewNotification](#addnewnotification)
        -   [Parameters](#parameters-2)
        -   [Examples](#examples-2)
    -   [deleteNotificationByProperty](#deletenotificationbyproperty)
        -   [Parameters](#parameters-3)
        -   [Examples](#examples-3)
    -   [deleteNotification](#deletenotification)
        -   [Parameters](#parameters-4)
        -   [Examples](#examples-4)
    -   [eventsListenerEndpoint](#eventslistenerendpoint)
        -   [Parameters](#parameters-5)
        -   [Examples](#examples-5)
    -   [getAllowedMethodsForNotification](#getallowedmethodsfornotification)
        -   [Examples](#examples-6)
    -   [getListOfNotifications](#getlistofnotifications)
        -   [Parameters](#parameters-6)
        -   [Examples](#examples-7)
    -   [getPaginationHeaders](#getpaginationheaders)
        -   [Examples](#examples-8)
    -   [modifyNotification](#modifynotification)
        -   [Parameters](#parameters-7)
        -   [Examples](#examples-9)
    -   [viewSingleNotification](#viewsinglenotification)
        -   [Parameters](#parameters-8)
        -   [Examples](#examples-10)

## NotificationsService

-   **See: <http://service-notifications.templatemonsterdev.com/doc/>**

### messages

object with class service messages

Type: [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)

### getResourceToken

Subscription - Get system centrifugo token based on resource id

#### Parameters

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.resourceId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Resource ID (orderId for example) (required)
    -   `params.timestamp` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** UNIX Timestamp (required)
    -   `params.prefix` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** prefix for centrifuge

#### Examples

Get membership plan info by ID


```javascript
(async () => {
  const service = new NotificationsService(url);
  const response = await service.getResourceToken(params);
})();
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** Promise object represents info

### getUserToken

Subscription - Get user token

#### Parameters

-   `timestamp` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** UNIX Timestamp (required)

#### Examples

Get membership plan info by ID


```javascript
(async () => {
  const service = new NotificationsService(url, token);
  const response = await service.getUserToken(timestamp);
})();
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** Promise object represents info

### addNewNotification

Notification - Add new notification

#### Parameters

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.user_id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** ID of the user for whom notification have been created (required)
    -   `params.content` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Notification html code (required)
    -   `params.subject` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Notification subject (required)
    -   `params.params` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** JSON object with parameters of notification (type, etc.) (required)

#### Examples

```javascript
(async () => {
  const service = new NotificationsService(url, token);
  const response = await service.addNewNotification(params);
})();
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** Promise object

### deleteNotificationByProperty

Notification - Delete notification by property

#### Parameters

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.propertyName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Notification param property name (required)
    -   `params.propertyValue` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Notification param property value (required)

#### Examples

```javascript
(async () => {
  const service = new NotificationsService(url, token);
  const response = await service.deleteNotificationByProperty(params);
})();
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** Promise object

### deleteNotification

Notification - Delete notification

#### Parameters

-   `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Notification unique ID (required)

#### Examples

```javascript
(async () => {
  const service = new NotificationsService(url, token);
  const response = await service.deleteNotification(params);
})();
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** Promise object

### eventsListenerEndpoint

Notification - Events listener endpoint

#### Parameters

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.user_id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** ID of the user for whom notification have been created (required)
    -   `params.event` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Event name (required)

#### Examples

```javascript
(async () => {
  const service = new NotificationsService(url, token);
  const response = await service.eventsListenerEndpoint(params);
})();
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** Promise object

### getAllowedMethodsForNotification

Notification - Get Allowed methods for Notification API

#### Examples

```javascript
(async () => {
  const service = new NotificationsService(url);
  const response = await service.getAllowedMethodsForNotification();
})();
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** Promise object

### getListOfNotifications

Notification - Get list of notifications

#### Parameters

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.perPage` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Number of notifications per one page (optional)
    -   `params.page` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Page number (optional)
    -   `params.is_viewed` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 0: find not viewed notifications, 1: find viewed notifications. Allowed values: 0, 1 (optional)

#### Examples

```javascript
(async () => {
  const service = new NotificationsService(url, token);
  const response = await service.getListOfNotifications(params);
})();
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** Promise object

### getPaginationHeaders

Notification - Get pagination headers

#### Examples

```javascript
(async () => {
  const service = new NotificationsService(url, token);
  const response = await service.getPaginationHeaders(params);
})();
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** Promise object

### modifyNotification

Notification - Modify notification

#### Parameters

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Notification unique ID (required)
    -   `params.viewed_at` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Time when notification was viewed (required)

#### Examples

```javascript
(async () => {
  const service = new NotificationsService(url, token);
  const response = await service.modifyNotification(params);
})();
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** Promise object

### viewSingleNotification

Notification - View single notification

#### Parameters

-   `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Notification unique ID (required)

#### Examples

```javascript
(async () => {
  const service = new NotificationsService(url, token);
  const response = await service.viewSingleNotification(id);
})();
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** Promise object