Skip to content

Commit

Permalink
Merge pull request #16 from mrvisser/user-delete
Browse files Browse the repository at this point in the history
(UserDelete) Add methods for deleting users
  • Loading branch information
simong committed May 27, 2015
2 parents 42989c1 + 9cc5f66 commit 6c590c8
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions lib/api.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var RestUtil = require('./util');
* @param {String} password The password the user should use to log into the global administrator tenant
* @param {String} displayName The display name of the administrator user
* @param {Object} [opts] Additional optional profile parameters for the user
* @param {Function} callback Standard callback method
* @param {Function} callback Standard callback function
* @param {Object} callback.err An error that occurred, if any
* @param {User} callback.user The user object that was created
*/
Expand All @@ -49,7 +49,7 @@ var createGlobalAdminUser = module.exports.createGlobalAdminUser = function(rest
* @param {String} password The password the user should use to login
* @param {String} displayName The display name of the administrator user
* @param {Object} [opts] Additional optional profile parameters for the user
* @param {Function} callback Standard callback method
* @param {Function} callback Standard callback function
* @param {Object} callback.err An error that occurred, if any
* @param {User} callback.user The user object that was created
*/
Expand All @@ -66,7 +66,7 @@ var createTenantAdminUser = module.exports.createTenantAdminUser = function(rest
* @param {String} password The password the user should use to login
* @param {String} displayName The display name of the administrator user
* @param {Object} [opts] Additional optional profile parameters for the user
* @param {Function} callback Standard callback method
* @param {Function} callback Standard callback function
* @param {Object} callback.err An error that occurred, if any
* @param {User} callback.user The user object that was created
*/
Expand All @@ -87,14 +87,38 @@ var createTenantAdminUserOnTenant = module.exports.createTenantAdminUserOnTenant
* @param {String} [opts.timezone] The user's timezone
* @param {String} [opts.publicAlias] The publically-available alias for users to see when the user's display name is protected
* @param {Boolean} [opts.acceptedTC] Whether or not the user accepts the Terms and Conditions
* @param {Function} callback Standard callback method takes arguments `err` and `resp`
* @param {Object} callback.err Error object containing error code and error message
* @param {Function} callback Standard callback function
* @param {Object} callback.err An error that occurred, if any
* @param {User} callback.response A User object representing the created user
*/
var createUser = module.exports.createUser = function(restCtx, username, password, displayName, opts, callback) {
_createUser(restCtx, null, username, password, displayName, opts, callback);
};

/**
* Delete a user
*
* @param {RestContext} restCtx Standard REST Context object that contains the current tenant URL and the current user credentials
* @param {String} userId The id of the user to delete
* @param {Function} callback Standard callback function
* @param {Object} callback.err An error that occurred, if any
*/
var deleteUser = module.exports.deleteUser = function(restCtx, userId, callback) {
RestUtil.RestRequest(restCtx, '/api/user/' + RestUtil.encodeURIComponent(userId), 'DELETE', null, callback);
};

/**
* Restore a user
*
* @param {RestContext} restCtx Standard REST Context object that contains the current tenant URL and the current user credentials
* @param {String} userId The id of the user to restore
* @param {Function} callback Standard callback function
* @param {Object} callback.err An error that occurred, if any
*/
var restoreUser = module.exports.restoreUser = function(restCtx, userId, callback) {
RestUtil.RestRequest(restCtx, '/api/user/' + RestUtil.encodeURIComponent(userId) + '/restore', 'POST', null, callback);
};

/**
* Creates a user on a particular tenant through the REST API
*
Expand All @@ -109,8 +133,8 @@ var createUser = module.exports.createUser = function(restCtx, username, passwor
* @param {String} [opts.timezone] The user's timezone
* @param {String} [opts.publicAlias] The publically-available alias for users to see when the user's display name is protected
* @param {Boolean} [opts.acceptedTC] Whether or not the user accepts the Terms and Conditions
* @param {Function} callback Standard callback method takes arguments `err` and `resp`
* @param {Object} callback.err Error object containing error code and error message
* @param {Function} callback Standard callback function
* @param {Object} callback.err An error that occurred, if any
* @param {User} callback.response A User object representing the created user
*/
var createUserOnTenant = module.exports.createUserOnTenant = function(restCtx, tenantAlias, username, password, displayName, opts, callback) {
Expand Down Expand Up @@ -145,11 +169,11 @@ var getUser = module.exports.getUser = function(restCtx, userId, callback) {
/**
* Update a user's basic profile through the REST API.
*
* @param {RestContext} restCtx Standard REST Context object that contains the current tenant URL and the current user credentials
* @param {String} userId The user id of the user we're trying to update
* @param {Object} params Object representing the profile fields that need to be updated. The keys are the profile fields, the values are the profile field values
* @param {Function} callback Standard callback function
* @param {Object} callback.err Standard error object, if any
* @param {RestContext} restCtx Standard REST Context object that contains the current tenant URL and the current user credentials
* @param {String} userId The user id of the user we're trying to update
* @param {Object} params Object representing the profile fields that need to be updated. The keys are the profile fields, the values are the profile field values
* @param {Function} callback Standard callback function
* @param {Object} callback.err Standard error object, if any
*/
var updateUser = module.exports.updateUser = function(restCtx, userId, params, callback) {
RestUtil.RestRequest(restCtx, '/api/user/' + RestUtil.encodeURIComponent(userId), 'POST', params, callback);
Expand Down Expand Up @@ -273,7 +297,7 @@ var acceptTermsAndConditions = module.exports.acceptTermsAndConditions = functio
* @param {String} password The password the user should use to login
* @param {String} displayName The display name of the administrator user
* @param {Object} [opts] Additional optional profile parameters for the user
* @param {Function} callback Standard callback method
* @param {Function} callback Standard callback function
* @param {Object} callback.err An error that occurred, if any
* @param {User} callback.user The user object that was created
* @api private
Expand Down Expand Up @@ -303,8 +327,8 @@ var _createTenantAdminUser = function(restCtx, tenantAlias, username, password,
* @param {String} [opts.timezone] The user's timezone
* @param {String} [opts.publicAlias] The publically-available alias for users to see when the user's display name is protected
* @param {Boolean} [opts.acceptedTC] Whether or not the user accepts the Terms and Conditions
* @param {Function} callback Standard callback method takes arguments `err` and `resp`
* @param {Object} callback.err Error object containing error code and error message
* @param {Function} callback Standard callback function
* @param {Object} callback.err An error that occurred, if any
* @param {User} callback.response A User object representing the created user
* @api private
*/
Expand Down

0 comments on commit 6c590c8

Please sign in to comment.