Skip to content

Commit

Permalink
feat(api): add get plan by id method
Browse files Browse the repository at this point in the history
  • Loading branch information
stfsy committed Jan 3, 2023
1 parent 5717c33 commit a1b1fcd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/paddle/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ module.exports = class {
}))
}

/**
*
* @param {String} plan subscription plan id
* @returns
*/
async getPlan({ plan_id }) {
const form = {
vendor_id: this._vendorId,
vendor_auth_code: this._authCode,
plan: plan_id
}
return this._returnResponseIf200(this._request(this._vendorsBaseUrl + PATH_LIST_PLANS, {
form
}))
}

/**
*
* @returns
Expand Down
5 changes: 5 additions & 0 deletions test-e2e/spec/api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ test('list all plans', async () => {
expect(subs.length).toBeGreaterThanOrEqual(2)
})

test('get plan by id', async () => {
const subs = await api.getPlan({ plan_id: 33590 })
expect(subs.length).toEqual(1)
})

test('list one plan', async () => {
const subs = await api.listPlans(33590)
expect(subs).toHaveLength(1)
Expand Down

0 comments on commit a1b1fcd

Please sign in to comment.