public final class MesosferUser
extends java.lang.Object
MesosferUser
is a local representation of user data that can be saved and
retrieved from the Mesosfer cloud.Modifier and Type | Method and Description |
---|---|
void |
changePasswordAsync(java.lang.String oldPassword,
java.lang.String newPassword,
ChangePasswordCallback callback)
Change password user using background thread.
|
static MesosferUser |
createUser()
Constructs a new MesosferUser with no data in it.
|
void |
fetchAsync(GetCallback<MesosferUser> callback)
Fetches this user with the data from the server in a background thread.
|
java.lang.String |
getCountry()
Gets country code.
|
java.util.Date |
getCreatedAt()
This reports time as the server sees it, so that if you create a
MesosferUser ,
then wait a while, and then call saveAsync(SaveCallback) , the creation time will be
the time of the first saveAsync(SaveCallback) call rather than the time the object
was created locally. |
static MesosferUser |
getCurrentUser()
This retrieves the currently logged in MesosferUser with a valid session, either from memory or
disk if necessary.
|
MesosferObject |
getData()
Gets the
MesosferObject that already saved in MesosferUser . |
org.json.JSONArray |
getDataArray(java.lang.String key)
Gets the
JSONArray value from the getData() given key string. |
boolean |
getDataBoolean(java.lang.String key)
Gets the
Boolean value from the getData() given key string. |
java.util.Date |
getDataDate(java.lang.String key)
Gets the
Date value from the getData() given key string. |
double |
getDataDouble(java.lang.String key)
Gets the
Double value from the getData() given key string. |
int |
getDataInteger(java.lang.String key)
Gets the
Integer value from the getData() given key string. |
long |
getDataLong(java.lang.String key)
Gets the
Long value from the getData() given key string. |
java.lang.Number |
getDataNumber(java.lang.String key)
Gets the
Number value from the getData() given key string. |
org.json.JSONObject |
getDataObject(java.lang.String key)
Gets the
JSONObject value from the getData() given key string. |
MesosferDataSchema |
getDataSchema()
Gets data
MesosferDataSchema of this object. |
java.lang.String |
getDataString(java.lang.String key)
Gets the
String value from the getData() given key string. |
java.lang.String |
getEmail()
Retrieves the email address.
|
java.lang.String |
getFirstName()
Gets first name.
|
java.lang.String |
getLastName()
Gets last name.
|
java.lang.String |
getObjectId()
Accessor to the object id.
|
java.lang.String |
getPhone()
Gets phone.
|
static MesosferQuery<MesosferUser> |
getQuery()
Constructs a query for
MesosferUser . |
java.util.Date |
getUpdatedAt()
This reports time as the server sees it, so that if you make changes to a
MesosferUser ,
then wait a while, and then call saveAsync(SaveCallback) , the updated time will be
the time of the saveAsync(SaveCallback) call rather than the time the object
was changed locally. |
static void |
logInAsync(java.lang.String email,
java.lang.String password,
LogInCallback callback)
Logs in a user with an email and password.
|
static void |
logOutAsync(LogOutCallback callback)
Logs out the currently logged in user session.
|
void |
registerAsync(RegisterCallback callback)
Signs up a new user.
|
void |
saveAsync(SaveCallback callback)
Saves this object to the server in a background thread.
|
MesosferUser |
setCountry(java.lang.String country)
Sets country code.
|
MesosferUser |
setData(java.lang.String key,
java.lang.Object value)
Add a key-value pair to this object.
|
MesosferUser |
setEmail(java.lang.String email)
Sets the email address.
|
MesosferUser |
setFirstName(java.lang.String firstName)
Sets first name.
|
MesosferUser |
setLastName(java.lang.String lastName)
Sets last name.
|
MesosferUser |
setPassword(java.lang.String password)
Sets the password.
|
MesosferUser |
setPhone(java.lang.String phone)
Sets phone.
|
org.json.JSONObject |
toJSON()
To put all keys and values of this
MesosferData into a JSONObject . |
java.lang.String |
toString() |
void |
updateDataAsync(SaveCallback callback)
Deprecated.
Use
saveAsync(SaveCallback) instead |
public static MesosferUser createUser()
registerAsync(RegisterCallback)
is called.public static MesosferQuery<MesosferUser> getQuery()
MesosferUser
.public static MesosferUser getCurrentUser()
public java.lang.String getEmail()
public java.lang.String getObjectId()
public java.util.Date getCreatedAt()
MesosferUser
,
then wait a while, and then call saveAsync(SaveCallback)
, the creation time will be
the time of the first saveAsync(SaveCallback)
call rather than the time the object
was created locally.public java.util.Date getUpdatedAt()
MesosferUser
,
then wait a while, and then call saveAsync(SaveCallback)
, the updated time will be
the time of the saveAsync(SaveCallback)
call rather than the time the object
was changed locally.public MesosferDataSchema getDataSchema()
MesosferDataSchema
of this object.MesosferDataSchema
objectpublic MesosferObject getData()
MesosferObject
that already saved in MesosferUser
.MesosferObject
public java.lang.String getDataString(java.lang.String key)
String
value from the getData()
given key string.key
- the key of String
value to get fromString
valuepublic java.util.Date getDataDate(java.lang.String key)
Date
value from the getData()
given key string.key
- the key of Date
value to get fromDate
valuepublic int getDataInteger(java.lang.String key)
Integer
value from the getData()
given key string.key
- the key of Integer
value to get fromInteger
valuepublic double getDataDouble(java.lang.String key)
Double
value from the getData()
given key string.key
- the key of Double
value to get fromDouble
valuepublic long getDataLong(java.lang.String key)
Long
value from the getData()
given key string.key
- the key of Long
value to get fromLong
valuepublic java.lang.Number getDataNumber(java.lang.String key)
Number
value from the getData()
given key string.key
- the key of Number
value to get fromNumber
valuepublic boolean getDataBoolean(java.lang.String key)
Boolean
value from the getData()
given key string.key
- the key of Boolean
value to get fromBoolean
valuepublic org.json.JSONObject getDataObject(java.lang.String key)
JSONObject
value from the getData()
given key string.key
- the key of JSONObject
value to get fromJSONObject
valuepublic org.json.JSONArray getDataArray(java.lang.String key)
JSONArray
value from the getData()
given key string.key
- the key of JSONArray
value to get fromJSONArray
valuepublic java.lang.String getFirstName()
public java.lang.String getLastName()
@Nullable public java.lang.String getCountry()
@Nullable public java.lang.String getPhone()
public org.json.JSONObject toJSON()
MesosferData
into a JSONObject
.JSONObject
of all keys and valuespublic java.lang.String toString()
toString
in class java.lang.Object
public MesosferUser setEmail(java.lang.String email)
email
- The email address to set.public MesosferUser setPassword(java.lang.String password)
password
- The password to set.public MesosferUser setFirstName(java.lang.String firstName)
firstName
- The first name to set.public MesosferUser setLastName(java.lang.String lastName)
lastName
- The last name to set.public MesosferUser setCountry(@NonNull java.lang.String country)
country
- The country to set.public MesosferUser setPhone(@NonNull java.lang.String phone)
phone
- the phone to set.public MesosferUser setData(@NonNull java.lang.String key, java.lang.Object value)
camelCaseLikeThis
.key
- Keys must be alphanumerical, and start with a letter.value
- Values may be numerical, String
, JSONObject
, JSONArray
,
JSONObject.NULL
, or Date
s. value may not be null
.public void registerAsync(RegisterCallback callback)
saveAsync(SaveCallback)
for
new MesosferUsers. This will create a new MesosferUser on the server, and also persist the
session on disk so that you can access the user using getCurrentUser()
.
An email and a password must be set before calling register.
This is preferable to using registerAsync(RegisterCallback)
callback
- callback.done(user, e) is called when the register completes.public static void logInAsync(@NonNull java.lang.String email, @NonNull java.lang.String password, LogInCallback callback)
getCurrentUser()
.
This is preferable to using logInAsync(String, String, LogInCallback)
,
unless your code is already running from a background thread.email
- The email address to log in with.password
- The password to log in with.callback
- callback.done(user, e) is called when the login completes.public void fetchAsync(GetCallback<MesosferUser> callback)
callback
- callback.done(object, e)
is called when the fetch completes.public static void logOutAsync(LogOutCallback callback)
Logs out the currently logged in user session. This will remove the session from disk, log out
of linked services, and future calls to getCurrentUser()
will return null
.
@Deprecated public void updateDataAsync(SaveCallback callback)
saveAsync(SaveCallback)
insteadcallback
- callback.done(e)
is called when the save completes.public void saveAsync(SaveCallback callback)
callback
- callback.done(e)
is called when the save completes.public void changePasswordAsync(java.lang.String oldPassword, java.lang.String newPassword, ChangePasswordCallback callback)
oldPassword
- the old password to changenewPassword
- the new password to setcallback
- callback.done(e)
is called when the save completes.