Fetch Post
Retrieves a specific post from the server, allowing users to view its content, comments, likes, and other associated information.
Steps to fetch a post
- Create a GetPostRequest object using
GetPostRequest.Builder
class by passing all the required parameters. - Call
getPost()
function using the instance ofLMFeedClient
. - Process the response (LMResponse<GetPostResponse>) as per your requirement.
CoroutineScope(Dispatchers.IO).launch {
// object of GetPostRequest
val getPostRequest = GetPostRequest.Builder()
.postId("ENTER POST ID") // id of the post fetched
.page(1) // page number for paginated comments
.pageSize(5) // page size for paginated comments
.build()
// get response (LMResponse<GetPostResponse>)
val response = LMFeedClient.getInstance().getPost(getPostRequest)
if (response.success) {
// your function to process the response data
processGetPostResponse(response.data)
} else {
// your function to process error message
processError(response.errorMessage)
}
}
Models
GetPostRequest
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
postId | String | Unique id of the post fetched. | |
page | Int | Page number of paginated comment data on the post. | |
pageSize | Int | Page size for paginated comment data on the post. |
GetPostResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
post | Post | Object of the post fetched. | |
users | Map<String, User> | Map of user unique id to user object. | |
topics | Map<String, Topic> | Map of topic id to topic object. | |
widgets | Map<String, Widget> | Map of widget id to widget object. |