App42 Cloud API

REST Cloud SDK

User

Creates User for the App. App42 Cloud API's provides a complete User Management for any Mobile or Web App. It supports User registration, retrieval, state management e.g. lock, delete and Authentication.

Along with User management the platform provides API's for persistent SessionManagement

In order to use the various functions available under a particular API, a developer will have to create an instance of ServiceAPI by passing the apiKey and the secretKey which has been received while creating an app.

	ServiceAPI api = new ServiceAPI("<API_KEY>","<SECRET_KEY>");                            

After initialization, developer needs to call the buildXXXService method on ServiceAPI instance to get the instance of the particular API that you wish to build. For example, To build an instance of UserService, buildUserService() method needs to be called.

	UserService userService = api.buildUserService();

Once the API instance has been retrieved, You are ready to use the functions available for that particular API.

The methods available under a particular API will return the domain object (like User in this case) as a response which will have the accessor / mutator to access the available properties for that object. You can get the response in the form of JSON as well. We have also provided the JSON response with every function detail which can be retrieved by calling the toString() on the returned object.

The request format for create User is
URL : https://api.shephertz.com/cloud/1.0/user
Method : POST
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json
Body :
{
    "app42": {
        "user": {
            "userName": "Nick",
            "password": "*****",
            "email": "nick@shephertz.com"
        }
    }
}                       

The functions available under User API can throw some exceptions in abnormal conditions. Example of the same has been given below.

E.g. If App developer is creating a user with username which is already in database, the function will throw the App42Exception (as shown below) with message as "Bad Request" and the appErrorCode as "2001" and the details as "The request parameters are invalid. Username '<userName>' already exists".

String userName = "Nick";
String pwd = "********";
String emailId = "nick@shephertz.com";	
 
try 
{  
	User user = userService.createUser(userName, pwd, emailId);  
} 
catch(App42Exception ex) 
{  
	int appErrorCode = ex.getAppErrorCode();  
	int httpErrorCode = ex.getHttpErrorCode();  
	if(appErrorCode == 2001)
	{
		// Handle here for Bad Request (The request parameters are invalid. Username '<userName>' already exists.)
	}
	else if(appErrorCode  == 2005)
	{
		// Handle here for Bad Request (The request parameters are invalid. User with emailId '<emailId>' already exists.)
	}
	else if(appErrorCode == 1401)
	{
		// handle here for Client is not authorized
	}
	else if(appErrorCode == 1500)
	{
		// handle here for Internal Server Error
	}
	String jsonText = ex.getMessage(); /* returns the Exception text in JSON format. (as shown below)*/   
}                           
{
    "app42Fault": {
        "httpErrorCode": 400,
        "appErrorCode": 2001,
        "message": "Bad Request",
         "details": "The Request parameters are invalid. Username 'Nick' already Exists"
    }
}							

Below are the HTTP Error Codes and their description, the function under the User API can throw.

/*
1400 - BAD REQUEST - The Request parameters are invalid
1401 - UNAUTHORIZED - Client is not authorized
1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again	
*/		

Below are the Application Error Codes and their description, the function under the User API can throw.

/*
2000 - NOT FOUND - User by the name '<userName>' does not exist. 
2001 - BAD REQUEST - The request parameters are invalid. Username '<userName>' already exists. 
2002 - NOT FOUND - UserName/Password did not match. Authentication Failed. 
2003 - BAD REQUEST - Old Password is not matching for user '<userName>'.  
2004 - NOT FOUND - User with the emailId '<emailId>' does not exist.
2005 - BAD REQUEST - The request parameters are invalid. User with emailId '<emailId>' already exists.  
2006 - NOT FOUND - Users do not exist.	
2007 - NOT FOUND - The number of users are less than the specified offset : <offset>.
2008 - NOT FOUND - The number of locked users are less than the specified offset : <offset>.
2009 - NOT FOUND - Users with the role '<role>' do not exist.
2010 - NOT FOUND - No role found for the user '<userName>'.
2011 - NOT FOUND - Role '<role>' for the user '<userName>' does not exist.
2012 - Not FOUND - Roles for the user '<userName>' do not exist.
*/					

Various functions available under User API has been explained below.

public User createUser(String userName, String pwd, String emailId) throws App42Exception

Create User for the App.

The request format for create User is
URL : https://api.shephertz.com/cloud/1.0/user
Method : POST
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json
Body :
{
    "app42": {
        "user": {
            "userName": "Nick",
            "password": "********",
            "email": "nick@shephertz.com"
        }
    }
}

