npm package: @plasma-platform/service-reviews
Description: Reviews service api
Author: Vira Peretiatko
Latest version: 1.8.0

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

* * *

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

# Short documentation

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

### Table of Contents

-   [ReviewsService](#reviewsservice)
    -   [Parameters](#parameters)
-   [getReviews](#getreviews)
    -   [Parameters](#parameters-1)
-   [getReviewsDesiredLocale](#getreviewsdesiredlocale)
    -   [Parameters](#parameters-2)
-   [checkReviewsUserCount](#checkreviewsusercount)
    -   [Parameters](#parameters-3)
-   [getReviewsUser](#getreviewsuser)
    -   [Parameters](#parameters-4)
-   [getReviewsVendor](#getreviewsvendor)
    -   [Parameters](#parameters-5)
-   [approveReview](#approvereview)
    -   [Parameters](#parameters-6)
-   [completeReview](#completereview)
    -   [Parameters](#parameters-7)
-   [declineReview](#declinereview)
    -   [Parameters](#parameters-8)
-   [addReviewVote](#addreviewvote)
    -   [Parameters](#parameters-9)
-   [replayTheReview](#replaythereview)
    -   [Parameters](#parameters-10)
-   [requestReviewComments](#requestreviewcomments)
    -   [Parameters](#parameters-11)
-   [voteComments](#votecomments)
    -   [Parameters](#parameters-12)
-   [getComments](#getcomments)
    -   [Parameters](#parameters-13)
-   [getCommentsUser](#getcommentsuser)
    -   [Parameters](#parameters-14)
-   [getCommentsUser](#getcommentsuser-1)
-   [addComment](#addcomment)
    -   [Parameters](#parameters-15)
-   [addCommentVote](#addcommentvote)
    -   [Parameters](#parameters-16)
-   [getReviewsMetadata](#getreviewsmetadata)
    -   [Parameters](#parameters-17)
    -   [Examples](#examples)
-   [getReviewInfoById](#getreviewinfobyid)
    -   [Parameters](#parameters-18)
-   [checkCommentsCount](#checkcommentscount)

## ReviewsService

Reviews Micro Service API

### 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`)

## getReviews

Return review information for given identifiers.

### Parameters

-   `params`  {Object} Reviews parameters

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"currentPageIndex":1,
"totalCount":11,
"lastPageIndex":6,
"items": [
 {
   "id":23,
   "status":4,
   "user_id":21543,
   "user_name":"mice mice",
   "title":"review title",
   "content":"review content",
   "score":5,
   "template_id":58444,
   "vote_up":0,
   "vote_down":0,
   "_links":{"self":{"href":"http://service-reviews.dev/api/v1/reviews/23"}}
  }, ...]
 }</pre>

## getReviewsDesiredLocale

Return review information for given identifiers.

### Parameters

-   `params`  {Object} Reviews parameters: desiredLocale, template_id, page, 'per-page', expand, sort etc.

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"currentPageIndex":1,
"totalCount":11,
"lastPageIndex":6,
"items": [
 {
   "id":23,
   "status":4,
   "user_id":21543,
   "user_name":"mice mice",
   "title":"review title",
   "content":"review content",
   "score":5,
   "template_id":58444,
   "vote_up":0,
   "vote_down":0,
   "_links":{"self":{"href":"http://service-reviews.dev/api/v1/reviews/23"}}
  }, ...]
 }</pre>

## checkReviewsUserCount

Return review head information for given identifiers. (user mode)

### Parameters

-   `params`  {Object} Reviews parameters

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"currentPageIndex":1,
"totalCount":11,
"lastPageIndex":6,
"items": [
 {
   "id":23,
   "status":4,
   "user_id":21543,
   "user_name":"mice mice",
   "title":"review title",
   "content":"review content",
   "score":5,
   "template_id":58444,
   "vote_up":0,
   "vote_down":0,
   "_links":{"self":{"href":"http://service-reviews.dev/api/v1/reviews/23"}}
  }, ...]
 }</pre>

## getReviewsUser

Return review information for given identifiers. (user mode)

### Parameters

-   `params`  {Object} Reviews parameters

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"currentPageIndex":1,
"totalCount":11,
"lastPageIndex":6,
"items": [
 {
   "id":23,
   "status":4,
   "user_id":21543,
   "user_name":"mice mice",
   "title":"review title",
   "content":"review content",
   "score":5,
   "template_id":58444,
   "vote_up":0,
   "vote_down":0,
   "_links":{"self":{"href":"http://service-reviews.dev/api/v1/reviews/23"}}
  }, ...]
 }</pre>

## getReviewsVendor

Return vendors reviews for given identifiers.

### Parameters

-   `params`  {Object} Reviews parameters
-   `headers`  {Object} Reviews headers

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"currentPageIndex":1,
"totalCount":11,
"lastPageIndex":6,
"items": [
 {
   "id":23,
   "status":4,
   "user_id":21543,
   "user_name":"mice mice",
   "title":"review title",
   "content":"review content",
   "score":5,
   "template_id":58444,
   "vote_up":0,
   "vote_down":0,
   "_links":{"self":{"href":"http://service-reviews.dev/api/v1/reviews/23"}}
  }, ...]
 }</pre>

## approveReview

Return approve review information for given identifiers.

### Parameters

-   `token`  {String} Access token
-   `id`  {Number} Review id

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"canModerate": 1,
"items":
 {
    "id": 1,
    "title": "Really good. Html is better than cms",
    "content": "I had font problem with flash cms. Now I have no problem with html",
    "score": 5,
    "created_at": 1469607948519,
    "user_id": 123,
    "template_id": 12345,
    "status": "initial",
    "vote_up": 1,
    "vote_down": 0,
    "_links": {"self":{"href":"http://service-reviews.dev/api/v1/reviews/1"}}
  }
 }</pre>

## completeReview

Return complete review information for given identifiers.

### Parameters

-   `token`  {String} Access token
-   `id`  {Number} Review id
-   `params`  {Object} Reviews parameters

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"canModerate": 1,
"items":
 {
    "id": 1,
    "title": "Really good. Html is better than cms",
    "content": "I had font problem with flash cms. Now I have no problem with html",
    "score": 5,
    "created_at": 1469607948519,
    "user_id": 123,
    "template_id": 12345,
    "status": "initial",
    "vote_up": 1,
    "vote_down": 0,
    "_links": {"self":{"href":"http://service-reviews.dev/api/v1/reviews/1"}}
  }
 }</pre>

## declineReview

Return decline review information for given identifiers.

### Parameters

-   `token`  {String} Access token
-   `id`  {Number} Review id

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"canModerate": 1,
"items":
 {
    "id": 1,
    "title": "Really good. Html is better than cms",
    "content": "I had font problem with flash cms. Now I have no problem with html",
    "score": 5,
    "created_at": 1469607948519,
    "user_id": 123,
    "template_id": 12345,
    "status": "initial",
    "vote_up": 1,
    "vote_down": 0,
    "_links": {"self":{"href":"http://service-reviews.dev/api/v1/reviews/1"}}
  }
 }</pre>

## addReviewVote

Return added votes for the review: increment vote_up or vote_down field.

### Parameters

-   `token`  {String} Access token
-   `id`  {Number} Review id
-   `params`  {Object} Reviews votes parameters

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"canModerate": 1,
"items":
 {
    "id": 1,
    "title": "Really good. Html is better than cms",
    "content": "I had font problem with flash cms. Now I have no problem with html",
    "score": 5,
    "created_at": 1469607948519,
    "user_id": 123,
    "template_id": 12345,
    "status": "initial",
    "vote_up": 1,
    "vote_down": 0,
    "_links": {"self":{"href":"http://service-reviews.dev/api/v1/reviews/1"}}
  }
 }</pre>

## replayTheReview

Return reply of the review information for given identifiers.

### Parameters

-   `token`  {String} Access token
-   `reviewId`  {Number} ID of the parent review
-   `params`  {Object} Body parameters

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"canModerate": 1,
"items":
 {
  "id": 1,
  "review_id": 1,
  "content": "I had font problem with flash cms. Now I have no problem with html",
  "created_at": 1469607948519,
  "user_id": 123,
  "vote_up": 0,
  "vote_down": 0,
  "_links": {"self":{"href":"http://service-reviews.dev/api/v1/reviews/1/comment/1"}}
  }
 }</pre>

## requestReviewComments

Return request review comments list.

### Parameters

-   `reviewId`  {Number} ID of the parent review

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"canModerate": 1,
"items":
 {
  "id": 1,
  "review_id": 1,
  "content": "I had font problem with flash cms. Now I have no problem with html",
  "created_at": 1469607948519,
  "user_id": 123,
  "vote_up": 0,
  "vote_down": 0,
  "_links": {"self":{"href":"http://service-reviews.dev/api/v1/reviews/1/comment/1"}}
  }
 }</pre>

## voteComments

Return votes of the review.

### Parameters

-   `token`  {String} Access token
-   `id`  {Number} ID of the comment
-   `reviewId`  {Number} ID of the parent review

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"canModerate": 1,
"items":
 {

  "id": 1,
  "review_id": 1,
  "content": "I had font problem with flash cms. Now I have no problem with html",
  "created_at": 1469607948519,
  "user_id": 123,
  "vote_up": 0,
  "vote_down": 0,
  "_links": {"self":{"href":"http://service-reviews.dev/api/v1/reviews/1/comment/1"}}
  }
 }</pre>

## getComments

Return comments information for given identifiers.

### Parameters

-   `params`  {Object} Comments parameters

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"currentPageIndex":1,
"totalCount":11,
"lastPageIndex":6,
"items": [
 {
   "id":23,
   "status":4,
   "user_id":21543,
   "user_name":"mice mice",
   "title":"comment title",
   "content":"comment content",
   "template_id":58444,
   "vote_up":0,
   "vote_down":0,
   "created_at": 1469607948519,
   "updated_at": 1469607948519,
   "author": "user",
   "_links":{"self":{"href":"http://service-reviews.dev/api/v1/reviews/23"}}
  }, ...]
 }</pre>

## getCommentsUser

Return users comments information for given identifiers.

### Parameters

-   `params`  {Object} Comments parameters

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"currentPageIndex":1,
"totalCount":11,
"lastPageIndex":6,
"items": [
 {
   "id":23,
   "status":4,
   "user_id":21543,
   "user_name":"mice mice",
   "title":"comment title",
   "content":"comment content",
   "template_id":58444,
   "vote_up":0,
   "vote_down":0,
   "created_at": 1469607948519,
   "updated_at": 1469607948519,
   "author": "user",
   "_links":{"self":{"href":"http://service-reviews.dev/api/v1/reviews/23"}}
  }, ...]
 }</pre>

## getCommentsUser

Return authors comments information for given identifiers.

## addComment

Add new QA

### Parameters

-   `token`  {String} Access token
-   `params`  {Object} Body parameters

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"canModerate": 1,
"items":
 {
    "id": 1,
    "status": "pending",
    "user_id": 12345,
    "user_name": "John Doe",
    "user_email": "jho***@gmail.com",
    "content": "I had font problem with flash cms. Now I have no problem with html",
    "template_id": 55555,
    "created_at": 1469607948519,
    "updated_at": 1469607948519,
    "vote_up": 0,
    "vote_down": 0,
    "locale": "en",
    "author": "moderator"
    "_links": {"self":{"href":"http://service-reviews.dev/api/v1/qas/1"}}
 }</pre>

## addCommentVote

Return added votes for the comment: increment vote_up or vote_down field.

### Parameters

-   `token`  {String} Access token
-   `id`  {Number} Comment id
-   `params`  {Object} Comment votes parameters

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** <pre>{
"canModerate": 1,
"items":
 {
     "id": 1,
     "status": "pending",
     "user_id": 12345,
     "user_name": "John Doe",
     "user_email": "jho***@gmail.com",
     "content": "I had font problem with flash cms. Now I have no problem with html",
     "template_id": 55555,
     "created_at": 1469607948519,
     "updated_at": 1469607948519,
     "vote_up": 0,
     "vote_down": 0,
     "locale": "en",
     "author": "moderator"
     "_links": {"self":{"href":"http://service-reviews.dev/api/v1/qas/1"}}
  }
 }</pre>

## getReviewsMetadata

Get reviews metadata

### Parameters

-   `params`  {Object} parameters

### Examples

```javascript
* @returns {Object} <pre>{
"headers":
 {
   "totalCount": 1}
 }</pre>
```

## getReviewInfoById

Get review info by id

### Parameters

-   `reviewId`  {Object} review id

## checkCommentsCount

Return count of unreplied comments.