npm package: @plasma-platform/tm-service-memberships
Description: Memberships Service API
Author: Anton Nemtsev
Latest version: 1.0.0

# Documentation

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

### Table of Contents

-   [MembershipsService](#membershipsservice)
    -   [messages](#messages)
    -   [getListOfMembershipGroups](#getlistofmembershipgroups)
    -   [getListOfAllMembershipPlans](#getlistofallmembershipplans)
    -   [getMembershipPlanInfoById](#getmembershipplaninfobyid)
    -   [getListOfSubscriptions](#getlistofsubscriptions)
    -   [getSubscription](#getsubscription)
    -   [reactivatePayments](#reactivatepayments)
    -   [suspendPayments](#suspendpayments)
    -   [getDownloadsByProductId](#getdownloadsbyproductid)

## MembershipsService

-   **See: <http://http://service-memberships.dev/doc/>**

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

### messages

Object with class service messages

### getListOfMembershipGroups

Groups - Get list of membership groups

**Parameters**

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.propertyId` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Use for filtering by TM property value id.
    -   `params.all` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Ignore membership group status on search, default value: 0, allowed values: 1, 0

**Examples**

_Get list of membership groups_

```javascript
(async () => {
  const service = new MembershipsService('//api.templatemonsterdev.com/memberships/v1/');
  const response = await service.getListOfMembershipGroups(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

### getListOfAllMembershipPlans

Memberships - Get list of all membership plans

**Parameters**

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.groupId` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Use for filtering by group ID
    -   `params.all` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Ignore membership group status on search, default value: 0, allowed values: 1, 0

**Examples**

_Get membership plan info by ID_

```javascript
(async () => {
  const service = new MembershipsService('//api.templatemonsterdev.com/memberships/v1/');
  const response = await service.getListOfAllMembershipPlans(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

### getMembershipPlanInfoById

Memberships - Get membership plan info by ID

**Parameters**

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.membershipId` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** ID of the membership plan (required)

**Examples**

_Get membership plan info by ID_

```javascript
(async () => {
  const service = new MembershipsService('//api.templatemonsterdev.com/memberships/v1/');
  const response = await service.getMembershipPlanInfoById(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

### getListOfSubscriptions

Subscriptions - Get list of subscriptions

**Parameters**

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.status` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Use for filtering by status. Allowed values: pending, active, inactive
    -   `params.membershipId` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Use for filtering by membership ID
    -   `params.groupId` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Use for filtering by membership group ID

**Examples**

_Get list of subscriptions_

```javascript
(async () => {
  const service = new MembershipsService('//api.templatemonsterdev.com/memberships/v1/', token);
  const response = await service.getListOfSubscriptions(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

### getSubscription

Subscriptions - Get subscription

**Parameters**

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.subscriptionId` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** ID of the subscription (required)

**Examples**

_Get list of subscriptions_

```javascript
(async () => {
  const service = new MembershipsService('//api.templatemonsterdev.com/memberships/v1/', token);
  const response = await service.getSubscription(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

### reactivatePayments

Subscriptions - Reactivate payments. Reactivate recurrent payments for subscription, payment status will be changed to active

**Parameters**

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.subscriptionId` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** ID of the subscription (required)

**Examples**

_Get list of subscriptions_

```javascript
(async () => {
  const service = new MembershipsService('//api.templatemonsterdev.com/memberships/v1/', token);
  const response = await service.reactivatePayments(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

### suspendPayments

Subscriptions - Suspend payments. Suspend recurrent payments for subscription, payment status will be changed to inactive

**Parameters**

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.subscriptionId` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** ID of the subscription (required)

**Examples**

_Get list of subscriptions_

```javascript
(async () => {
  const service = new MembershipsService('//api.templatemonsterdev.com/memberships/v1/', token);
  const response = await service.suspendPayments(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

### getDownloadsByProductId

Subscription Downloads - Get downloads by product ID. Gets download by product ID from entire user downloads list.

**Parameters**

-   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
    -   `params.productId` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** product id (required)

**Examples**

_Get list of subscriptions_

```javascript
(async () => {
  const service = new MembershipsService('//api.templatemonsterdev.com/memberships/v1/', token);
  const response = await service.getDownloadsByProductId(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