App42 Cloud API

iOS 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 *serviceAPIObj = [[ServiceAPI alloc]init];
serviceAPIObj.apiKey = @"<API_KEY>";
serviceAPIObj.secretKey = @"<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 = [serviceAPIObj 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.

NSString *userName = @"Nick";
NSString *password = @"********";
NSString *emailId = @"nick@shephertz.com";		
 
User *user = [userService createUser:userName password:password emailAddress:emailId]; /* returns the User object. */
NSString *userName = user.userName;
NSString *emailId = user.emailId;
NSString *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".

						
NSString *userName = @"Nick";
NSString *password = @"********";
NSString *emailId = @"nick@shephertz.com";
 	
@try{
	User *user = [userService createUser:userName password:password emailAddress:emailId];
} @catch(App42Exception *ex) {
	int appErrorCode = ex.appErrorCode;
	int httpErrorCode = ex.httpErrorCode;
	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
}
	NSString *jsonText = ex.reason; /* 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.

-(User*)createUser:(NSString*)userName password:(NSString*)pwd emailAddress:(NSString*)emailId

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
NSString *userName = @"Nick";
NSString *password = @"********";
NSString *emailId = @"nick@shephertz.com";
 	
User *user = [userService createUser:userName password:password emailAddress:emailId]; /* returns the User object. */
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "nick@shephertz.com"
                }
            }
        }
    }
}   
-(User*)createUser:(NSString*)userName password:(NSString*)pwd emailAddress:(NSString*)emailId roleList:(NSArray*)roleList

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
NSString *userName = @"Nick";
NSString *password = @"********";
NSString *emailId = @"nick@shephertz.com";
NSArray *roleArray = [[NSArray alloc]initWithObjects:@"Admin",@"Manager",@"Programmer",@"Tester", nil];

User *user = [userService createUser:userName password:password emailAddress:emailId roleList:roleArray];/* returns the User object. */
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSArray *userRoleList = user.roleList;
for(NSString *role in userRoleList)
{
		NSLog(@"roles is %@",role);
}
String jsonResponse = user.toString(); /* returns the response in JSON format. (as shown below)*/		
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": " nick@shephertz.com",
                    "role": [
                        "Admin",
                        "Manager",
                        "Programmer",
                        "Tester"
                    ]
                }
            }
        }
    }
}	
-(User*)assignRoles:(NSString*)userName roleList:(NSArray*)roleList

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
NSString *userName = @"Nick";
NSArray *roleArray = [[NSArray alloc]initWithObjects:@"Admin",@"Manager",@"Programmer",@"Tester", nil];

User *user = [userService createUser:userName roleList:roleArray];/* returns the User object. */
NSLog(@"userName is %@" , user.userName);
NSArray *userRoleList = user.roleList;
for(NSString *role in userRoleList)
{
		NSLog(@"roles is %@",role);
}
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"
                    ]
                }
            }
        }
    }
}
-(User*)getRolesByUser:(NSString*)userName

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
NSString *userName = @"Nick";

User *user = [userService getRolesByUser:userName]; /* returns the User object. */
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSArray *userRoleList = user.roleList;
for(NSString *role in userRoleList)
{
	NSLog(@"roles is %@",role);
}
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/ 
{
    "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"
                    }
                }
            }
        }
    }
}
-(NSArray*)getUsersByRole:(NSString*)role

Get Users based on Role

Parameters:

role - Role for which User needs to be retrieved

Returns:

List of User Object for that particular role

Response: NSArray

Exception:

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

NSArray *userList = [userService getUsersByRole:role]; /* returns the list of User objects. */ 
for(User *user in userList)
{
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSLog(@"firstName is %@" ,  user.profile.firstName);
NSArray *userRoleList = user.roleList;
for(NSString *role in userRoleList)
{
	NSLog(@"roles is %@",role);
}
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/
}
  
  		
{
    "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-3333-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"
                        }
                    }
                ]
            }
        }
    }
}
-(User*)getUser:(NSString*)userName

Gets user details 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.
*/ 	        
For more details click Exception
NSString *userName = @"Nick";

User *user = [userService getUser:userName]; /* returns the User object. */
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSLog(@"firstName is %@" ,  user.profile.firstName);
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/
                            
{
    "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"
                    }
                }
            }
        }
    }
}                                        
-(NSArray*)getAllUsers

Gets All users details.

Parameters:

N/A

Returns:

List that contains all User Object

Response: NSArray

