Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.

Commit 0dcb855

Browse files
committed
feat(api): add list plans method
1 parent ed1a43f commit 0dcb855

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

lib/paddle/api.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,21 @@ module.exports = class {
5959
*/
6060
async listSubscriptions(state = 'active') {
6161
return this._returnResponseIf200(this._got(PATH_LIST_USERS, {
62-
form: {
63-
vendor_id: this._vendorId,
64-
vendor_auth_code: this._authCode,
65-
state
66-
}
62+
/**
63+
*
64+
* @param {String} plan return only specific plan info
65+
* @returns
66+
*/
67+
async listPlans(plan) {
68+
const form = {
69+
vendor_id: this._vendorId,
70+
vendor_auth_code: this._authCode
71+
}
72+
if (plan) {
73+
form.plan = plan
74+
}
75+
return this._returnResponseIf200(this._got(PATH_LIST_PLANS, {
76+
form
6777
}))
6878
}
6979

test-e2e/spec/api.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,14 @@ test('list all products', async () => {
1919
test('list all subscriptions', async () => {
2020
const subs = await api.listSubscriptions()
2121
expect(subs).toHaveLength(0)
22+
})
23+
24+
test('list all plans', async () => {
25+
const subs = await api.listPlans()
26+
expect(subs).toHaveLength(2)
27+
})
28+
29+
test('list one plan', async () => {
30+
const subs = await api.listPlans(33590)
31+
expect(subs).toHaveLength(1)
2232
})

0 commit comments

Comments
 (0)