Merge pull request #186 from hell00world/master

Added changeTradeURL method
This commit is contained in:
Alex Corn 2017-12-28 00:21:00 -05:00 committed by GitHub
commit 0b8dd57a40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -413,6 +413,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;
@ -473,4 +485,4 @@ require('./classes/CSteamUser.js');
/**
@callback SteamCommunity~genericErrorCallback
@param {Error|null} err - An Error object on failure, or null on success
*/
*/