Exception:

This method throws following exception.
/*
2006 - NOT FOUND - Users do not exist.
*/ 	        
For more details click Exception
NSArray *userList = [userService getAllUsers]; /* returns the list of User objects. */
for(User *user in userList)
{
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSLog(@"firstName is %@" ,  user.profile.firstName);
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/
}
{
    "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-3333-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"
                        }
                    }
                ]
            }
        }
    }
}     
-(App42Response*)getAllUsersCount

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 objects. */
BOOL success = response.isResponseSuccess;
int totalRecords = response.totalRecords;
NSString *jsonResponse = [response toString]; /* returns the response in JSON format. (as shown below)*/     

{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}	
-(NSArray*)getAllUsers:(int)max offset:(int)offset

Gets All users By Paging

Parameters:

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

Returns:

List that contains all User Object

Response: NSArray

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
int max = 1;
int offset = 0 ;

NSArray *userList = [userService getAllUsers:max offset:offset]; /* returns the list of User objects. */
for(User *user in userList)
{
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSLog(@"firstName is %@" ,  user.profile.firstName);
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/ 
}
		
{
    "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"
                    }
                }
            }
        }
    }
}		    			   
-(User*)getUserByEmailId:(NSString*)emailId

Gets user details based on Email Id.

Parameters:

emailId - EmailId of the user to be retrieved

Returns:

The 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
	
NSString *emailId = @"nick@shephertz.com";

User *user = [userService getUserByEmailId:emailId]; /* returns the User object. */
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSLog(@"firstName is %@" ,  user.profile.firstName);
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/
                            
{
    "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"
                    }
                }
            }
        }
    }
}                                          
-(NSArray*)getLockedUsers

Gets All the locked users details.

Parameters:

N/A

Returns:

List that contains locked User Objects

Response: NSArray

Exception:

This method throws following exception.
/*
2006 - NOT FOUND - Users do not exist.
*/ 		        
For more details click Exception
	
NSArray *userList = [userService getLockedUsers]; /* returns the list of User objects. */
for(User *user in userList)
{
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSLog(@"firstName is %@" ,  user.profile.firstName);
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/
}
 
{
    "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"
                        }
                    }
                ]
            }
        }
    }
}
-(App42Response*)getLockedUsersCount

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 objects. */
BOOL success = response.isResponseSuccess;
int totalRecords = response.totalRecords;
NSString *jsonResponse = [response toString]; /* returns the response in JSON format. (as shown below)*/      
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}		
-(NSArray*)getLockedUsers:(int)max offset:(int)offset

Gets All the locked users details By paging.

Parameters:

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

Returns:

List that contains locked User Objects

Response: NSArray

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
int max = 1;
int offset = 0 ;

NSArray *userList = [userService getLockedUsers:max offset:offset]; /* returns the list of User objects. */
for(User *user in userList)
{  
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSLog(@"firstName is %@" ,  user.profile.firstName); 
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/ 
}   
 
{
    "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"
                    }
                }
            }
        }
    }
}                                         
-(NSArray*)getUsersByProfileData:(Profile*)profileData

Get Users based on Profile Data.

Parameters:

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

Returns:

List of User Object for that particular role

Response: NSArray

Exception:

This method throws following exception.
/*
2006 - NOT FOUND - Users do not exist.
*/ 		        
For more details click Exception
NSString *userName = @"Nick";						
NSString *pwd = @"********";
NSString *emailId = @"nick@shephertz.com";
User *userObj = [[User alloc]init];
Profile *profileData = [[Profile alloc]initWithUser:userObj];			
profileData.firstName = @"Nick";
profileData.lastName = @"Gill";

User *user = [userService getUsersByProfileData:profileData] /* returns the User object. */
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSLog(@"firstName is %@" ,  user.profile.firstName);
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/   
{
    "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"
                        }
                    }
                ]
            }
        }
    }
}
-(App42Response*)resetUserPassword:(NSString*)uName password:(NSString*)password

Updates the User password based on userName.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
NSString *userName = @"Nick";
NSString *password = @"*******";

App42Response *response = [userService resetUserPassword:userName password:password); /* returns the App42Response object. */
BOOL success = response.isResponseSuccess;
NSString *jsonResponse = [response toString]; /* returns the response in JSON format. (as shown below)*/     
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "password": "*******";
                }
            }
        }
    }
}
-(App42Response*)revokeRole:(NSString*)userName role:(NSString*)role

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
NSString *userName = @"Nick";
NSString *role = @"Admin";			

