Merge branch 'api-v3-hourglass-purchase' of https://github.com/TheHollidayInn/habitrpg into TheHollidayInn-api-v3-hourglass-purchase2

This commit is contained in:
Matteo Pagliazzi
2016-04-01 16:28:20 +02:00
8 changed files with 236 additions and 36 deletions

View File

@@ -699,4 +699,27 @@ api.purchase = {
},
};
/**
* @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;