Get Universal Feed
The getUniversalFeed()
function is used to retrieve the universal feed, including posts, users, topics, widgets, and reposted posts based on specified parameters.
Steps to Get Universal Feed
Build a
GetFeedRequest
object using theGetFeedRequestBuilder
class.Call the
getUniversalFeed()
function using the instance of theLMFeedClient
class.Use the response as per your requirement.
// Build the request object
final GetFeedRequest universalFeedRequest = (GetFeedRequestBuilder()
..page(1)
..pageSize(10)
..topicIds(["topic-id-1", "topic-id-2"]))
.build();
// Get the response from calling the function
final GetFeedResponse universalFeedResponse = await lmFeedClient.getUniversalFeed(universalFeedRequest);
// Process the response, as per requirement
if(universalFeedResponse.success) {
// your function to handle successful retrieval of universal feed
handleUniversalFeedSuccess(universalFeedResponse);
} else {
// your function to handle error message
handleUniversalFeedError(universalFeedResponse.errorMessage);
}
tip
Fetching the universal feed allows you to provide users with a curated feed based on specified topics and widgets.
Models
GetFeedRequest
List of parameters for the GetFeedRequest
class
Variable | Type | Description | Optional |
---|---|---|---|
page | int | Page number for pagination | |
pageSize | int | Number of items per page | |
topics | List<String> | List of topic IDs | ✔ |
widgetIds | List<String> | List of widget IDs | ✔ |
GetFeedResponse
List of parameters for the GetFeedResponse
class
Variable | Type | Description | Optional |
---|---|---|---|
success | bool | API success status | |
errorMessage | String | Error message in case of failure | ✔ |
posts | List<Post> | List of post models | ✔ |
users | Map<String, User> | Map of user models (key: user ID) | ✔ |
topics | Map<String, Topic> | Map of topic models (key: topic ID) | ✔ |
widgets | Map<String, WidgetModel> | Map of widget models (key: widget ID) | ✔ |
repostedPosts | Map<String, Post> | Map of reposted post models (key: post ID) | ✔ |
filteredComments | Map<String, Comment> | Map of filtered comments | ✔ |
userTopics | Map<String, List<String>> | Map of user topics (key: user ID) | ✔ |