From 9ee49d4f1518af2dc729777a9e3cf83313fc1b12 Mon Sep 17 00:00:00 2001 From: Alexander Corn Date: Sat, 25 Jul 2015 01:24:28 -0400 Subject: [PATCH] Added profileSettings method --- components/profile.js | 35 +++++++++++++++++++++++++++++++++++ index.js | 1 + 2 files changed, 36 insertions(+) create mode 100644 components/profile.js diff --git a/components/profile.js b/components/profile.js new file mode 100644 index 0000000..07fadb7 --- /dev/null +++ b/components/profile.js @@ -0,0 +1,35 @@ +var SteamCommunity = require('../index.js'); + +SteamCommunity.PrivacyState = { + "Private": 1, + "FriendsOnly": 2, + "Public": 3 +}; + +var CommentPrivacyState = { + "1": "commentselfonly", + "2": "commentfriendsonly", + "3": "commentanyone" +}; + +SteamCommunity.prototype.profileSettings = function(profile, comments, inventory, inventoryGiftPrivacy, emailConfirmation, callback) { + this._myProfile("edit/settings", { + "sessionID": this.getSessionID(), + "type": "profileSettings", + "privacySetting": profile, + "commentSetting": CommentPrivacyState[comments], + "inventoryPrivacySetting": inventory, + "inventoryGiftPrivacy": inventoryGiftPrivacy ? 1 : 0, + "tradeConfirmationSetting": emailConfirmation ? 1 : 0 + }, function(err, response, body) { + if(!callback) { + return; + } + + if(err || response.statusCode != 200) { + callback(err || new Error("HTTP error " + response.statusCode)); + } else { + callback(null); + } + }); +}; diff --git a/index.js b/index.js index 7b3861c..a941ffb 100644 --- a/index.js +++ b/index.js @@ -314,3 +314,4 @@ require('./classes/CMarketSearchResult.js'); require('./classes/CSteamGroup.js'); require('./classes/CSteamUser.js'); require('./components/chat.js'); +require('./components/profile.js');