App42Response *response = [userService revokeRole:userName role:role]; /* returns the App42Response object. */
BOOL success = response.isResponseSuccess;
NSString *jsonResponse = [response toString]; /* returns the response in JSON format. (as shown below)*/     
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "role": "Admin"
                }
            }
        }
    }
}
-(App42Response*)revokeAllRoles:(NSString*)userName

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>' does not Exist
*/ 		        
For more details click Exception
NSString *userName = @"Nick";

App42Response *response = [userService revokeAllRoles:userName]; /* returns the App42Response object. */
BOOL success = response isResponseSuccess;
NSString *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"
                        }
                    ]
                }
            }
        }
    }
}
-(User*)updateEmail:(NSString*)uName emailAddress:(NSString*)emailAddress

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
NSString *userName = @"Nick";
NSString *emailId = @"nick@shephertz.com";	
User *user = [userService updateEmail:userName emailAddress:emailId]; /* returns the User object. */
NSString *userName = user.userName;
NSString *email = user.email;
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "email": "nick@shephertz.com"
                }
            }
        }
    }
}                                     
-(App42Response*)deleteUser:(NSString*)userName

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: User Object

Exception:

This method throws following exception.
/*
2000 - NOT FOUND - User by the name '<userName>' does not exist.
*/ 		        
For more details click Exception
NSString *userName = @"Nick";
App42Response *response = [userService deleteUser:userName]; /* returns the App42Response object. */
NSString *success = response.isResponseSuccess;
NSString *jsonResponse = [response toString]; /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick"
                }
            }
        }
    }
}                                    
-(User*)createOrUpdateProfile:(NSString *)uName profile:(ProfileData*)profile

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
NSString *userName = @"Nick";						
NSString *pwd = @"********";
NSString *emailId = @"nick@shephertz.com";
User *userObj = [userService createUser:userName password:password emailAddress:emailId]; /* returns the User object. */
Profile *profile = [[Profile alloc]initWithUser:userObj];			
profile.firstName = @"Nick";
profile.lastName = @"Gill";
profile.sex = MALE;
NSDate *date = [NSDate date]; 	/* returns the current date object.User can set any date */ 		
profile.dateOfBirth = date;
profile.city = @"Houston";
profile.state = @"Texas";
profile.pincode = @"74193";
profile.country = @"USA";
profile.mobile = @"+1-1111-111-111";
profile.homeLandLine = @"+1-2222-222-222";
profile.officeLandLine = @"+1-33333-333-333";
			
User *user = [userService createOrUpdateProfile:userObj] /* returns the User object. */
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSLog(@"firstName is %@" ,  user.profile.firstName);
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/
                            
{
    "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"
                    }
                }
            }
        }
    }
}                                      
-(App42Response*)authenticateUser:(NSString*)uName password:(NSString*)password

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
NSString *userName = @"Nick";
NSString *pwd = @"*******";

App42Response *response = [userService authenticate:userName password:pwd]; /* returns the App42Response object. */
NSString *success = response.isResponseSuccess;
NSString *jsonResponse = [response toString]; /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "accountLocked": false
                }
            }
        }
    }
}                                       
-(User*)unlockUser:(NSString*)uName

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.

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
						
NSString *userName = @"Nick"; 
						
User *user = [userService unlockUser:userName]; /* returns the User object. */
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "accountLocked": false
                }
            }
        }
    }
}                                          
-(User*)lockUser:(NSString*)uName

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
	
NSString *userName = @"Nick"; 

User *user = [userService lockUser:userName]; /* returns the User object. */
NSLog(@"userName is %@" , user.userName);
NSLog(@"emailId is %@" ,  user.emailId);
NSString *jsonResponse = [user toString]; /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick",
                    "accountLocked": true
                }
            }
        }
    }
}										
-(App42Response*)changeUserPassword:(NSString*)uName oldPassword:(NSString*)oldPwd newPassword:(NSString*)newPwd

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

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
NSString *userName = @"Nick"; 
NSString *oldPwd = @"*******"; 
NSString *newPwd = @"*******"; 
						
App42Response *response = [userService changeUserPassword:userName oldPassword:oldPwd newPassword:newPwd]; /* returns the App42Response object. */
NSString *success = response.isResponseSuccess;
NSString *jsonResponse = [response toString]; /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "users": {
                "user": {
                    "userName": "Nick"
                }
            }
        }
    }
}