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

Commit a700319

Browse files
committed
feat(api): add get plan by id method
1 parent 3aa266a commit a700319

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/paddle/api.js

+16
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,22 @@ module.exports = class {
163163
}))
164164
}
165165

166+
/**
167+
*
168+
* @param {String} plan subscription plan id
169+
* @returns
170+
*/
171+
async getPlan({ plan_id }) {
172+
const form = {
173+
vendor_id: this._vendorId,
174+
vendor_auth_code: this._authCode,
175+
plan: plan_id
176+
}
177+
return this._returnResponseIf200(this._request(this._vendorsBaseUrl + PATH_LIST_PLANS, {
178+
form
179+
}))
180+
}
181+
166182
/**
167183
*
168184
* @returns

test-e2e/spec/api.spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ test('list all plans', async () => {
2929
expect(subs.length).toBeGreaterThanOrEqual(2)
3030
})
3131

32+
test('get plan by id', async () => {
33+
const subs = await api.getPlan({ plan_id: 33590 })
34+
expect(subs.length).toEqual(1)
35+
})
36+
3237
test('list one plan', async () => {
3338
const subs = await api.listPlans(33590)
3439
expect(subs).toHaveLength(1)

0 commit comments

Comments
 (0)