From 58516d4ed1134863971025ba1e35a68230cd72d7 Mon Sep 17 00:00:00 2001 From: jfx Date: Sat, 23 May 2020 16:24:20 +1000 Subject: [PATCH] Add openBoosterPack --- components/market.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/components/market.js b/components/market.js index ac35725..8545bbc 100644 --- a/components/market.js +++ b/components/market.js @@ -109,6 +109,43 @@ SteamCommunity.prototype.turnItemIntoGems = function(appid, assetid, expectedGem }) }; +/** + * Open a booster pack. + * @param {int} appid + * @param {int|string} assetid + * @param {function} callback + */ +SteamCommunity.prototype.openBoosterPack = function(appid, assetid, callback) { + this._myProfile({ + "endpoint": "ajaxunpackbooster/", + "json": true, + "checkHttpError": false + }, { + "appid": appid, + "communityitemid": assetid, + "sessionid": this.getSessionID() + }, (err, res, body) => { + if (err) { + callback(err); + return; + } + + if (body.success && body.success != SteamCommunity.EResult.OK) { + let err = new Error(body.message || SteamCommunity.EResult[body.success]); + err.eresult = err.code = body.success; + callback(err); + return; + } + + if (!body.rgItems) { + callback(new Error("Malformed response")); + return; + } + + callback(null, body.rgItems); + }) +}; + /** * Get details about a gift in your inventory. * @param {string} giftID