Post¶
-
public class
Post
extends FeedItem implements Serializable, Postable, Putable¶ Represents a post made by a user in a network. A post is arbitrary, formatted text of the user’s choosing.
Fields¶
author¶
The
User
who created the post. This may not be present and have to be instantiated fromPost.userId
. Currently, this is handled byorg.codethechange.culturemesh.API
datePosted¶
network¶
-
public Network
network
¶ The
Network
who created the post. This may not be present and have to be instantiated fromPost.networkId
. Currently, this is handled byorg.codethechange.culturemesh.API
networkId¶
userId¶
Constructors¶
Post¶
-
public
Post
(long id, long author, long networkId, String content, String imgLink, String vidLink, String datePosted)¶ Create a new post object from the provided parameters. The resulting object will not be fully instantiated (e.g.
Post.author
andPost.network
will benull
.Parameters: - id – Uniquely identifies the post across all of CultureMesh
- author – ID of
User
who created the post - networkId – ID of the
Network
in which the post was made - content – Formatted text that composes the body of the post.
- imgLink – Link to an image associated with the post.
null
if none associated. - vidLink – Link to a video associated with the post.
null
if none associated - datePosted – When the post was created. Must conform to
EEE, dd MMM yyyy kk:mm:ss z
Post¶
-
public
Post
(JSONObject json)¶ Creates a bare (uninstantiated)
Post
from a JSON that conforms to the below format:{ "id": 0, "id_user": 0, "id_network": 0, "post_date": "string", "post_text": "string", "post_class": 0, "post_original": "string", "vid_link": "string", "img_link": "string" }
Parameters: - json – JSON representation of the
Post
to construct
Throws: - JSONException – May be thrown in response to an improperly formatted JSON
- json – JSON representation of the
Methods¶
getAuthor¶
getContent¶
getDatePosted¶
getImageLink¶
getNetwork¶
getPostJson¶
-
public JSONObject
getPostJson
()¶ Wrapper for
Post.toJSON()
getPostedTime¶
getPutJson¶
-
public JSONObject
getPutJson
()¶ Wrapper for
Post.toJSON()
getVideoLink¶
setContent¶
setDatePosted¶
setImageLink¶
setVideoLink¶
toJSON¶
-
public JSONObject
toJSON
()¶ Generate a JSON describing the object. The JSON will conform to the following format:
{ "id_user": 0, "id_network": 0, "post_text": "string", "vid_link": "string", "img_link": "string" }
The resulting object is suitable for use with the
/post/new
endpoint (PUT and POST).Throws: - JSONException – Unclear when this would be thrown
Returns: JSON representation of the object