diff --git a/README.md b/README.md index c195011..db6c3ce 100644 --- a/README.md +++ b/README.md @@ -367,6 +367,7 @@ Methods are provided within `client.promotions.*` namespace. - [Create Promotion Campaign](#create-promotion-campaign) - [Validate Promotion Campaign](#validate-promotion-campaign) - [List Promotion's Tiers](#list-promotions-tiers) +- [List All Promotion Tiers](#doc-list-all-promotion-tiers) - [Create Promotion's Tier](#create-promotions-tier) - [Redeem Promotion's Tier](#redeem-promotions-tier) - [Update Promotion's Tier](#update-promotions-tier) @@ -386,6 +387,14 @@ client.promotions.validate(validationContext) client.promotions.tiers.list(promotionCampaignId) ``` Check [promotion's tier object](http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-promotion-object) +#### [List All Promotion Tiers] +```javascript +client.promotions.tiers.listAll() +client.promotions.tiers.listAll({ is_available: true }) +client.promotions.tiers.listAll({ page: 2, limit: 10 }) +``` +You can list all currently available promotions by specifying `is_available` flag. + #### [Create Promotion's Tier] ```javascript client.promotions.tiers.create(promotionId, promotionsTier) @@ -1122,6 +1131,7 @@ Bug reports and pull requests are welcome through [GitHub Issues](https://github [Create Promotion Campaign]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-promotion-campaign [Validate Promotion Campaign]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#validate-promotions-1 [List Promotion's Tiers]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-promotions +[Doc List All Promotion Tiers]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-promotion-tiers [Create Promotion's Tier]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-promotion-tier-to-campaign [Redeem Promotion's Tier]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#redeem-promotion [Update Promotion's Tier]: http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-promotion diff --git a/src/PromotionTiers.js b/src/PromotionTiers.js index 3282453..351af2f 100644 --- a/src/PromotionTiers.js +++ b/src/PromotionTiers.js @@ -7,6 +7,10 @@ module.exports = class PromotionTiers { this.client = client } + listAll (params = {}, callback) { + return this.client.get('/promotions/tiers', params, callback) + } + list (promotionId, callback) { return this.client.get(`/promotions/${encode(promotionId)}/tiers`, null, callback) } diff --git a/test/promotions-api.spec.js b/test/promotions-api.spec.js index e466e19..f282278 100644 --- a/test/promotions-api.spec.js +++ b/test/promotions-api.spec.js @@ -52,6 +52,31 @@ describe('Promotions API', function () { }) describe('promotion tiers', function () { + describe('all tiers', function () { + it('should list all promotion tiers in specific page', function (done) { + var server = nock('https://api.voucherify.io', reqWithoutBody) + .get('/v1/promotions/tiers?limit=10&page=2') + .reply(200, {}) + + client.promotions.tiers.listAll({ limit: 10, page: 2 }) + .then(function () { + server.done() + done() + }) + }) + it('should list all available promotion tiers', function (done) { + var server = nock('https://api.voucherify.io', reqWithoutBody) + .get('/v1/promotions/tiers?is_available=true') + .reply(200, {}) + + client.promotions.tiers.listAll({ is_available: true }) + .then(function () { + server.done() + done() + }) + }) + }) + it('should list promotion tiers', function (done) { var server = nock('https://api.voucherify.io', reqWithoutBody) .get('/v1/promotions/promo_test_id/tiers')