App42 Cloud API

J2ME(S40) 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.

	String userName = "Nick";
 String pwd = "********";
 String emailId = "nick@gmail.com";		
 
 User user = userService.createUser(userName, pwd, emailId); /* returns the User object. */
	System.out.println("userName is " + user.getUserName());
 System.out.println("emailId is " + user.getEmail());
	String jsonResponse = user.toString(); /* returns the response in JSON format. */                            

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@gmail.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.

Parameters:

userName - UserName which should be unique for the App
pwd - Password for the User
emailId - Email address of the user

Returns:

The created User Object.

Response: User Object

Exception:

This method throws following exception.
/*
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
String userName = "Nick";
String pwd = "********";
String emailId = "nick@gmail.com";

User user = userService.createUser(userName, pwd, emailId); /* returns the User object. */
System.out.println("userName is " + user.getUserName());
System.out.println("emailId is " + user.getEmail());
String jsonResponse = user.toString(); /* returns the response in JSON format. (as shown below)*/
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "nick@gmail.com"
                }
            }
        }
    }
}   
public User createUser(String userName, String pwd, String emailId,Vector roleList) throws App42Exception

Create User for the App.

Parameters:

userName - UserName which should be unique for the App
pwd - Password for the User
emailId - Email address of the user
roleList - List of roles to be assigned to User

Returns:

The created User Object.

Response: User Object

Exception:

This method throws following exception.
/*
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
String userName = "Nick";
String pwd = "*******";
String emailId = "nick@gmail.com";
Vector roleList = new Vector();
roleList.addElement("Admin");
roleList.addElement("Manager");
roleList.addElement("Programmer");
roleList.addElement("Tester");

User user = userService.createUser(userName,pwd,emailId,roleList); /* returns the User object. */
System.out.println("userName is " + user.getUserName());
System.out.println("emailId is " + user.getEmail()); 
Vector userRoleList  = user.getRoleList();
for(int i =0;i< userRoleList.size();i++)
{
String roles = (String) userRoleList.elementAt(i);
System.out.println("role is " + roles);
}
String jsonResponse = user.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "nick@gmail.com",
                    "role": [
                        "Admin",
                        "Manager",
                        "Programmer",
                        "Tester"
                    ]
                }
            }
        }
    }
}	
public User assignRoles(String userName, Vector roleList)throws App42Exception

Assign Roles for the App

Parameters:

userName - UserName which should be unique for the App
roleList - List of roles to be assigned to User

Returns:

The created User Object.

Response: User Object

Exception:

This method throws following exception.
/*
2000 - NOT FOUND -  User by the name '<userName>' does not exist. 
*/ 		       
For more details click Exception
String userName = "Nick";			
Vector roleList = new Vector ();
roleList.addElement("Admin");
roleList.addElement("Manager");
roleList.addElement("Programmer");
roleList.addElement("Tester");

User user = userService.assignRoles(userName,roleList); /* returns the User object. */
System.out.println("userName is " + user.getUserName() );
Vector userRoleList  = user.getRoleList();
for(int i =0;i< userRoleList.size();i++)
{
String roles = (String) userRoleList.elementAt(i);
System.out.println("role is " + roles);
}
String jsonResponse = user.toString(); /* returns the response in JSON format. (as shown below)*/                          
		
{
    "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

Parameters:

userName - UserName which should be unique for the App

Returns:

The User Object

Response: User Object

Exception:

This method throws following exception.
/*
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
String userName = "Nick";

User user = userService.getRolesByUser(userName); /* returns the User object. */
System.out.println("userName is " + user.getUserName());
System.out.println("emailId is " + user.getEmail());
Vector userRoleList  = user.getRoleList();
for(int i =0;i< userRoleList.size();i++)
{
String roles = (String) userRoleList.elementAt(i);
System.out.println("role is " + roles);
}
System.out.println("firstName is " + user.getProfile().getFirstName()); 
String jsonResponse = user.toString(); /* returns the response in JSON format. (as shown below)*/                          
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "nick@gmail.com",
                    "role": [
                        "Admin",
                        "Manager",
                        "Programmer",
                        "Tester"
                    ],
                    "accountLocked": false,
                    "profile": {
                        "firstName": "Nick",
                        "lastName": "Gill",
                        "sex": "Male",
                        "dateOfBirth": "2012-12-11T18:30:00.000Z",
                        "mobile": "+95890123457",
                        "officeLandLine": "+1-1800-111-999",
                        "homeLandLine": "+1-1800-877-453",
                        "line1":"Line1",
                        "line2":"Line2",
                        "city": "Tulsa",
                        "state":"Oklahoma",
                        "pincode":"74193",
                        "country":"USA"
                    }
                }
            }
        }
    }
}
public Vector getUsersByRole(String role) throws App42Exception

