From 89a1df67ec083cc4627b15937807109c12199161 Mon Sep 17 00:00:00 2001 From: Andrew Dassonville Date: Wed, 6 Jul 2016 16:20:42 -0700 Subject: [PATCH] Add ability to get user aliases --- classes/CSteamUser.js | 4 ++++ components/users.js | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/classes/CSteamUser.js b/classes/CSteamUser.js index eb7faaf..a166b2e 100644 --- a/classes/CSteamUser.js +++ b/classes/CSteamUser.js @@ -150,6 +150,10 @@ CSteamUser.prototype.inviteToGroup = function(groupID, callback) { this._community.inviteUserToGroup(this.steamID, groupID, callback); }; +CSteamUser.prototype.getAliases = function(callback) { + this._community.getUserAliases(this.steamID, callback); +}; + CSteamUser.prototype.getInventoryContexts = function(callback) { this._community.getUserInventoryContexts(this.steamID, callback); }; diff --git a/components/users.js b/components/users.js index 72b7169..ea98c7e 100644 --- a/components/users.js +++ b/components/users.js @@ -190,6 +190,32 @@ SteamCommunity.prototype.inviteUserToGroup = function(userID, groupID, callback) }, "steamcommunity"); }; +SteamCommunity.prototype.getUserAliases = function(userID, callback) { + if(typeof userID === 'string') { + userID = new SteamID(userID); + } + + var endpoint = "/profiles/" + userID.getSteamID64(); + + var self = this; + this.httpRequestGet({ + "uri": "https://steamcommunity.com" + endpoint + "/ajaxaliases", + "json": true + }, function(err, response, body) { + if (err) { + callback(err); + return; + } + + if(typeof body !== 'object') { + callback(new Error("Malformed response")); + return; + } + + callback(null, body); + }, "steamcommunity"); +}; + SteamCommunity.prototype.getUserInventoryContexts = function(userID, callback) { if(typeof userID === 'string') { userID = new SteamID(userID);