Returns:

The created User Object.

Response: User Object

Request Format:

Exception:

The method throws the following exception with the error code.
/*
2001 - BAD REQUEST - The request parameters are invalid. Username '<userName>' already exists.
2005 - BAD REQUEST - The request parameters are invalid. User with emailId '<emailId>' already exists.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "nick@shephertz.com"
                }
            }
        }
    }
}   
public User createUser(String userName, String pwd, String emailId, ArrayList<String>roleList) throws App42Exception

Create User for the App.

Request Format:

The request format for createUser with role is
URL : https://api.shephertz.com/cloud/1.0/user/role
Method : POST
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json
Body :
{
    "app42": {
        "user": {
            "userName": "Nick",
			"email": "nick@shephertz.com",
			"password": "********",	
			"role": [
                        "Admin",
                        "Manager",
                        "Programmer",
                        "Tester"
                    ]
        }
    }
}

Returns:

The created User Object.

Response: User Object

Exception:

The method throws the following exception with the error code.
/*
2001 - BAD REQUEST - The request parameters are invalid. Username '<userName>' already exists.
2005 - BAD REQUEST - The request parameters are invalid. User with emailId '<emailId>' already exists.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "nick@shephertz.com",
                    "role": [
                        "Admin",
                        "Manager",
                        "Programmer",
                        "Tester"
                    ]
                }
            }
        }
    }
}	
public User assignRoles(String userName, ArrayList<String>roleList)throws App42Exception

Assign Roles for the App

Request Format:

The request format for assignRoles is
URL : https://api.shephertz.com/cloud/1.0/user/assignrole
Method : POST
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json
Body :
{
    "app42": {
        "user": {
            "userName": "Nick",
			"role": [
                        "Admin",
                        "Manager",
                        "Programmer",
                        "Tester"
                    ]
        }
    }
}

Returns:

The created User Object.

Response: User Object

Exception:

The method throws the following exception with the error code.
/*
2000 - NOT FOUND - User by the name '<userName>' does not exist.
*/ 		  
        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "role": [
                        "Admin",
                        "Manager",
                        "Programmer",
                        "Tester"
                    ]
                }
            }
        }
    }
}
public User getRolesByUser(String userName) throws App42Exception

Get Roles based on userName

Request Format:

The request format for getRolesByUser is
URL : https://api.shephertz.com/cloud/1.0/{userName}/roles
Method : GET
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

The User Object

Response: User Object

Exception:

The method throws the following exception with the error code.
/*
2000 - NOT FOUND - User by the name '<userName>' does not exist.
2010 - NOT FOUND - No role found for the user '<userName>'.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "nick@shephertz.com",
                    "role": [
                        "Admin",
                        "Manager",
                        "Programmer",
                        "Tester"
                    ],
                    "accountLocked": false,
                    "profile": {
                        "firstName": "Nick",
                        "lastName": "Gill",
                        "sex": "Male",
                        "dateOfBirth": "2012-12-11T18:30:00.000Z",
                        "mobile": "+1-1111-111-111",  
                        "homeLandLine": "+1-2222-222-222",  
                        "officeLandLine": "+1-33333-333-333",
                        "line1":"Line1",
                        "line2":"Line2",
                        "city": "Tulsa",
                        "state":"Oklahoma",
                        "pincode":"74193",
                        "country":"USA"
                    }
                }
            }
        }
    }
}
public ArrayList<User> getUsersByRole(String role) throws App42Exception

Get Users based on Role

Request Format:

The request format for getUsersByRole is
URL : https://api.shephertz.com/cloud/1.0/user/role/{role}
Method : GET
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

List of User Object for that particular role

Response: ArrayList<User> Object

Exception:

The method throws the following exception with the error code.
/*
2009 - NOT FOUND - Users with the role '<role>' do not exist.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": [
                    {
                        "userName": "Nick",
                        "email": "nick@shephertz.com",
                        "role": "Admin",
                        "accountLocked": false,
                        "profile": {
                            "firstName": "Nick",
                            "lastName": "Gill",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+1-1111-111-111",  
                            "homeLandLine": "+1-2222-222-222",  
                            "officeLandLine": "+1-33333-333-333",
                            "line1": "300 Oxford Street",
                            "line2": "W1A 1EX ",
                            "city": "Tulsa",
                            "state": "Oklahoma",
                            "pincode": "74193",
                            "country": "USA"
                        }
                    },
                    {
                        "userName": "Allen Hill",
                        "email": "allenHill@shephertz.com",
                        "role": "Admin",
                        "accountLocked": false,
                        "profile": {
                            "firstName": "Allen",
                            "lastName": "Hill",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+1-1111-111-111",  
                            "homeLandLine": "+1-2222-222-222",  
                            "officeLandLine": "+1-33333-333-333",
                            "line1": "300 Oxford Street2",
                            "line2": "W1A 1EX 2",
                            "city": "Tulsa",
                            "state": "Oklahoma",
                            "pincode": "74193",
                            "country": "USA"
                        }
                    }
                ]
            }
        }
    }
}
public User getUser(String userName) throws App42Exception

Gets user details based on userName.

Request Format:

The request format for getUser is
URL : https://api.shephertz.com/cloud/1.0/user/{userName}
Method : GET
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

The User Object

Response: User Object

Exception:

The method throws the following exception with the error code.
/*
2000 - NOT FOUND - User by the name  '<userName>' does not exist.
*/ 	        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "nick@shephertz.com",
                    "accountLocked": false,
                    "profile": {
                        "firstName": "Nick",
                        "lastName": "Gill",
                        "sex": "Male",
                        "dateOfBirth": "2012-12-11T18:30:00.000Z",
                        "mobile": "+1-1111-111-111",  
                        "homeLandLine": "+1-2222-222-222",  
                        "officeLandLine": "+1-33333-333-333",
                        "line1": "300 Oxford Street",
                        "line2": "W1A 1EX ",
                        "city": "Tulsa",
                        "state": "Oklahoma",
                        "pincode": "74193",
                        "country": "USA"
                    }
                }
            }
        }
    }
}                                        
public ArrayList<User> getAllUsers() throws App42Exception