Get Users based on Role

Parameters:

role - Role for which User needs to be retrieved

Returns:

Vector of User Object for that particular role

Response: Vector User Object

Exception:

This method throws following exception.
/*
2009 - NOT FOUND - Users with the role '<role>' do not exist.
*/ 		        
For more details click Exception
String role = "Admin";

Vector userList = userService.getUsersByRole(role); /* returns the User object. */
for (int i =0;i < userList.size(); i++) 
{
	User user = (User) userList.elementAt(i);
	System.out.println("userName is " + user.getUserName());
    System.out.println("emailId is " + user.getEmail()); 
	System.out.println("firstName is " + user.getProfile().getFirstName()); 
	Vector userRoleList  = user.getRoleList();
for(int j =0;j< userRoleList.size();j++)
{
String roles = (String) userRoleList.elementAt(j);
System.out.println("role is " + roles);
}
}
String jsonResponse = user.toString(); /* returns the response in JSON format. (as shown below)*/                          
  		
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": [
                    {
                        "userName": "Nick",
                        "email": "nick@gmail.com",
                        "role": "Admin",
                        "accountLocked": false,
                        "profile": {
                            "firstName": "Nick",
                            "lastName": "Gill",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+95890123457",
                            "officeLandLine": "+1-1800-111-999",
                            "homeLandLine": "+1-1800-877-453",
                            "line1": "300 Oxford Street",
                            "line2": "W1A 1EX ",
                            "city": "Tulsa",
                            "state": "Oklahoma",
                            "pincode": "74193",
                            "country": "USA"
                        }
                    },
                    {
                        "userName": "Allen Hill",
                        "email": "allenHill@gmail.com",
                        "role": "Admin",
                        "accountLocked": false,
                        "profile": {
                            "firstName": "Allen",
                            "lastName": "Hill",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+95890123457",
                            "officeLandLine": "+1-1800-111-999",
                            "homeLandLine": "+1-1800-877-453",
                            "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.

Parameters:

userName - UserName which should be unique for the App

Returns:

User Object

Response: User Object

Exception:

This method throws following exception.
/*
2000 - NOT FOUND - User by the name '<userName>' does not exist.
*/ 	        
For more details click Exception
String userName = "Nick";

User user = userService.getUser(userName); /* returns the User object. */
System.out.println("userName is " + user.getUserName());
System.out.println("emailId is " + user.getEmail());
System.out.println("firstName is " + user.getProfile().getFirstName());
String jsonResponse = user.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "nick@gmail.com",
                    "accountLocked": false,
                    "profile": {
                        "firstName": "Nick",
                        "lastName": "Gill",
                        "sex": "Male",
                        "dateOfBirth": "2012-12-11T18:30:00.000Z",
                        "mobile": "+95890123457",
                        "officeLandLine": "+1-1800-111-999",
                        "homeLandLine": "+1-1800-877-453",
                        "line1": "300 Oxford Street",
                        "line2": "W1A 1EX ",
                        "city": "Tulsa",
                        "state": "Oklahoma",
                        "pincode": "74193",
                        "country": "USA"
                    }
                }
            }
        }
    }
}                                        
public Vector getAllUsers() throws App42Exception

Gets All users details.

Parameters:

N/A

Returns:

The Vector that contains all User Object

Response: Vector User Object

Exception:

