From ce764ca28ea3d5d1855929bcedf820dbe6ddb74a Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Tue, 15 Sep 2015 15:41:57 -0400 Subject: [PATCH] WIP(hourglass): Mystery sets API route --- common/locales/en/subscriber.json | 3 ++- common/script/index.coffee | 10 +++++++++- website/src/routes/apiv2.coffee | 9 +++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/common/locales/en/subscriber.json b/common/locales/en/subscriber.json index e496bf2364..a47ca9ab76 100644 --- a/common/locales/en/subscriber.json +++ b/common/locales/en/subscriber.json @@ -73,5 +73,6 @@ "typeNotAllowedHourglass": "Item type not supported for purchase with Mystic Hourglass. Allowed types: ", "petsNotAllowedHourglass": "Pet not available for purchase with Mystic Hourglass.", "mountsNotAllowedHourglass": "Mount not available for purchase with Mystic Hourglass.", - "hourglassPurchase": "Purchased an item using a Mystic Hourglass!" + "hourglassPurchase": "Purchased an item using a Mystic Hourglass!", + "hourglassPurchaseSet": "Purchased an item set using a Mystic Hourglass!" } diff --git a/common/script/index.coffee b/common/script/index.coffee index a11376201f..8714ff24ac 100644 --- a/common/script/index.coffee +++ b/common/script/index.coffee @@ -1016,7 +1016,7 @@ api.wrap = (user, main=true) -> analytics?.track('acquire item', analyticsData) user.purchased.plan.consecutive.trinkets-- - cb? null, _.pick(user,$w 'items purchased.plan.consecutive') + cb? {code:200, message:i18n.t('hourglassPurchaseSet', req.language)}, _.pick(user,$w 'items purchased.plan.consecutive') hourglassPurchase: (req, cb, analytics)-> {type, key} = req.params @@ -1029,6 +1029,14 @@ api.wrap = (user, main=true) -> user.items.pets[key] = 5 if type is 'mounts' user.items.mounts[key] = true + analyticsData = { + uuid: user._id, + itemKey: key, + itemType: type, + acquireMethod: 'Hourglass', + category: 'behavior' + } + analytics?.track('acquire item', analyticsData) cb? {code:200, message:i18n.t('hourglassPurchase', req.language)}, _.pick(user,$w 'items purchased.plan.consecutive') sell: (req, cb) -> diff --git a/website/src/routes/apiv2.coffee b/website/src/routes/apiv2.coffee index 3757b3142a..4612509ed3 100644 --- a/website/src/routes/apiv2.coffee +++ b/website/src/routes/apiv2.coffee @@ -197,6 +197,15 @@ module.exports = (swagger, v2) -> ] action: user.hourglassPurchase + "/user/inventory/hourglass/mysterySet/{key}" + spec: + method: 'POST' + description: "Purchase a Mystery Item Set using a Mystic Hourglass" + parameters:[ + path('key',"The key for the Mystery Set you're purchasing (call /content route for available keys)",'string') + ] + action: user.buyMysterySet + "/user/inventory/feed/{pet}/{food}": spec: method: 'POST'