From 6f8456882a662cbe794521add630e7352afbd9a5 Mon Sep 17 00:00:00 2001 From: hell00world Date: Thu, 28 Dec 2017 00:19:57 +0100 Subject: [PATCH] Added changeTradeURL method --- index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e95ced9..dab68fc 100644 --- a/index.js +++ b/index.js @@ -382,6 +382,18 @@ SteamCommunity.prototype.getTradeURL = function(callback) { }, "tradeoffermanager"); }; +SteamCommunity.prototype.changeTradeURL = function (callback) { + this._myProfile("/tradeoffers/newtradeurl", { + "sessionid": this.getSessionID() + }, (err, response, body) => { + if (err || response.statusCode != 200) + return callback(err || "HTTP error " + response.statusCode); + if (!body || typeof body !== "string" || body.length < 3 || body.indexOf('"') !== 0) + return callback(new Error("Malformed response")); + return callback(null, body.replace(/\"/g, '')); //"t1o2k3e4n" => t1o2k3e4n + }, "tradeoffermanager"); +}; + SteamCommunity.prototype._myProfile = function(endpoint, form, callback) { var self = this; @@ -442,4 +454,4 @@ require('./classes/CSteamUser.js'); /** @callback SteamCommunity~genericErrorCallback @param {Error|null} err - An Error object on failure, or null on success - */ \ No newline at end of file + */