npm package: @plasma-platform/service-promos
Description: Promos service api
Author: Daria Hromyk
Latest version: 1.5.1

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

* * *

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

# Short documentation

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

### Table of Contents

-   [PromosService](#promosservice)
    -   [Parameters](#parameters)
    -   [messages](#messages)
-   [getPromosBySlot](#getpromosbyslot)
    -   [Parameters](#parameters-1)
-   [getPromos](#getpromos)
-   [getPromosMetadata](#getpromosmetadata)
-   [getAuthorNotifications](#getauthornotifications)
    -   [Parameters](#parameters-2)
    -   [Examples](#examples)
-   [setActionAuthorNotification](#setactionauthornotification)
    -   [Parameters](#parameters-3)
    -   [Examples](#examples-1)
-   [createGiftForAuthor](#creategiftforauthor)
    -   [Parameters](#parameters-4)
    -   [Examples](#examples-2)
-   [createGiftForAuthor](#creategiftforauthor-1)
    -   [Parameters](#parameters-5)
    -   [Examples](#examples-3)

## PromosService

-   **See: <https://jsonplaceholder.typicode.com/>**

Promos Micro Service API that you may adopt for your needs

### Parameters

-   `url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** service url
-   `token` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | null)** user access tocken if available (optional, default `null`)

### messages

Object with class service messages

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

## getPromosBySlot

Return promos information for given slot.

### Parameters

-   `slot` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Slot Name
-   `locale` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** locale

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>
{
  "_id" : "5b62fab40643dd000b634c92",
  "slot" : "Main",
  "type" : "slider",
  "created_at" : 1533213364,
  "updated_at" : 1533214495,
  "params" : {
     "switch_time" : "15",
     "slides" : [
       {
          "en" : {
            "productId" : "55555",
            "title" : "Monstroid - Wordpress Theme",
            "titleHtmlType" : "h1",
            "rating" : "5",
            "price" : "99.9",
            "promoPrice" : "77",
            "blueButtonName" : "View Details",
            "blueButtonLink" : "https://www.templatemonster.com/intense-multipurpose-html-template.html",
            "grayButtonName" : "Live Demo",
            "grayButtonLink" : "https://www.templatemonster.com/demo/55555.html",
            "image" : "https://s.tmimgcdn.com/scr/62200/monstroid2-multipurpose-wordpress-theme_62222-original.jpg?width=1280",
            "imageAlt" : "monstroid wordpress theme",
            "bgImage" : "https://s.tmimgcdn.com/scr/59500/59555-prestashop-b.jpg?width=50",
            "display" : "left",
            "type" : "product",
            "active" : "1"
          }
       },
    ... ]
    },
  "tags" : [
    "main",
    "test"
  ]
}
</pre>

## getPromos

Return promos information for all slots.

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>
[{
  "_id" : "5b62fab40643dd000b634c92",
  "slot" : "Main",
  "type" : "slider",
  "created_at" : 1533213364,
  "updated_at" : 1533214495,
  "params" : {
     "switch_time" : "15",
     "slides" : [
       {
          "en" : {
            "productId" : "55555",
            "title" : "Monstroid - Wordpress Theme",
            "titleHtmlType" : "h1",
            "rating" : "5",
            "price" : "99.9",
            "promoPrice" : "77",
            "blueButtonName" : "View Details",
            "blueButtonLink" : "https://www.templatemonster.com/intense-multipurpose-html-template.html",
            "grayButtonName" : "Live Demo",
            "grayButtonLink" : "https://www.templatemonster.com/demo/55555.html",
            "image" : "https://s.tmimgcdn.com/scr/62200/monstroid2-multipurpose-wordpress-theme_62222-original.jpg?width=1280",
            "imageAlt" : "monstroid wordpress theme",
            "bgImage" : "https://s.tmimgcdn.com/scr/59500/59555-prestashop-b.jpg?width=50",
            "display" : "left",
            "type" : "product",
            "active" : "1"
          }
       },
    ... ]
    },
  "tags" : [
    "main",
    "test"
  ]
},
...]
</pre>

## getPromosMetadata

Return promos information for all slots.

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>
</pre>

## getAuthorNotifications

Get author's notifications items.

### Parameters

-   `properties` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array of author's properties.
-   `sort` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** defines on which fields to sort.

### Examples

```javascript
(async () => {
  const service = new Service('http://service-promos.templatemonsterdev.com/api/v1/', token);
  const request = await service.getAuthorNotifications(properties);
})();
```

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

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

## setActionAuthorNotification

Set action to author's notification.

### Parameters

-   `params` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object of params.
    -   `params.promoId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** promo id.
    -   `params.action` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** promo action.

### Examples

```javascript
(async () => {
  const service = new Service('http://service-promos.templatemonsterdev.com/api/v1/', token);
  const request = await service.setActionAuthorNotification(params);
})();
```

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

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

## createGiftForAuthor

Create gift to author.

### Parameters

-   `params` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object of params.
    -   `params.slot` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** promo slot.

### Examples

```javascript
(async () => {
  const service = new Service('http://service-promos.templatemonsterdev.com/api/v1/', token);
  const request = await service.createGiftForAuthor(params);
})();
```

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

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

## createGiftForAuthor

Get authors gift.

### Parameters

-   `params` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object of params.
    -   `params.slot` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** promo slot.

### Examples

```javascript
(async () => {
  const service = new Service('http://service-promos.templatemonsterdev.com/api/v1/', token);
  const request = await service.getGiftAuthor(params);
})();
```

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

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