User¶
-
public class
User
implements Serializable¶ Represents a CultureMesh user’s public profile. Methods that require non-public data (e.g. email or password) take that information in as parameters and do not store it after the method completes.
Fields¶
id¶
-
public long
id
¶ The user’s unique identifier, which identifies them across all of CultureMesh and is constant. Not editable by user.
Constructors¶
User¶
-
public
User
(long id, String firstName, String lastName, String username, String imgURL, String aboutMe, String gender)¶ Create a new object, storing the provided parameters into the related instance fields.
Parameters: - id – Uniquely identifies user across all of CultureMesh.
- firstName – User’s first name (may be pseudonymous)
- lastName – User’s last name (may be pseudonymous)
- username – The user’s “display name” that will serve as their main public identifier. Must be unique across all of CultureMesh’s users.
- imgURL – URL suffix (after
User.IMG_URL_PREFIX
to the user’s profile picture - aboutMe – Short bio describing the user
- gender – User’s self-identified gender
User¶
-
public
User
(long id, String firstName, String lastName, String username)¶ Create a new object, storing the provided parameters into the related instance fields. Intended to be used when creating accounts, as
img_url
,about_me
, andgender
are initialized to defaults as described in the constants forUser
.Parameters: - id – Uniquely identifies user across all of CultureMesh.
- firstName – User’s first name (may be pseudonymous)
- lastName – User’s last name (may be pseudonymous)
- username – The user’s “display name” that will serve as their main public identifier. Must be unique across all of CultureMesh’s users.
User¶
-
public
User
(JSONObject res)¶ Create a new user from a JSON that conforms to the following format:
{ "id": 0, "username": "string", "first_name": "string", "last_name": "string", "role": 0, "gender": "string", "about_me": "string", "img_link": "string", }
Other key-value pairs are acceptable, but will be ignored. Note that
img_link
does not include the baseUser.IMG_URL_PREFIX
. A missing, null, or emptyimg_link
is interpreted as an unset link, whichUser.CM_LOGO_URL
is used for.Parameters: - res – JSON describing the user to create
Throws: - JSONException – May be thrown in the case of an improperly structured JSON
Methods¶
getBio¶
getFirstName¶
getImgURL¶
getLastName¶
getPostJson¶
-
public JSONObject
getPostJson
(String email, String password)¶ Create a JSON representation of the object that conforms to the following format:
{ "username": "string", "password": "string", "first_name": "string", "last_name": "string", "email": "string", "role": 0, "img_link": "string", "about_me": "string", "gender": "string" }
This is intended to be the format used by the
/user/users
POST endpoint. Note thatimg_link
does not include the baseUser.IMG_URL_PREFIX
. A missing, null, or emptyimg_link
is interpreted as an unset link, whichUser.CM_LOGO_URL
is used for.Throws: - JSONException – Unclear when this would be thrown
Returns: JSON representation of the object
getPutJson¶
-
public JSONObject
getPutJson
(String email)¶ Create a JSON representation of the object that conforms to the following format:
{ "id": 0, "username": "string", "first_name": "string", "last_name": "string", "email": "string", "role": 0, "gender": "string", "about_me": "string", "img_link": "string" }
This is intended to be the format used by the
/user/users
PUT endpoint. Note thatimg_link
does not include the baseUser.IMG_URL_PREFIX
. A missing, null, or emptyimg_link
is interpreted as an unset link, whichUser.CM_LOGO_URL
is used for.Throws: - JSONException – Unclear when this would be thrown
Returns: JSON representation of the object