mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-01-13 20:22:20 +08:00
Slight refactor for help.js component
This commit is contained in:
parent
ec1284e961
commit
7ae8a97a0f
@ -2,6 +2,8 @@ const SteamCommunity = require('../index.js');
|
||||
|
||||
const Helpers = require('./helpers.js');
|
||||
|
||||
const HELP_SITE_DOMAIN = 'https://help.steampowered.com';
|
||||
|
||||
/**
|
||||
* Restore a previously removed steam package from your steam account.
|
||||
* @param {int|string} packageID
|
||||
@ -9,30 +11,14 @@ const Helpers = require('./helpers.js');
|
||||
*/
|
||||
SteamCommunity.prototype.restorePackage = function(packageID, callback) {
|
||||
this.httpRequestPost({
|
||||
"uri": "https://help.steampowered.com/wizard/AjaxDoPackageRestore",
|
||||
"form": {
|
||||
"packageid": packageID,
|
||||
"sessionid": this.getSessionID('https://help.steampowered.com'),
|
||||
"wizard_ajax": 1
|
||||
uri: HELP_SITE_DOMAIN + '/wizard/AjaxDoPackageRestore',
|
||||
form: {
|
||||
packageid: packageID,
|
||||
sessionid: this.getSessionID(HELP_SITE_DOMAIN),
|
||||
wizard_ajax: 1
|
||||
},
|
||||
"json": true
|
||||
}, (err, res, body) => {
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!body.success) {
|
||||
callback(body.errorMsg ? new Error(body.errorMsg) : Helpers.eresultError(body.success));
|
||||
return;
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
json: true
|
||||
}, wizardAjaxHandler(callback));
|
||||
};
|
||||
|
||||
/**
|
||||
@ -42,14 +28,23 @@ SteamCommunity.prototype.restorePackage = function(packageID, callback) {
|
||||
*/
|
||||
SteamCommunity.prototype.removePackage = function(packageID, callback) {
|
||||
this.httpRequestPost({
|
||||
"uri": "https://help.steampowered.com/wizard/AjaxDoPackageRemove",
|
||||
"form": {
|
||||
"packageid": packageID,
|
||||
"sessionid": this.getSessionID('https://help.steampowered.com'),
|
||||
"wizard_ajax": 1
|
||||
uri: HELP_SITE_DOMAIN + '/wizard/AjaxDoPackageRemove',
|
||||
form: {
|
||||
packageid: packageID,
|
||||
sessionid: this.getSessionID(HELP_SITE_DOMAIN),
|
||||
wizard_ajax: 1
|
||||
},
|
||||
"json": true
|
||||
}, (err, res, body) => {
|
||||
json: true
|
||||
}, wizardAjaxHandler(callback));
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a handler for wizard ajax HTTP requests.
|
||||
* @param {function} callback
|
||||
* @returns {(function(*=, *, *): void)|*}
|
||||
*/
|
||||
function wizardAjaxHandler(callback) {
|
||||
return (err, res, body) => {
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
@ -65,5 +60,5 @@ SteamCommunity.prototype.removePackage = function(packageID, callback) {
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user