Gets All users details.

Request Format:

The request format for getAllUsers is
URL : https://api.shephertz.com/cloud/1.0/user
Method : GET
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

List that contains all User Object

Response: ArrayList<User> Object

Exception:

The method throws the following exception with the error code.
/*
2006 - NOT FOUND - Users do not exist.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": [
                    {
                        "userName": "Nick",
                        "email": "nick@shephertz.com",
                        "accountLocked": false,
                        "profile": {
                            "firstName": "Nick",
                            "lastName": "Gill",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+1-1111-111-111",  
                            "homeLandLine": "+1-2222-222-222",  
                            "officeLandLine": "+1-33333-333-333",
                            "line1": "300 Oxford Street",
                            "line2": "W1A 1EX ",
                            "city": "Tulsa",
                            "state": "Oklahoma",
                            "pincode": "74193",
                            "country": "USA"
                        }
                    },
                    {
                        "userName": "Alfred",
                        "email": "Alfred@shephertz.com",
                        "accountLocked": false,
                        "profile": {
                            "firstName": "Alfred",
                            "lastName": "Manistra",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+1-1111-111-111",  
                            "homeLandLine": "+1-2222-222-222",  
                            "officeLandLine": "+1-33333-333-333",
                            "line1": "300 Oxford Street2",
                            "line2": "W1A 1EX 2",
                            "city": "London",
                            "state": "State",
                            "pincode": "120981",
                            "country": "London"
                        }
                    }
                ]
            }
        }
    }
}     
public App42Response getAllUsersCount() throws App42Exception

Gets the count of all the users

Request Format:

The request format for getAllUsersCount is
URL : https://api.shephertz.com/cloud/1.0/user/count/all
Method : GET
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

The count of all User exists

Response:App42Response Object

For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}	
public ArrayList<User>getAllUsers(int max, int offset) throws App42Exception

Gets All users By Paging

Request Format:

The request format for getAllUsers by paging is
URL : https://api.shephertz.com/cloud/1.0/user/paging/{max}/{offset}
Method : GET
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

The List that contains all User Object

Response: ArrayList<User> Object

Exception:

The method throws the following exception with the error code.
/*
2007 - NOT FOUND - The number of users are less than the specified offset : <offset>.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick ",
                    "email": "nick@shephertz.com",
                    "accountLocked": false,
                    "profile": {
                        "firstName": "Nick",
                        "lastName": "Gill",
                        "sex": "Male",
                        "dateOfBirth": "2012-12-11T18:30:00.000Z",
                        "mobile": "+1-1111-111-111",  
                        "homeLandLine": "+1-2222-222-222",  
                        "officeLandLine": "+1-33333-333-333",
                        "line1": "300 Oxford Street",
                        "line2": "W1A 1EX ",
                        "city": "Tulsa",
                        "state": "Oklahoma",
                        "pincode": "74193",
                        "country": "USA"
                    }
                }
            }
        }
    }
}		    			   
public User getUserByEmailId(String emailId) throws App42Exception

Gets user details based on Email Id.

Request Format:

The request format for getUserByEmailId is
URL : https://api.shephertz.com/cloud/1.0/user/email/{emailId}
Method : GET
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

The User Object

Response:User Object

Exception:

The method throws the following exception with the error code.
/*
2004 - NOT FOUND - User with the emailId '<emailId>' does not exist.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "nick@shephertz.com",
                    "accountLocked": false,
                    "profile": {
                        "firstName": "Nick",
                        "lastName": "Gill",
                        "sex": "Male",
                        "dateOfBirth": "2012-12-11T18:30:00.000Z",
                        "mobile": "+1-1111-111-111",  
                        "homeLandLine": "+1-2222-222-222",  
                        "officeLandLine": "+1-33333-333-333",
                        "line1": "300 Oxford Street2",
                        "line2": "W1A 1EX 2",
                        "city": "London",
                        "state": "State",
                        "pincode": "120981",
                        "country": "London"
                    }
                }
            }
        }
    }
}                                          
public ArrayList<User> getLockedUsers() throws App42Exception

Gets All the locked users details.

Request Format:

The request format for getLockedUsers is
URL : https://api.shephertz.com/cloud/1.0/user/locked
Method : GET
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

The List that contains locked User Objects

Response: ArrayList<User> Object

Exception:

The method throws the following exception with the error code.
/*
2006 - NOT FOUND - Users do not exist.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": [
                    {
                        "userName": "Nick ",
                        "email": "nick@shephertz.com",
                        "accountLocked": true,
                        "profile": {
                            "firstName": "Nick ",
                            "lastName": "Gill",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+1-1111-111-111",  
                            "homeLandLine": "+1-2222-222-222",  
                            "officeLandLine": "+1-33333-333-333",
                            "line1": "300 Oxford Street",
                            "line2": "W1A 1EX ",
                            "city": "Tulsa",
                            "state": "Oklahoma",
                            "pincode": "74193",
                            "country": "USA"
                        }
                    },
                    {
                        "userName": "Billy",
                        "email": "billy@shephertz.com",
                        "accountLocked": true,
                        "profile": {
                            "firstName": "Billy",
                            "lastName": "Bouden",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+1-1111-111-111",  
                            "homeLandLine": "+1-2222-222-222",  
                            "officeLandLine": "+1-33333-333-333",
                            "line1": "300 Oxford Street2",
                            "line2": "W1A 1EX 2",
                            "city": "London",
                            "state": "State",
                            "pincode": "120981",
                            "country": "London"
                        }
                    }
                ]
            }
        }
    }
}
public App42Response getLockedUsersCount() throws App42Exception

Gets the count of all the locked users

Request Format:

The request format for getLockedUsersCount is
URL : https://api.shephertz.com/cloud/1.0/user/count/locked
Method : GET
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

The count of locked User exists

Response:App42Response Object

For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}		
public ArrayList<User> getLockedUsers(int max, int offset) throws App42Exception

Gets All the locked users details By paging.

Request Format:

The request format for getLockedUsers by paging is
URL : https://api.shephertz.com/cloud/1.0/user/locked/{max}/{offset}
Method : GET
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

The List that contains locked User Objects

Response: ArrayList<User> Object

Exception:

The method throws the following exception with the error code.
/*
2008 - NOT FOUND - The number of locked users are less than the specified offset : <offset>.
*/ 	        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick ",
                    "email": "nick@shephertz.com",
                    "accountLocked": true,
                    "profile": {
                        "firstName": "Nick ",
                        "lastName": "Gill",
                        "sex": "Male",
                        "dateOfBirth": "2012-12-11T18:30:00.000Z",
                        "mobile": "+1-1111-111-111",  
                        "homeLandLine": "+1-2222-222-222",  
                        "officeLandLine": "+1-33333-333-333",
                        "line1": "300 Oxford Street",
                        "line2": "W1A 1EX ",
                        "city": "Tulsa",
                        "state": "Oklahoma",
                        "pincode": "74193",
                        "country": "USA"
                    }
                }
            }
        }
    }
}                                         
public ArrayList<User> getUsersByProfileData(User.Profile profileData) throws App42Exception

