Documentation - coupon

closes #8109
This commit is contained in:
MathWhiz
2016-10-07 09:26:38 -04:00
committed by Blade Barringer
parent 9615a332a5
commit d4aac1ee4b
2 changed files with 25 additions and 16 deletions

View File

@@ -29,14 +29,6 @@ describe('POST /coupons/generate/:event', () => {
}); });
}); });
it('returns an error if event is missing', async () => {
await expect(user.post('/coupons/generate')).to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: 'Not found.',
});
});
it('returns an error if event is invalid', async () => { it('returns an error if event is invalid', async () => {
await expect(user.post('/coupons/generate/notValid?count=1')).to.eventually.be.rejected.and.eql({ await expect(user.post('/coupons/generate/notValid?count=1')).to.eventually.be.rejected.and.eql({
code: 400, code: 400,

View File

@@ -10,13 +10,25 @@ import couponCode from 'coupon-code';
let api = {}; let api = {};
/**
* @apiDefine Sudo Sudo Users
* Moderators with all access permissions.
*/
/** /**
* @api {get} /api/v3/coupons Get coupons * @api {get} /api/v3/coupons Get coupons
* @apiDescription Sudo users only
* @apiName GetCoupons * @apiName GetCoupons
* @apiGroup Coupon * @apiGroup Coupon
* @apiPermission sudo
* *
* @apiSuccess {String} Coupons in CSV format * @apiSuccess {String} Coupons in CSV format
*
* @apiSuccessExample {String}
* code,event,date,user
* GJG4-WEA4-QX3P,wondercon,1476929528704,user-uuid
* TT32-EYQA-JPBT,wondercon,1476929528705,
* V3EK-GE8M-LMJ4,wondercon,1476929528705,another-user-uuid
*
*/ */
api.getCoupons = { api.getCoupons = {
method: 'GET', method: 'GET',
@@ -40,14 +52,17 @@ api.getCoupons = {
/** /**
* @api {post} /api/v3/coupons/generate/:event Generate coupons for an event * @api {post} /api/v3/coupons/generate/:event Generate coupons for an event
* @apiDescription Sudo users only
* @apiName GenerateCoupons * @apiName GenerateCoupons
* @apiGroup Coupon * @apiGroup Coupon
* @apiPermission sudo
* *
* @apiParam {String} event The event for which the coupon should be generated * @apiParam (Path) {String=wondercon,google_6mo} event The event for which the coupon should be generated
* @apiParam {Number} count Query parameter to specify the number of coupon codes to generate * @apiParam (Query) {Number} count The number of coupon codes to generate
* *
* @apiSuccess {Array} data Generated coupons * @apiSuccess {Array} data Generated coupons
*
* @apiError (400) {BadRequest} CouponValidationError The request was missing the count query parameter or used an invalid event.
*
*/ */
api.generateCoupons = { api.generateCoupons = {
method: 'POST', method: 'POST',
@@ -66,11 +81,11 @@ api.generateCoupons = {
}; };
/** /**
* @api {post} /api/v3/coupons/enter/:code Enter coupon code * @api {post} /api/v3/coupons/enter/:code Redeem a coupon code
* @apiName EnterCouponCode * @apiName RedeemCouponCode
* @apiGroup Coupon * @apiGroup Coupon
* *
* @apiParam {String} code The coupon code to apply * @apiParam (Path) {String} code The coupon code to apply
* *
* @apiSuccess {Object} data User object * @apiSuccess {Object} data User object
*/ */
@@ -96,7 +111,9 @@ api.enterCouponCode = {
* @apiName ValidateCoupon * @apiName ValidateCoupon
* @apiGroup Coupon * @apiGroup Coupon
* *
* @apiSuccess {Boolean} data.valid True or false * @apiParam (Path) {String} code The coupon code to validate
*
* @apiSuccess {Boolean} data.valid True or False
*/ */
api.validateCoupon = { api.validateCoupon = {
method: 'POST', method: 'POST',