Memberships
Kind: global class
new Memberships()
Memberships API JS client.
In order to use Memberships API you should create an instance of this class.
import Memberships from "tm-memberships-api-client-js";
const products = new Memberships ('http://service-memberships.dev/api/v1', 'en');
memberships.getMembershipGroups(params) ⇒ Array
Return list of membership groups.
Kind: instance method of Memberships
Returns: Array
-
[
{
"id":"1",
"name":"Name",
"active_icon":"http://s3.amazonaws.com/doc/2017-02-02/",
"inactive_icon":"http://s3.amazonaws.com/doc/2017-02-02/",
"type_id":"17763",
}, ...]
Param | Type | Description |
---|
params | Object | Membership groups parameters { type_id: Number } |
memberships.getMemberships(params) ⇒ Array
Return list of all membership plans.
Kind: instance method of Memberships
Returns: Array
-
[
{
"id":"1",
"title":"Premium",
"descriptions":"Example description",
"group_id":"1",
"price": 199,
"max_downloads":"10",
"duration_days":"30",
}, ...]
Param | Type | Description |
---|
params | Object | Membership group parameters { group_id: Number } |
memberships.getMembership(params) ⇒ Array
Return membership plan by id.
Kind: instance method of Memberships
Returns: Array
-
{
"id":"1",
"title":"Premium",
"descriptions":"Example description",
"group_id":"1",
"price": 199,
"max_downloads":"10",
"duration_days":"30",
}
Param | Type | Description |
---|
params | number | id |
memberships.getListOfSubscriptions(token, params) ⇒ Array
Return list of subscriptions
.
Kind: instance method of Memberships
Returns: Array
-
[
{
"id":"1",
"membership": {
"id":"1",
"title":"Premium",
"descriptions":"Example description",
"group_id":"1",
"price": 199,
"max_downloads":"10",
"duration_days":"30",
},
"user_id":"12345",
"status":"active"
"end_date":"1038444",
"downloads":"0",
"downloads_quota": 100,
}, ...]
Param | Type | Description |
---|
token | String | User token |
params | Object | Membership groups parameters { status : String, membership_id : Number, group_id : Number } |
memberships.getSubscription(token, id) ⇒ Object
Return subscription
.
Kind: instance method of Memberships
Returns: Object
-
{
"id":"1",
"membership": {
"id":"1",
"title":"Premium",
"descriptions":"Example description",
"group_id":"1",
"price": 199,
"max_downloads":"10",
"duration_days":"30",
},
"user_id":"12345",
"status":"active"
"end_date":"1038444",
"downloads":"0",
"downloads_quota": 100,
}
Param | Type | Description |
---|
token | String | User token |
id | Number | User id |
memberships.reactivatePayments(token, id) ⇒ Object
Reactivate payments
Kind: instance method of Memberships
Returns: Object
-
{
"id":"1",
"membership": {
"id":"1",
"title":"Premium",
"descriptions":"Example description",
"group_id":"1",
"price": 199,
"max_downloads":"10",
"duration_days":"30",
},
"user_id":"12345",
"status":"active"
"end_date":"1038444",
"downloads":"0",
"downloads_quota": 100,
"payment_status": active,
}
Param | Type | Description |
---|
token | String | User token |
id | Number | Membership subscription id |
memberships.suspendPayments(token, id) ⇒ Object
Suspend payments
Kind: instance method of Memberships
Returns: Object
-
{
"id":"1",
"membership": {
"id":"1",
"title":"Premium",
"descriptions":"Example description",
"group_id":"1",
"price": 199,
"max_downloads":"10",
"duration_days":"30",
},
"user_id":"12345",
"status":"active"
"end_date":"1038444",
"downloads":"0",
"downloads_quota": 100,
"payment_status": active,
}
Param | Type | Description |
---|
token | String | User token |
id | Number | Membership subscription id |
memberships.getListOfDownloads(token, id) ⇒ Object
Return list of downloads.
Kind: instance method of Memberships
Returns: Object
-
{
"currentPageIndex":1,
"totalCount":11,
"lastPageIndex":6,
"items": [
{
"id":"1",
"product_id":"143142",
"created_at":"12345"
}, ...]
}
Param | Type | Description |
---|
token | String | User token |
id | Number | Product id |
memberships._isValidId(id) ⇒ Bool
Return Correct id or not
Kind: instance method of Memberships
Param | Type | Description |
---|
id | Number | Product id |
memberships._fetchRequest(url, token, method, params) ⇒ Promise
Return Fetch Promise
Kind: instance method of Memberships
Param | Type | Description |
---|
url | String | Where request go |
token | String | auth user token |
method | String | request method must be uppercase, default 'GET' |
params | Object | request params object |