Get Users based on Profile Data.

Request Format:

The request format for getUsersByProfileData is
URL : https://api.shephertz.com/cloud/1.0/user/profile/{parameters}
Method : GET
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Exception:

The method throws the following exception with the error code.
/*
2006 - NOT FOUND - Users do not exist.
*/ 		        

Returns:

The ArrayList of User Object for that particular role

Response: ArrayList<User> Object

For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": [
                    {
                        "userName": "Nick",
                        "email": "nick@shephertz.com",
                        "accountLocked": false,
                        "profile": {
                            "firstName": "Nick",
                            "lastName": "Gill",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
							"mobile": "+1-1111-111-111",  
                            "homeLandLine": "+1-2222-222-222",  
                            "officeLandLine": "+1-33333-333-333",
							"line1": "300 Oxford Street",
							"line2": "W1A 1EX ",
							"city": "Tulsa",
							"state": "Oklahoma",
							"pincode": "74193",
							"country": "USA"
                        }
                    },
                    {
                        "userName": "Billy",
                        "email": "billy@shephertz.com",
                        "accountLocked": false,
                        "profile": {
                            "firstName": "Billy",
                            "lastName": "Bouden",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+1-1111-111-111",  
                            "homeLandLine": "+1-2222-222-222",  
                            "officeLandLine": "+1-33333-333-333",
                            "line1": "300 Oxford Street2",
                            "line2": "W1A 1EX 2",
                            "city": "London",
                            "state": "State",
                            "pincode": "120981",
                            "country": "London"
                        }
                    }
                ]
            }
        }
    }
}
public App42Response resetUserPassword(String userName,String password) throws App42Exception

