v3: port getBuyList and shared.updateStore

This commit is contained in:
Matteo Pagliazzi
2016-03-26 16:25:15 +01:00
parent 93b80352c4
commit 3002c9b7fd
5 changed files with 130 additions and 27 deletions

View File

@@ -46,6 +46,32 @@ api.getUser = {
},
};
/**
* @api {get} /user/inventory/buy Get the gear items available for purchase for the current user
* @apiVersion 3.0.0
* @apiName UserGetBuyList
* @apiGroup User
*
* @apiSuccess {Object} list The buy list
*/
api.getBuyList = {
method: 'GET',
middlewares: [authWithHeaders(), cron],
url: '/user/inventory/buy',
async handler (req, res) {
let list = _.cloneDeep(common.updateStore(res.locals.user));
// return text and notes strings
_.each(list, item => {
_.each(item, (itemPropVal, itemPropKey) => {
if (_.isFunction(itemPropVal) && itemPropVal.i18nLangFunc) item[itemPropKey] = itemPropVal(req.language);
});
});
res.respond(200, list);
},
};
/**
* @api {delete} /user DELETE an authenticated user's profile
* @apiVersion 3.0.0