This method throws following exception.
/*
2006 - NOT FOUND - Users do not exist.
*/ 		        
For more details click Exception
Vector userList = userService.getAllUsers(); /* returns the list of User objects. */
for(int i=0;i < userList.size();i++)
{
	User user = (User) userList.elementAt(i);
	System.out.println("userName is " + user.getUserName());
	System.out.println("emailId is " + user.getEmail());
	System.out.println("firstName is " + user.getProfile().getFirstName()); 
}
String jsonResponse = userList.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": [
                    {
                        "userName": "Nick",
                        "email": "nick@gmail.com",
                        "accountLocked": false,
                        "profile": {
                            "firstName": "Nick",
                            "lastName": "Gill",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+95890123457",
                            "officeLandLine": "+1-1800-111-999",
                            "homeLandLine": "+1-1800-877-453",
                            "line1": "300 Oxford Street",
                            "line2": "W1A 1EX ",
                            "city": "Tulsa",
                            "state": "Oklahoma",
                            "pincode": "74193",
                            "country": "USA"
                        }
                    },
                    {
                        "userName": "Alfred",
                        "email": "Alfred@gmail.com",
                        "accountLocked": false,
                        "profile": {
                            "firstName": "Alfred",
                            "lastName": "Manistra",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+95890123457",
                            "officeLandLine": "+1-1800-111-999",
                            "homeLandLine": "+1-1800-877-453",
                            "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

Parameters:

N/A

Returns:

The count of all User exists

Response: App42Response Object

For more details click Exception
App42Response response = userService.getAllUsersCount(); /* returns the App42Response object. */
boolean success = response.isResponseSuccess(); 
int totalRecords = response.getTotalRecords();
String jsonResponse = response.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}	
public Vector getAllUsers(Integer max, Integer offset) throws App42Exception

Gets All users details.

Parameters:

max - Maximum number of records to be fetched
offset - From where the records are to be fetched

Returns:

The Vector that contains all User Object

Response: Vector User Object

Exception:

This method throws following exception.
/*
2007 - NOT FOUND - The number of users are less than the specified offset : <offset>.
*/ 		        
For more details click Exception
Integer max = new Integer(1);
Integer offset = new Integer(0);
						
Vector userList = userService.getAllUsers(max,offset); /* returns the list of User objects. */
for(int i=0;i < userList.size();i++)
{
    User user = (User) userList.elementAt(i);
	System.out.println("userName is " + user.getUserName());
	System.out.println("emailId is " + user.getEmail());
    System.out.println("firstName is " + user.getProfile().getFirstName());	
}
String jsonResponse = userList.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick ",
                    "email": "nick@gmail.com",
                    "accountLocked": false,
                    "profile": {
                        "firstName": "Nick",
                        "lastName": "Gill",
                        "sex": "Male",
                        "dateOfBirth": "2012-12-11T18:30:00.000Z",
                        "mobile": "+95890123457",
                        "officeLandLine": "+1-1800-111-999",
                        "homeLandLine": "+1-1800-877-453",
                        "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.

Parameters:

emailId - EmailId of the user to be retrieved

Returns:

User Object

Response: User Object

Exception:

This method throws following exception.
/*
2004 - NOT FOUND - User with the emailId '<emailId>' does not exist.
*/ 		        
For more details click Exception
String emailId = "nick@gmail.com";

User user = userService.getUserByEmailId(emailId); /* returns the User object. */
System.out.println("userName is " + user.getUserName());
System.out.println("emailId is " + user.getEmail()); 
System.out.println("firstName is " + user.getProfile().getFirstName());
String jsonResponse = user.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "nick@gmail.com",
                    "accountLocked": false,
                    "profile": {
                        "firstName": "Nick",
                        "lastName": "Gill",
                        "sex": "Male",
                        "dateOfBirth": "2012-12-11T18:30:00.000Z",
                        "mobile": "+95890123457",
                        "officeLandLine": "+1-1800-111-999",
                        "homeLandLine": "+1-1800-877-453",
                        "line1": "300 Oxford Street2",
                        "line2": "W1A 1EX 2",
                        "city": "London",
                        "state": "State",
                        "pincode": "120981",
                        "country": "London"
                    }
                }
            }
        }
    }
}                                          
public Vector getLockedUsers() throws App42Exception

