Fixed some code style issues

This commit is contained in:
Alexander Corn 2017-12-28 00:32:06 -05:00
parent 0b8dd57a40
commit 5da6e40ebb

View File

@ -13,7 +13,8 @@ module.exports = SteamCommunity;
SteamCommunity.SteamID = SteamID; SteamCommunity.SteamID = SteamID;
SteamCommunity.ConfirmationType = require('./resources/EConfirmationType.js'); SteamCommunity.ConfirmationType = require('./resources/EConfirmationType.js');
SteamCommunity.EResult = require('./resources/EResult.js'); SteamCommunity.EResult = require('./resources/EResult.js')
function SteamCommunity(options) { function SteamCommunity(options) {
options = options || {}; options = options || {};
@ -410,19 +411,23 @@ SteamCommunity.prototype.getTradeURL = function(callback) {
} else { } else {
callback(new Error("Malformed response")); callback(new Error("Malformed response"));
} }
}, "tradeoffermanager"); }, "steamcommunity");
}; };
SteamCommunity.prototype.changeTradeURL = function (callback) { SteamCommunity.prototype.changeTradeURL = function(callback) {
this._myProfile("/tradeoffers/newtradeurl", { this._myProfile("/tradeoffers/newtradeurl", {"sessionid": this.getSessionID()}, (err, response, body) => {
"sessionid": this.getSessionID() if (!callback) {
}, (err, response, body) => { return;
if (err || response.statusCode != 200) }
return callback(err || "HTTP error " + response.statusCode);
if (!body || typeof body !== "string" || body.length < 3 || body.indexOf('"') !== 0) if (!body || typeof body !== "string" || body.length < 3 || body.indexOf('"') !== 0) {
return callback(new Error("Malformed response")); callback(new Error("Malformed response"));
return callback(null, body.replace(/\"/g, '')); //"t1o2k3e4n" => t1o2k3e4n return;
}, "tradeoffermanager"); }
var newToken = body.replace(/"/g, ''); //"t1o2k3e4n" => t1o2k3e4n
callback(null, "https://steamcommunity.com/tradeoffer/new/?partner=" + this.steamID.accountid + "&token=" + newToken, newToken);
}, "steamcommunity");
}; };
SteamCommunity.prototype._myProfile = function(endpoint, form, callback) { SteamCommunity.prototype._myProfile = function(endpoint, form, callback) {