Class NewsfeedAPI
- java.lang.Object
-
- com.cheetahdigital.corekit.models.module.Controller
-
- com.cheetahdigital.newsfeed.core.api.NewsfeedAPI
-
- All Implemented Interfaces:
RestController
public class NewsfeedAPI extends Controller
Class for setting the query parameters of Newsfeed API
-
-
Field Summary
-
Fields inherited from class com.cheetahdigital.corekit.models.module.Controller
STANDARD_DATE_FORMAT, TIMEZONE_DATE_FORMAT
-
-
Constructor Summary
Constructors Constructor Description NewsfeedAPI()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addComment(NewsfeedParams queryParams, NewsfeedFields fieldParams, Listener<SuccessResponse> listener)
Add a comment to the post.void
addPost(NewsfeedParams queryParams, NewsfeedFields fieldParams, java.util.List<okhttp3.MultipartBody.Part> attachments, ListenerModel<BaseModel<NewPost>,NewPost> listener)
Add a new post to the newsfeed.void
deleteComment(NewsfeedParams queryParams, ListenerModel<BaseModel<DeletedComment>,DeletedComment> listener)
Delete a comment for a specific post.void
deletePost(NewsfeedParams queryParams, ListenerModel<BaseModel<Post>,Post> listener)
Delete a post from the newsfeed.void
flagComment(NewsfeedParams queryParams, NewsfeedFields fieldParams, Listener<SuccessResponse> callback)
Flag a comment for a specific news feed post.void
flagPost(NewsfeedParams queryParams, NewsfeedFields fieldParams, Listener<SuccessResponse> callback)
Flag a post.void
getComment(NewsfeedParams queryParams, boolean clearCache, ListenerModel<BaseModel<SingleComment>,SingleComment> listener)
Get a comment from post.void
getComments(NewsfeedParams queryParams, boolean clearCache, ListenerModel<BaseModel<Comments>,Comments> listener)
Get the list of comments for a specific post.void
getFeeds(NewsfeedParams queryParams, boolean clearCache, ListenerModel<BaseModel<Feeds>,Feeds> listener)
Get all the newsfeed.void
getFlags(NewsfeedParams queryParams, boolean clearCache, ListenerModel<BaseModel<java.util.List<Flag>>,java.util.List<Flag>> listener)
Lists all available flags to be assigned or set later on a news feed post/comment.void
getNewsfeed(NewsfeedParams queryParams, boolean clearCache, ListenerModel<BaseModel<Newsfeed>,Newsfeed> listener)
Get the list of posts.void
getPost(NewsfeedParams queryParams, boolean clearCache, ListenerModel<BaseModel<Post>,Post> listener)
Get a post.void
likeComment(NewsfeedParams queryParams, Listener<SuccessResponse> listener)
Like a comment for a specific post.void
likePost(NewsfeedParams queryParams, Listener<SuccessResponse> listener)
Like a post from the newsfeed.void
unflagComment(NewsfeedParams queryParams, Listener<SuccessResponse> callback)
Unflag a comment for a specific news feed post.void
unflagPost(NewsfeedParams queryParams, Listener<SuccessResponse> callback)
Unflag a post.void
unlikeComment(NewsfeedParams queryParams, Listener<SuccessResponse> listener)
Unlike a comment for a specific post.void
unLikePost(NewsfeedParams queryParams, Listener<SuccessResponse> listener)
Unlike a post from the newsfeed.-
Methods inherited from class com.cheetahdigital.corekit.models.module.Controller
createCache, createHttpClient, createRetrofitInterface, evictAllCache, getGsonConfiguration, getRestAdapter, getTimeoutConnectionInSeconds, getTimeoutSocketInSeconds, initialize, removeResponsesFromCache
-
-
-
-
Method Detail
-
getFeeds
public void getFeeds(NewsfeedParams queryParams, boolean clearCache, ListenerModel<BaseModel<Feeds>,Feeds> listener)
Get all the newsfeed. To get a list of newsfeed for a specific category(optional), includeNewsfeedParams.setCategory(String)
in the params.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIclearCache
- clear previously stored cachelistener
- whether the newsfeed is already received from the server
-
getNewsfeed
public void getNewsfeed(NewsfeedParams queryParams, boolean clearCache, ListenerModel<BaseModel<Newsfeed>,Newsfeed> listener)
Get the list of posts. To get a list of post for a specific newsfeed, includeNewsfeedParams.setFeedName(String)
. Feed name is optional, if nothing is specified, The default newsfeed is main_newsfeed, or the first available news feed.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIclearCache
- clear previously stored cachelistener
- callback to handle the results
-
getPost
public void getPost(NewsfeedParams queryParams, boolean clearCache, ListenerModel<BaseModel<Post>,Post> listener)
Get a post. Remember to set the id byBaseParams.setId(String)
- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIclearCache
- clear previously stored cachelistener
- callback to handle the results
-
deletePost
public void deletePost(NewsfeedParams queryParams, ListenerModel<BaseModel<Post>,Post> listener)
Delete a post from the newsfeed. The post must be owned by the user. Remember to set the id byBaseParams.setId(String)
.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIlistener
- callback to handle the results
-
likePost
public void likePost(NewsfeedParams queryParams, Listener<SuccessResponse> listener)
Like a post from the newsfeed. Remember to set the id byBaseParams.setId(String)
.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIlistener
- callback to handle the results
-
unLikePost
public void unLikePost(NewsfeedParams queryParams, Listener<SuccessResponse> listener)
Unlike a post from the newsfeed. Remember to set the id byBaseParams.setId(String)
.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIlistener
- callback to handle the results
-
addPost
public void addPost(NewsfeedParams queryParams, NewsfeedFields fieldParams, java.util.List<okhttp3.MultipartBody.Part> attachments, ListenerModel<BaseModel<NewPost>,NewPost> listener)
Add a new post to the newsfeed. Remember to set the body byNewsfeedFields.setBody(String)
.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIfieldParams
- theNewsfeedFields
for Newsfeed APIattachments
- a set of images and /or videos that will be attached to the postlistener
- callback to handle the results
-
getComments
public void getComments(NewsfeedParams queryParams, boolean clearCache, ListenerModel<BaseModel<Comments>,Comments> listener)
Get the list of comments for a specific post. Remember to set the id byBaseParams.setId(String)
.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIclearCache
- clear previously stored cachelistener
- callback to handle the results
-
addComment
public void addComment(NewsfeedParams queryParams, NewsfeedFields fieldParams, Listener<SuccessResponse> listener)
Add a comment to the post. Remember to set the id of thePost
byBaseParams.setId(String)
and set the content of the comment byNewsfeedFields.setMessage(String)
.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIfieldParams
- theNewsfeedFields
for Newsfeed APIlistener
- callback to handle the results
-
getComment
public void getComment(NewsfeedParams queryParams, boolean clearCache, ListenerModel<BaseModel<SingleComment>,SingleComment> listener)
Get a comment from post. Remember to set the id of thePost
byBaseParams.setId(String)
and the id of theComment
byNewsfeedParams.setCommentId(String)
.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIclearCache
- clear previously stored cachelistener
- callback to handle the results
-
likeComment
public void likeComment(NewsfeedParams queryParams, Listener<SuccessResponse> listener)
Like a comment for a specific post. Remember to set the id of thePost
byBaseParams.setId(String)
and the id of theComment
byNewsfeedParams.setCommentId(String)
.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIlistener
- callback to handle the results
-
unlikeComment
public void unlikeComment(NewsfeedParams queryParams, Listener<SuccessResponse> listener)
Unlike a comment for a specific post. Remember to set the id of thePost
byBaseParams.setId(String)
and the id of theComment
byNewsfeedParams.setCommentId(String)
.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIlistener
- callback to handle the results
-
deleteComment
public void deleteComment(NewsfeedParams queryParams, ListenerModel<BaseModel<DeletedComment>,DeletedComment> listener)
Delete a comment for a specific post. Remember to set the id of thePost
byBaseParams.setId(String)
and the id of theComment
byNewsfeedParams.setCommentId(String)
.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIlistener
- callback to handle the results
-
getFlags
public void getFlags(NewsfeedParams queryParams, boolean clearCache, ListenerModel<BaseModel<java.util.List<Flag>>,java.util.List<Flag>> listener)
Lists all available flags to be assigned or set later on a news feed post/comment.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIclearCache
- true to clear cached response, else falselistener
- callback to handle the results
-
flagPost
public void flagPost(NewsfeedParams queryParams, NewsfeedFields fieldParams, Listener<SuccessResponse> callback)
Flag a post. Remember to set the id of thePost
byBaseParams.setId(String)
and set the selected flag byNewsfeedFields.setFlag(String)
.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIfieldParams
- contains the field parameter for Newsfeed APIcallback
- callback to handle the results
-
unflagPost
public void unflagPost(NewsfeedParams queryParams, Listener<SuccessResponse> callback)
Unflag a post. Remember to set the id of thePost
byBaseParams.setId(String)
- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIcallback
- callback to handle the results
-
flagComment
public void flagComment(NewsfeedParams queryParams, NewsfeedFields fieldParams, Listener<SuccessResponse> callback)
Flag a comment for a specific news feed post. Remember to set the id of thePost
byBaseParams.setId(String)
, id of theComment
byNewsfeedParams.setCommentId(String)
, and set the selected flag byNewsfeedFields.setFlag(String)
.- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIfieldParams
- theNewsfeedFields
for Newsfeed APIcallback
- callback to handle the results
-
unflagComment
public void unflagComment(NewsfeedParams queryParams, Listener<SuccessResponse> callback)
Unflag a comment for a specific news feed post. Remember to set the id of thePost
byBaseParams.setId(String)
and the id of theComment
byNewsfeedParams.setCommentId(String)
,- Parameters:
queryParams
- theNewsfeedParams
for Newsfeed APIcallback
- callback to handle the results
-
-