Gets All the locked users details.

Parameters:

N/A

Returns:

The list that contains locked User Objects

Response: Vector User Object

Exception:

This method throws following exception.
/*
2006 - NOT FOUND - Users do not exist.
*/ 		        
For more details click Exception
Vector userList = userService.getLockedUsers(); /* returns the list of locked User objects. */
for(int i=0;i < userList.size();i++)
{
	User user = (User) userList.elementAt(i);
	System.out.println("userName is " + user.getUserName());
	System.out.println("emailId is " + user.getEmail()); 
	System.out.println("firstName is " + user.getProfile().getFirstName());
}
String jsonResponse = userList.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": [
                    {
                        "userName": "Nick ",
                        "email": "nick@gmail.com",
                        "accountLocked": true,
                        "profile": {
                            "firstName": "Nick ",
                            "lastName": "Gill",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+95890123457",
                            "officeLandLine": "+1-1800-111-999",
                            "homeLandLine": "+1-1800-877-453",
                            "line1": "300 Oxford Street",
                            "line2": "W1A 1EX ",
                            "city": "Tulsa",
                            "state": "Oklahoma",
                            "pincode": "74193",
                            "country": "USA"
                        }
                    },
                    {
                        "userName": "Billy",
                        "email": "billy@gmail.com",
                        "accountLocked": true,
                        "profile": {
                            "firstName": "Billy",
                            "lastName": "Bouden",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+95890123457",
                            "officeLandLine": "+1-1800-111-999",
                            "homeLandLine": "+1-1800-877-453",
                            "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.

Parameters:

N/A

Returns:

The count of locked User exists

Response: App42Response Object

For more details click Exception
App42Response response = userService.getLockedUsersCount(); /* returns the App42Response  object. */ 
boolean success = response.isResponseSuccess();
int totalRecords = response.getTotalRecords();
String jsonResponse = userList.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}		
public Vector getLockedUsers(Integer max,Integer offset) throws App42Exception

Gets All the locked users details.

Parameters:

max - Maximum number of records to be fetched
offset - From where the records are to be fetched

Returns:

The list that contains locked User Objects

Response: Vector User Object

Exception:

This method throws following exception.
/*
2008 - NOT FOUND - The number of locked users are less than the specified offset : <offset>.
*/ 	        
For more details click Exception
Integer max = new Integer(1);
Integer offset = new Integer(0);

Vector userList = userService.getLockedUsers(max,offset); /* returns the list of locked User objects. */
for(int i=0;i < userList.size();i++)
{
	User user = (User) userList.elementAt(i);
	System.out.println("userName is " + user.getUserName());
    System.out.println("emailId is " + user.getEmail()); 
	System.out.println("firstName is " + user.getProfile().getFirstName());
}
String jsonResponse = userList.toString(); /* returns the response in JSON format. (as shown below)*/                            
		  
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick ",
                    "email": "nick@gmail.com",
                    "accountLocked": true,
                    "profile": {
                        "firstName": "Nick ",
                        "lastName": "Gill",
                        "sex": "Male",
                        "dateOfBirth": "2012-12-11T18:30:00.000Z",
                        "mobile": "+95890123457",
                        "officeLandLine": "+1-1800-111-999",
                        "homeLandLine": "+1-1800-877-453",
                        "line1": "300 Oxford Street",
                        "line2": "W1A 1EX ",
                        "city": "Tulsa",
                        "state": "Oklahoma",
                        "pincode": "74193",
                        "country": "USA"
                    }
                }
            }
        }
    }
}      
public Vector getUsersByProfileData(User.Profile profileData) throws App42Exception

Get Users based on Profile Data.

Parameters:

profileData - Profile Data key/value for which Users need to be retrieved

Returns:

The Vector of User Object for that particular role

Response: Vector User Object

Exception:

This method throws following exception.
/*
2006 - NOT FOUND - Users do not exist.
*/ 		        
For more details click Exception
String userName = "Nick";						
String pwd = "********";
String emailId = "nick@gmail.com";					
					
