steamcommunity 3.43.1 → 3.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,61 +1,64 @@
1
- const SteamCommunity = require('../index.js');
2
-
3
- const Helpers = require('./helpers.js');
4
-
5
- /**
6
- * Restore a previously removed steam package from your steam account.
7
- * @param {int|string} packageID
8
- * @param {function} callback
9
- */
10
- SteamCommunity.prototype.restorePackage = function(packageID, callback) {
11
- this.httpRequestPost({
12
- "uri": "https://help.steampowered.com/wizard/AjaxDoPackageRestore",
13
- "form": {
14
- "packageid": packageID,
15
- "sessionid": this.getSessionID('https://help.steampowered.com'),
16
- "wizard_ajax": 1
17
- },
18
- "json": true
19
- }, (err, res, body) => {
20
- if (err) {
21
- callback(err);
22
- return;
23
- }
24
-
25
- if (!body.success) {
26
- callback(body.errorMsg ? new Error(body.errorMsg) : Helpers.eresultError(body.success));
27
- return;
28
- }
29
-
30
- callback(null);
31
- });
32
- };
33
-
34
- /**
35
- * Remove a steam package from your steam account.
36
- * @param {int|string} packageID
37
- * @param {function} callback
38
- */
39
- SteamCommunity.prototype.removePackage = function(packageID, callback) {
40
- this.httpRequestPost({
41
- "uri": "https://help.steampowered.com/wizard/AjaxDoPackageRemove",
42
- "form": {
43
- "packageid": packageID,
44
- "sessionid": this.getSessionID('https://help.steampowered.com'),
45
- "wizard_ajax": 1
46
- },
47
- "json": true
48
- }, (err, res, body) => {
49
- if (err) {
50
- callback(err);
51
- return;
52
- }
53
-
54
- if (!body.success) {
55
- callback(body.errorMsg ? new Error(body.errorMsg) : Helpers.eresultError(body.success));
56
- return;
57
- }
58
-
59
- callback(null);
60
- });
61
- };
1
+ const SteamCommunity = require('../index.js');
2
+
3
+ const Helpers = require('./helpers.js');
4
+
5
+ const HELP_SITE_DOMAIN = 'https://help.steampowered.com';
6
+
7
+ /**
8
+ * Restore a previously removed steam package from your steam account.
9
+ * @param {int|string} packageID
10
+ * @param {function} callback
11
+ */
12
+ SteamCommunity.prototype.restorePackage = function(packageID, callback) {
13
+ this.httpRequestPost({
14
+ uri: HELP_SITE_DOMAIN + '/wizard/AjaxDoPackageRestore',
15
+ form: {
16
+ packageid: packageID,
17
+ sessionid: this.getSessionID(HELP_SITE_DOMAIN),
18
+ wizard_ajax: 1
19
+ },
20
+ json: true
21
+ }, wizardAjaxHandler(callback));
22
+ };
23
+
24
+ /**
25
+ * Remove a steam package from your steam account.
26
+ * @param {int|string} packageID
27
+ * @param {function} callback
28
+ */
29
+ SteamCommunity.prototype.removePackage = function(packageID, callback) {
30
+ this.httpRequestPost({
31
+ uri: HELP_SITE_DOMAIN + '/wizard/AjaxDoPackageRemove',
32
+ form: {
33
+ packageid: packageID,
34
+ sessionid: this.getSessionID(HELP_SITE_DOMAIN),
35
+ wizard_ajax: 1
36
+ },
37
+ json: true
38
+ }, wizardAjaxHandler(callback));
39
+ };
40
+
41
+ /**
42
+ * Returns a handler for wizard ajax HTTP requests.
43
+ * @param {function} callback
44
+ * @returns {(function(*=, *, *): void)|*}
45
+ */
46
+ function wizardAjaxHandler(callback) {
47
+ return (err, res, body) => {
48
+ if (!callback) {
49
+ return;
50
+ }
51
+
52
+ if (err) {
53
+ callback(err);
54
+ return;
55
+ }
56
+
57
+ if (!body.success) {
58
+ callback(body.errorMsg ? new Error(body.errorMsg) : Helpers.eresultError(body.success));
59
+ return;
60
+ }
61
+
62
+ callback(null);
63
+ };
64
+ }