com.netmera.mobile
Class NetmeraUser

java.lang.Object
  extended by com.netmera.mobile.NetmeraUser

public class NetmeraUser
extends java.lang.Object

NetmeraUser object is for managing users of the application. You can register, update, login users with this class.


Constructor Summary
NetmeraUser()
          Default constructor to create user object.
 
Method Summary
 void activateUser(java.lang.String email)
          Activates the registered User.
 void deactivateUser(java.lang.String email)
          Deactivates the registered User
static NetmeraUser getCurrentUser()
          Returns the current logged user.
 java.util.Map<java.lang.String,java.lang.Object> getCustomFields()
           
 java.lang.String getEmail()
          Returns the email of the user
 java.lang.String getName()
          Returns the name of the user
 java.lang.String getNickname()
          Returns the nickname of the user
 java.lang.String getSurname()
          Returns the surname of the user
 boolean isGeneratedMail()
          Returns the mail status of the user.
 boolean isNewUser()
          Returns the status of the user.
static NetmeraUser login(java.lang.String email, java.lang.String password)
          Logs a user into the registered application.
static NetmeraUser loginAsGuest()
          Logs a guest into the application.
static void loginAsGuestInBackground(NetmeraCallback<NetmeraUser> callback)
          Logs a guest into the application in the background thread.
static void loginInBackground(java.lang.String email, java.lang.String password, NetmeraCallback<NetmeraUser> callback)
          Logs the user into the registered application in the background thread.
static void logout()
          User logged out from the application.
 void register()
          Registers new user.
 void registerInBackground(NetmeraCallback<NetmeraUser> callback)
          Registers user in the background thread.
 void setCustomFields(java.util.Map<java.lang.String,java.lang.Object> customFields)
           
 void setEmail(java.lang.String email)
          Sets the email of the user
 void setName(java.lang.String name)
          Sets the name of the user
 void setNickname(java.lang.String nickname)
          Sets the nickname of the user
 void setPassword(java.lang.String password)
          Sets the password of the user
 void setSurname(java.lang.String surname)
          Sets the surname of the user
 void update()
          Updates user info.
 void updateInBackground(NetmeraCallback<NetmeraUser> callback)
          Updates user info in the background thread.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetmeraUser

public NetmeraUser()
Default constructor to create user object.

Method Detail

getEmail

public java.lang.String getEmail()
Returns the email of the user

Returns:
email of the user

setEmail

public void setEmail(java.lang.String email)
Sets the email of the user

Parameters:
email - of the user

setPassword

public void setPassword(java.lang.String password)
Sets the password of the user

Parameters:
password - of the user

getNickname

public java.lang.String getNickname()
Returns the nickname of the user

Returns:
nickname of the user

setNickname

public void setNickname(java.lang.String nickname)
Sets the nickname of the user

Parameters:
nickname - of the user

getName

public java.lang.String getName()
Returns the name of the user

Returns:
name of the user

setName

public void setName(java.lang.String name)
Sets the name of the user

Parameters:
name - of the user

getSurname

public java.lang.String getSurname()
Returns the surname of the user

Returns:
surname of the user

setSurname

public void setSurname(java.lang.String surname)
Sets the surname of the user

Parameters:
surname - of the user

getCustomFields

public java.util.Map<java.lang.String,java.lang.Object> getCustomFields()

setCustomFields

public void setCustomFields(java.util.Map<java.lang.String,java.lang.Object> customFields)

isNewUser

public boolean isNewUser()
Returns the status of the user. If it is newly created it returns true

Returns:
status of the user

isGeneratedMail

public boolean isGeneratedMail()
Returns the mail status of the user. If it is auto-generated it returns false

Returns:
status of the user

getCurrentUser

public static NetmeraUser getCurrentUser()
                                  throws NetmeraException
Returns the current logged user. If no user logged in then it returns null.

Returns:
current user
Throws:
NetmeraException

register

public void register()
              throws NetmeraException
Registers new user. Before calling this method email,password and nickname fields of the NetmeraUser should be setted. Those are the compulsory fields. There are also optional name and surname fields.

NetmeraUser user = new NetmeraUser();
user.setEmail("test@test.com");
user.setNickname("test");
user.setPassword("123456");
user.register();

Throws:
NetmeraException

registerInBackground

public void registerInBackground(NetmeraCallback<NetmeraUser> callback)
Registers user in the background thread. Since it runs on the background thread it does not block program.It is recommended over register() method.

Parameters:
callback - NetmeraCallback.onFail(NetmeraException) or NetmeraCallback.onSuccess(Object) methods called when register operation finishes.

update

public void update()
            throws NetmeraException
Updates user info. Before calling this method email,password and nickname fields of the NetmeraUser should be setted. Those are the compulsory fields.

Throws:
NetmeraException

updateInBackground

public void updateInBackground(NetmeraCallback<NetmeraUser> callback)
Updates user info in the background thread. Since it runs on the background thread it does not block program.It is recommended over update() method.

Parameters:
callback - NetmeraCallback.onFail(NetmeraException) or NetmeraCallback.onSuccess(Object) methods called when update operation finishes.

login

public static NetmeraUser login(java.lang.String email,
                                java.lang.String password)
                         throws NetmeraException
Logs a user into the registered application. Email and password fields of user is used for this operation.

Parameters:
email - of the user
password - of the user
Returns:
the logged User
Throws:
NetmeraException

loginInBackground

public static void loginInBackground(java.lang.String email,
                                     java.lang.String password,
                                     NetmeraCallback<NetmeraUser> callback)
Logs the user into the registered application in the background thread. Since it runs on the background thread it does not block program.It is recommended over login() method.

Parameters:
email - of the user
password - of the user
callback - NetmeraCallback.onFail(NetmeraException) or NetmeraCallback.onSuccess(Object) methods called when login operation finishes.

loginAsGuest

public static NetmeraUser loginAsGuest()
                                throws NetmeraException
Logs a guest into the application.

Returns:
the logged User
Throws:
NetmeraException

loginAsGuestInBackground

public static void loginAsGuestInBackground(NetmeraCallback<NetmeraUser> callback)
Logs a guest into the application in the background thread. Since it runs on the background thread it does not block program.It is recommended over loginAsGuest() method.

Parameters:
callback - NetmeraCallback.onFail(NetmeraException) or NetmeraCallback.onSuccess(Object) methods called when guest login operation finishes.

logout

public static void logout()
User logged out from the application.


activateUser

public void activateUser(java.lang.String email)
                  throws NetmeraException
Activates the registered User.

Parameters:
email - of the user
Throws:
NetmeraException

deactivateUser

public void deactivateUser(java.lang.String email)
                    throws NetmeraException
Deactivates the registered User

Parameters:
email - of the user
Throws:
NetmeraException