Fetch Comment
The getComment() function serves the purpose of fetching a specific comment along with its associated replies. By utilizing this function, developers can seamlessly retrieve detailed information about a comment and the ensuing conversation.
Steps to Get Comment
- Create an instance of
GetCommentRequestwith the required parameters:commentId,postId, andpage. - Call the
getComment()function using the instance of theLMFeedClientclass, passing the request as a parameter. - Utilize the response as per your application's requirements.
// Create an instance of GetCommentRequest
GetCommentRequest request = (GetCommentRequestBuilder()
..postId("post_id")
..commentId("comment_id")
..page(1))
.build();
// Get the response from calling the function
final GetCommentResponse commentResponse = await lmFeedClient.getComment(commentRequest);
// Process the response, as per requirement
if (commentResponse.success) {
// your function to handle successful retrieval of the comment and replies
handleGetCommentSuccess(commentResponse.postReplies, commentResponse.users);
} else {
// your function to handle error message
handleGetCommentError(commentResponse.errorMessage);
}
Models
GetCommentRequest
List of parameters for the GetCommentRequest class
| Variable | Type | Description |
|---|---|---|
| commentId | String | Comment ID to retrieve |
| postId | String | Post ID associated with the comment |
| page | int | Page number for pagination |
GetCommentResponse
List of parameters for the GetCommentResponse class
| Variable | Type | Description | Optional |
|---|---|---|---|
| success | bool | API success status | |
| errorMessage | String | Error message in failure | ✔ |
| postReplies | Comment | Comment and replies entity | ✔ |
| users | Map<String, User> | Map of user UUIDs to User entities | ✔ |
| topics | Map<String, Topic> | Map of topic IDs to Topic entities | |
| widgets | Map<String, WidgetModel> | Map of widget IDs to WidgetModel entities | |
| userTopics | Map<String, List<String>> | Map of user topics (key: user ID) | ✔ |