User.Profile profileData = new User().new Profile();
profileData.setFirstName("Nick");
profileData.setLastName("Gill");
Vector userList = userService.getUsersByProfileData(profileData); /* returns the list of User objects. */
for(int i =0;i< userList.size();i++)
{
    User user = (User) userList.elementAt(i);
    System.out.println("userName is " + user.getUserName());
	System.out.println("emailId is " + user.getEmail());
	System.out.println("firstName is " + user.getProfile().getFirstName());
}
String jsonResponse = userList.toString(); /* returns the response in JSON format. (as shown below)*/   
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": [
                    {
                        "userName": "Nick",
                        "email": "nick@gmail.com",
                        "accountLocked": false,
                        "profile": {
                            "firstName": "Nick",
                            "lastName": "Gill",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
							"mobile": "+95890123457",
							"officeLandLine": "+1-1800-111-999",
							"homeLandLine": "+1-1800-877-453",
							"line1": "300 Oxford Street",
							"line2": "W1A 1EX ",
							"city": "Tulsa",
							"state": "Oklahoma",
							"pincode": "74193",
							"country": "USA"
                        }
                    },
                    {
                        "userName": "Billy",
                        "email": "billy@gmail.com",
                        "accountLocked": false,
                        "profile": {
                            "firstName": "Billy",
                            "lastName": "Bouden",
                            "sex": "Male",
                            "dateOfBirth": "2012-12-11T18:30:00.000Z",
                            "mobile": "+95890123457",
                            "officeLandLine": "+1-1800-111-999",
                            "homeLandLine": "+1-1800-877-453",
                            "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 based on userName. Note: Only email can be updated.
Username cannot be updated.

Parameters:

userName - UserName which should be unique for the App
password - Password to be reset.

Returns:

App42Response Object

Response:App42Response Object

Exception:

This method throws following exception.
/*
2000 - NOT FOUND - User by the name '<userName>' does not exist.
*/ 		        
For more details click Exception
String userName = "Nick";
String password = "********"
	
App42Response response = userService.resetUserPassword(userName,password); /* returns the App42Response object. */
boolean  success = response.isResponseSuccess();
String jsonResponse = response.toString(); /* returns the response in JSON format. (as shown below)*/ 
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick"
                }
            }
        }
    }
}
public App42Response revokeRole(String userName, String role) throws App42Exception

Revokes the specified role from the user.

Parameters:

userName - UserName from whom the role has to be revoked
role - Role that has to be revoked

Returns:

App42Response Object

Response: App42Response Object

Exception:

This method throws following exception.
/*
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
String userName = "Nick";
String role = "Admin";	

App42Response response = userService.revokeRole(userName,role); /* returns the App42Response object. */
boolean  success = response.isResponseSuccess();
String jsonResponse = response.toString(); /* returns the response in JSON format. (as shown below)*/ 
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "role": "Admin"
                }
            }
        }
    }
}
public App42Response revokeAllRoles(String userName) throws App42Exception

Revokes all the roles from the user.

Parameters:

userName - Name of the User from whom Roles have to be revoked

Returns:

App42Response Object

Response: App42Response Object

Exception:

This method throws following exception.
/*
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
String userName = "Nick";		

App42Response response = userService.revokeAllRoles(userName); /* returns the App42Response object. */
boolean  success = response.isResponseSuccess();
String jsonResponse = response.toString(); /* returns the response in JSON format. (as shown below)*/ 
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "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.

Parameters:

userName - UserName which should be unique for the App
emailId - Email address of the user

Returns:

Updated User Object

Response: User Object

Exception:

This method throws following exception.
/*
2000 - NOT FOUND -  User by the name '<userName>' does not exist. 
*/ 		        
For more details click Exception
String userName = "Nick";	
String emailId = "almighty@gmail.com";

User user = userService.updateEmail(userName, emailId); /* returns the updated User object. */
System.out.println("userName is " + user.getUserName());
System.out.println("emailId is " + user.getEmail());
String jsonResponse = user.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "almighty@gmail.com"
                }
            }
        }
    }
}                                     
public App42Response deleteUser(String userName) throws App42Exception

Delete a particular user based on userName.

Parameters:

userName - UserName which should be unique for the App

