Ported Hourglass Purchase, add unit tests. Created new hourglass purchase route and tests

This commit is contained in:
Keith Holliday
2016-04-01 08:11:26 -05:00
parent 3089658cc7
commit dd12443166
8 changed files with 236 additions and 36 deletions

View File

@@ -676,4 +676,27 @@ api.disableClasses = {
},
};
/**
* @api {post} /user/purchase-hourglass/:type/:key Purchase Hourglass.
* @apiVersion 3.0.0
* @apiName UserPurchaseHourglass
* @apiGroup User
*
* @apiParam {string} type {pets|mounts}. The type of item to purchase
* @apiParam {string} key Ex: {MantisShrimp-Base}. The key for the mount/pet
*
* @apiSuccess {Object} data `items purchased.plan.consecutive`
*/
api.userPurchaseHourglass = {
method: 'POST',
middlewares: [authWithHeaders(), cron],
url: '/user/purchase-hourglass/:type/:key',
async handler (req, res) {
let user = res.locals.user;
let purchaseHourglassResponse = common.ops.purchaseHourglass(user, req, res.analytics);
await user.save();
res.respond(200, purchaseHourglassResponse);
},
};
module.exports = api;