Skip to main content

Fetch Post

The getPost() function is used to fetch a post. It takes a GetPostRequest as input, which includes the postId, page, and pageSize. The function returns a GetPostResponse as a Future.

Steps to Get a Post​

  1. Create an instance of GetPostRequest with the required parameters: postId, page, and pageSize.
  2. Call the getPost() function using the instance of the LMFeedClient class, passing the request as a parameter.
  3. Use the response as per your requirement.
// Create an instance of GetPostRequest
GetPostRequest request = (GetPostRequestBuilder()
..page(1)
..pageSize(10)
..postId("post_id"))
.build();

// Get the response from calling the function
final GetPostResponse getPostResponse = await lmFeedClient.getPost(getPostRequest);

// Process the response, as per requirement
if (getPostResponse.success) {
// your function to handle successful retrieval of the post
handleGetPostSuccess(getPostResponse.post, getPostResponse.users, getPostResponse.topics, getPostResponse.widgets, getPostResponse.repostedPosts);
} else {
// your function to handle error message
handleGetPostError(getPostResponse.errorMessage);
}

Models​

GetPostRequest​

List of parameters for the GetPostRequest class

VariableTypeDescriptionOptional
postIdStringUnique identifier of the post
pageintPage number for pagination
pageSizeintNumber of items per page

GetPostResponse​

List of parameters for the GetPostResponse class

VariableTypeDescriptionOptional
successboolAPI success status
errorMessageStringError message in case of failure✔
postPostThe fetched post entity
usersMap<String, User>Map of user UUIDs to User entities
topicsMap<String, Topic>Map of topic IDs to Topic entities
widgetsMap<String, WidgetModel>Map of widget IDs to WidgetModel entities
repostedPostsMap<String, Post>Map of post IDs to reposted Post entities
userTopicsMap<String, List<String>>Map of user topics (key: user ID)✔