npm package: @plasma-platform/tm-service-products
Description: Products Service API
Author: Kyrylo Voronoi
Latest version: 2.1.7

# Documentation

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

### Table of Contents

-   [ServiceProducts](#serviceproducts)
    -   [messages](#messages)
    -   [disableTemplate](#disabletemplate)
    -   [freezeTemplate](#freezetemplate)
    -   [getTemplateByIdPublic](#gettemplatebyidpublic)
    -   [getTemplateById](#gettemplatebyid)
    -   [getTemplatesTopics](#gettemplatestopics)
    -   [getTemplatesTypes](#gettemplatestypes)
    -   [getTemplates](#gettemplates)
    -   [getTemplatesPublic](#gettemplatespublic)
    -   [getTotalTemplatesSales](#gettotaltemplatessales)
    -   [getUserOwnProducts](#getuserownproducts)
    -   [undoDisableProcess](#undodisableprocess)
    -   [undoFreezeProcess](#undofreezeprocess)
    -   [updateUserRatingAndTotalReviewsCount](#updateuserratingandtotalreviewscount)
    -   [getProductsBySpecificParams](#getproductsbyspecificparams)

## ServiceProducts

-   **See: <http://service-products.templatemonster.com/doc>**

**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 token if available (optional, default `null`)

### messages

Object with class service messages

### disableTemplate

Disable template

**Parameters**

-   `templateId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** template ID

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/', token);
  const request = await service.disableTemplate(53001);
})();
```

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)>** object of disable product

### freezeTemplate

Freeze template

**Parameters**

-   `templateId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** template ID

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/', token);
  const request = await service.freezeTemplate(53001);
})();
```

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)>** object 0f freeze product

### getTemplateByIdPublic

Get template by id (public method)

**Parameters**

-   `props` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `props.expand` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** expand information
    -   `props.ids` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** list of templates id divided by comma (e.g. "55555,55556,55557")
    -   `props.locale` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 2 char locale (en, ru de, etc.)

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/');
  const request = await service.getTemplateByIdPublic({locale: 'en', ids: 53000});
)();
```

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)>** object of product

### getTemplateById

Get template by id

**Parameters**

-   `props` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `props.expand` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** expand information
    -   `props.ids` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** list of templates id divided by comma (e.g. "55555,55556,55557")

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/', token);
  const request = await service.getTemplateById(53001);
})();
```

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)>** object of product

### getTemplatesTopics

Get templates topics

**Parameters**

-   `props` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `props.isAdult` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** return only adult or not templates
    -   `props.ids` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** array of templates id divided by comma (e.g. "55555,55556,55557")
    -   `props.searchWord` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
    -   `props.properties` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** array of properties where key is a property name and value is a value to search. e.g. (?properties[author_user_id]=1506970)
    -   `props.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** find all templates with given type name (e.g. "?type=wordpress", "?type=wordpress themes")

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/');
  const request = await service.getTemplatesTopics({
isAdult: 1,
ids: '53001',
searchWord: 'qwe',
properties: {
id: 2570,
propertyName: 'Name of the template',
},
type: 'wordpress',
});
})();
```

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)>** object of topics products list

### getTemplatesTypes

Get templates types

**Parameters**

-   `props` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `props.isAdult` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** return only adult or not templates
    -   `props.ids` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** array of templates id divided by comma (e.g. "55555,55556,55557")
    -   `props.searchWord` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
    -   `props.properties` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** array of properties where key is a property name and value is a value to search. e.g. (?properties[author_user_id]=1506970)

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/');
  const request = await service.getTemplatesTypes({
isAdult: 1,
ids: '53001',
searchWord: 'qwe',
properties: {
id: 2570,
propertyName: 'Name of the template',
},
});
})();
```

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)>** object of types products list

### getTemplates

Get templates

**Parameters**

-   `props` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `props.isAdult` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** return only adult or not templates
    -   `props.ids` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** array of templates id divided by comma (e.g. "55555,55556,55557")
    -   `props.searchWord` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
    -   `props.properties` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** array of properties where key is a property name and value is a value to search. e.g. (?properties[author_user_id]=1506970)
    -   `props.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** find all templates with given type name (e.g. "?type=wordpress", "?type=wordpress themes")
    -   `props.sort` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** available value [cheap, pricey, new, from doc API]
    -   `props.perPage` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** max templates per one page (20 by default, 200 is max size)
    -   `props.page` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** page number to view
    -   `props.filterTopic` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** topic id
    -   `props.filterUser` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** vendor id
    -   `props.filterPlatform` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** platform name [wordpress, joomla, ...]

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/', token);
  const request = await service.getTemplates({
isAdult: 1,
ids: '53001',
searchWord: 'qwe',
properties: {
id: 2570,
propertyName: 'Name of the template',
},
type: 'wordpress',
sort: 'price',
perPage: 20,
page: 1,
});
})();
```

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)>** object of products list

### getTemplatesPublic

Get templates public

**Parameters**

-   `props` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `props.isAdult` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** return only adult or not templates
    -   `props.ids` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** array of templates id divided by comma (e.g. "55555,55556,55557")
    -   `props.searchWord` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
    -   `props.properties` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** array of properties where key is a property name and value is a value to search. e.g. (?properties[author_user_id]=1506970)
    -   `props.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** find all templates with given type name (e.g. "?type=wordpress", "?type=wordpress themes")
    -   `props.sort` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** available value [cheap, pricey, new, from doc API]
    -   `props.perPage` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** max templates per one page (20 by default, 200 is max size)
    -   `props.page` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** page number to view
    -   `props.filterTopic` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** topic id
    -   `props.filterUser` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** vendor id
    -   `props.filterPlatform` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** platform name [wordpress, joomla, ...]

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/', token);
  const request = await service.getTemplatesPublic({
isAdult: 1,
ids: '53001',
searchWord: 'qwe',
properties: {
id: 2570,
propertyName: 'Name of the template',
},
type: 'wordpress',
sort: 'price',
perPage: 20,
page: 1,
});
})();
```

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)>** object of products list

### getTotalTemplatesSales

Get total templates sales

**Parameters**

-   `props` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `props.isAdult` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** return only adult or not templates
    -   `props.ids` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** array of templates id divided by comma (e.g. "55555,55556,55557")
    -   `props.searchWord` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
    -   `props.properties` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** array of properties where key is a property name and value is a value to search. e.g. (?properties[author_user_id]=1506970)
    -   `props.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** find all templates with given type name (e.g. "?type=wordpress", "?type=wordpress themes")

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/');
  const request = await service.getTotalTemplatesSales({
isAdult: 1,
ids: '53001',
searchWord: 'qwe',
properties: {
id: 2570,
propertyName: 'Name of the template',
},
type: 'wordpress',
});
})();
```

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)>** object of templates total sales value

### getUserOwnProducts

Get user own products

**Parameters**

-   `props` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `props.locale` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 2 char locale (en, ru de, etc.)
    -   `props.properties` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** array of properties where key is a property name and value is a value to search. e.g. (?properties[author_user_id]=1506970)
    -   `props.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** find all templates with given type name (e.g. "?type=wordpress", "?type=wordpress themes")
    -   `props.sort` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** defines on which fields to sort (e.g. ?sort=price,-templateId) ("-" symbol is DESC sort)
    -   `props.perPage` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** max templates per one page (20 by default, 200 is max size)
    -   `props.page` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** page number to view

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/products/', token);
  const request = await service.getUserOwnProducts({
properties: {
id: 2570,
propertyName: 'Name of the template',
},
type: 'wordpress',
sort: 'price',
perPage: 20,
page: 1,
});
})();
```

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)>** object of product parameters

### undoDisableProcess

Undo disable process

**Parameters**

-   `templateId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** template ID

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/products/', token);
  const request = await service.undoDisableProcess(53001);
})();
```

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)>** object of product

### undoFreezeProcess

Undo freeze process

**Parameters**

-   `templateId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** template ID

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/products/', token);
  const request = await service.undoFreezeProcess(53001);
})();
```

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)>** object of product

### updateUserRatingAndTotalReviewsCount

Update user rating and total reviews count

**Parameters**

-   `props` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `props.templateId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Reviewed template id
    -   `props.reviewsAverageScore` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Review score
    -   `props.reviewsTotal` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Total amount of reviews for this template

**Examples**

```javascript
(async () => {
  const service = new Service('http://service-products.dev/api/v1/', token);
  const request = await service.updateUserRatingAndTotalReviewsCount({
templateId: 53001,
reviewsAverageScore: 123,
reviewsTotal: 123,
});
})();
```

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)>** object of updated product parameters

### getProductsBySpecificParams

Search products by specific params (only v2)

**Parameters**

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

**Examples**

```javascript
(async () => {
  const service = new Service('//api.templatemonsterdev.com/products/v2/');
  const request = await service.getProductsBySpecificParams({ locale: 'en' });
})();
```

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)>** object product parameters