Returns:

App42Response Object if user deleted successfully

Response: App42Response Object

Exception:

This method throws following exception.
/*
2000 - NOT FOUND - User by the name '<userName>' does not exist.
*/ 		        
For more details click Exception
String userName = "Nick";		

App42Response response = userService.deleteUser(userName); /* returns the App42Response object. */
boolean success = response.isResponseSuccess();
String jsonResponse = response.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "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.

Parameters:

user - User for which profile has to be updated,this should contain the userName and profile object in it.

Returns:

User Object with updated Profile information

Response: User Object

Exception:

This method throws following exception.
/*
2000 - NOT FOUND - User by the name '<userName>' does not exist.
*/ 		        
For more details click Exception
String userName = "Nick";						
String pwd = "********";
String emailId = "nick@gmail.com";			

User userObj = userService.createUser(userName, pwd, emailId); /* returns the User object. */ 
Profile profile = userObj.new Profile();
    profile.setFirstName("Nick");
    profile.setLastName("Gill");
	profile.setSex(UserGender.MALE);
    Date date = new Date(); /* returns the current date object.User can set any date */ 
    profile.setDateOfBirth(date);
	profile.setCity("Houston");
    profile.setState("Texas");
    profile.setPincode("74193");
    profile.setCountry("USA");
    profile.setMobile("+958901234571");
    profile.setHomeLandLine("+1-1800-877-453");
    profile.setOfficeLandLine("+1-1800-111-999");
User user = userService.createOrUpdateProfile(userObj); /* returns the updated User object. */
System.out.println("userName is " + user.getUserName());
System.out.println("emailId is " + user.getEmail());
System.out.println("firstName is " + user.getProfile().getFirstName());
String jsonResponse = user.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick ",
                    "email": "nick@gmail.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": "+958901234571",
                        "homeLandLine": "+1-1800-877-453",
                        "officeLandLine": "+1-1800-111-999"
                    }
                }
            }
        }
    }
}                                      
public App42Response authenticate(String userName, String pwd)throws App42Exception

Authenticate user based on userName and password.

Parameters:

userName - UserName which should be unique for the App
pwd - Password for the User

Returns:

App42Response Object if authenticated successfully.

Response: App42Response Object

Exception:

This method throws following exception.
/*
2002 - NOT FOUND - UserName/Password did not match. Authentication Failed.
*/ 		        
For more details click Exception
String userName = "Nick";
String pwd = "*******";			

App42Response response = userService.authenticate(userName, pwd); /* returns the App42Response object. */
boolean success = response.isResponseSuccess();
String jsonResponse = response.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "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 the user to be activated

Parameters:

userName - UserName which should be unique for the App

Returns:

The unlocked User Object

Response: User Object

Exception:

This method throws following exception.
/*
2000 - NOT FOUND - User by the name '<userName>' does not exist.
*/ 		        
For more details click Exception
String userName = "Nick";

User user = userService.unlockUser(userName); /* returns the unlocked User object. */
System.out.println("userName is " + user.getUserName());
String jsonResponse = user.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "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

Parameters:

userName - UserName which should be unique for the App

Returns:

The locked User Object

Response: User Object

Exception:

This method throws following exception.
/*
2000 - NOT FOUND - User by the name '<userName>' does not exist.
*/ 		        
For more details click Exception
String userName = "Nick";

User user = userService.lockUser(userName); /* returns the unlocked User object. */
System.out.println("userName is " + user.getUserName());
String jsonResponse = user.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "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.

Parameters:

userName - UserName which should be unique for the App
oldPwd - Old Password for the user for authentication
newPwd - New Password for the user to change

Returns:

App42Response Object if updated successfully

Response: App42Response Object

Exception:

This method throws following exception.
/*
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
String userName = "Nick";
String oldPwd   = "*******";
String newPwd   = "*******";	

App42Response response = userService.changeUserPassword(userName, oldPwd, newPwd); /* returns the App42Response object. */
boolean success = response.isResponseSuccess();
String jsonResponse = response.toString(); /* returns the response in JSON format. (as shown below)*/                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick"
                }
            }
        }
    }
}