Updates the User password based on userName.Username cannot be updated.

Request Format:

The request format for resetUserPassword is
URL : https://api.shephertz.com/cloud/1.0/user/resetUserPassword  
Method : PUT
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json
Body:
{  
    "app42": {  
        "user": {  
            "userName": "Nick",
            "password": "********"
        }  
    }  
} 

Returns:

App42Response Object

Response:App42Response Object

Exception:

The method throws the following exception with the error code.
/*
2000 - NOT FOUND - User by the name '<userName>' does not exist.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "password": "********"
                }
            }
        }
    }
}
public App42Response revokeRole(String userName, String role) throws App42Exception

Revokes the specified role from the user.

Request Format:

The request format for revokeRole is
URL : https://api.shephertz.com/cloud/1.0/user/{userName}/revoke/{role}  
Method : DELETE
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

App42Response Object

Response:App42Response Object

Exception:

The method throws the following exception with the error code.
/*
2000 - NOT FOUND - User by the name  '<userName>' does not exist.
2011 - NOT FOUND - Role '<role>' for the user '<userName>' does not exist.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "role": "Admin"
                }
            }
        }
    }
}
public App42Response revokeAllRoles(String userName) throws App42Exception

Revokes all the roles from the user.

Request Format:

The request format for revokeAllRoles is
URL : https://api.shephertz.com/cloud/1.0/user/{userName}/revoke
Method : DELETE
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

App42Response Object

Response:App42Response Object

Exception:

The method throws the following exception with the error code.
/*
2000 - NOT FOUND - User by the name  '<userName>' does not exist.
2012 - Not Found - Roles for the user '<userName>' do not exist.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "testingUser111343043253822",
                    "role": [
                        {
                            "role": "Admin"
                        },
                        {
                            "role": "Manager"
                        },
                        {
                            "role": "Programmer"
                        },
                        {
                            "role": "Tester"
                        }
                    ]
                }
            }
        }
    }
}
public User updateEmail(String userName, String emailId) throws App42Exception

Updates the User based on userName.
Note: Only email can be updated. Username cannot be updated.

Request Format:

The request format for updateEmail is
URL : https://api.shephertz.com/cloud/1.0/user
Method : PUT
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json
Body :
{
    "app42": {
        "user": {
            "userName": "Nick",
			"email": "almighty@shephertz.com"
        }
    }
}

Returns:

Updated User Object

Response:User Object

Exception:

The method throws the following exception with the error code.
/*
2000 - NOT FOUND - User by the name '<userName>' does not exist.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "almighty@shephertz.com"
                }
            }
        }
    }
}
public App42Response deleteUser(String userName) throws App42Exception

Deletes a particular user based on userName.

Request Format:

The request format for deleteUser is
URL : https://api.shephertz.com/cloud/1.0/user/{userName}
Method : DELETE
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json

Returns:

App42Response Object if user deleted successfully

Response: App42Response Object

Exception:

The method throws the following exception with the error code.
/*
2000 - NOT FOUND - User by the name '<userName>' does not Exist
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick"
                }
            }
        }
    }
}                                    
public User createOrUpdateProfile(User user)throws App42Exception

Creates or Updates User Profile.
Note: First time when the Profile for the user is created. In future calls user information will be updated.

Request Format:

The request format for createOrUpdateProfile is
URL : https://api.shephertz.com/cloud/1.0/user/profile
Method : PUT
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json
Body :
{
    "app42": {
        "user": {
            "userName": "Nick",
            "profileData": {
                        "firstName": "Nick ",
                        "lastName": "Gill",
                        "sex": "Male",
                        "dateOfBirth": "2012-12-11T18:30:00.000Z",
                        "city": "Houston",
                        "state": "Texas",
                        "pincode": "74193",
                        "country": "USA",
                        "mobile": "+1-1111-111-111",  
                        "homeLandLine": "+1-2222-222-222",  
                        "officeLandLine": "+1-33333-333-333",
            }
        }
    }
}

Returns:

User Object with updated Profile information

Response: User Object

Exception:

The method throws the following exception with the error code.
/*
2000 - NOT FOUND - User by the name  '<userName>' does not exist.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick ",
                    "email": "nick@shephertz.com",
                    "accountLocked": false,
                    "profile": {
                        "firstName": "Nick ",
                        "lastName": "Gill",
                        "sex": "Male",
                        "dateOfBirth": "2012-12-11T18:30:00.000Z",
                        "city": "Houston",
                        "state": "Texas",
                        "pincode": "74193",
                        "country": "USA",
                        "mobile": "+1-1111-111-111",  
                        "homeLandLine": "+1-2222-222-222",  
                        "officeLandLine": "+1-33333-333-333",
                    }
                }
            }
        }
    }
}                                      
public App42Response authenticate(String userName, String pwd)throws App42Exception

Authenticate user based on userName and password.

Request Format:

The request format for authenticate is
URL : https://api.shephertz.com/cloud/1.0/user/authenticate
Method : POST
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json
Body :
{
    "app42": {
        "user": {
            "userName": "Nick",
            "password": "********"
        }
    }
}

Returns:

App42Response Object if authenticated successfully.

Response: App42Response Object

Exception:

The method throws the following exception with the error code.
/*
2002 - NOT FOUND - UserName/Password did not match. Authentication Failed.  
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "accountLocked": false
                }
            }
        }
    }
}                                       
public User unlockUser(String userName) throws App42Exception

Unlock the user based on the userName. Apps can use these feature to unlock a user because of reasons specific to their usercase e.g. If payment received and the App wants to the user to be active.

Request Format:

The request format for unlockUser is
URL : https://api.shephertz.com/cloud/1.0/user/unlock
Method : PUT
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json
Body :
{
    "app42": {
        "user": {
            "userName": "Nick"
        }
    }
}

Returns:

The unlocked User Object

Response: User Object

Exception:

The method throws the following exception with the error code.
/*
2000 - NOT FOUND - User by the name  '<userName>' does not exist.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "accountLocked": false
                }
            }
        }
    }
}                                          
public User lockUser(String userName) throws App42Exception

Locks the user based on the userName. Apps can use these feature to lock a user because of reasons specific to their usercase e.g. If payment not received and the App wants the user to be inactive.

Request Format:

The request format for lockUser is
URL : https://api.shephertz.com/cloud/1.0/user/lock
Method : PUT
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json
Body :
{
    "app42": {
        "user": {
            "userName": "Nick"
        }
    }
}

Returns:

The locked User Object

Response: User Object

Exception:

The method throws the following exception with the error code.
/*
2000 - NOT FOUND - User by the name  '<userName>' does not exist.
*/ 		        
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "accountLocked": true
                }
            }
        }
    }
}										
public App42Response changeUserPassword(String userName, String oldPwd, String newPwd) throws App42Exception

Change the password for user based on the userName. If the old password is valid.

Request Format:

The request format for changeUserPassword is
URL : https://api.shephertz.com/cloud/1.0/user/changeUserPassword
Method : PUT
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json
Body:
{
    "app42": {
        "user": {
            "userName": "Nick",
            "newPassword": "*******"
			"oldPassword": "*******",
        }
    }
}

Returns:

App42Response Object if updated successfully

Response: App42Response Object

Exception:

The method throws the following exception with the error code.
/*
2000 - NOT FOUND - User by the name  '<userName>' does not exist.
2003 - BAD REQUEST - Old Password is not matching for user '<userName>'.  
*/ 		       
For more details click Exception
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick"
                }
            }
        }
    }
}