Get User Topics
The getUserTopics()
function is used to fetch a list of topics which a user have followed.
Steps to Get Topics
- Build a
GetUserTopicsRequest
object using theGetUserTopicsRequestBuilder
class. - Call the
getUserTopics()
function using the instance of theLMFeedClient
class. - Use the response as per your requirement.
note
isEnabled
key is nullable, if you want to fetch enabled topics send isEnabled
= true
. For disabled topics send isEnabled
= false
and to fetch all the existing topics send send isEnabled
= null
// Build the request object
GetUserTopicsRequest request = (GetUserTopicsRequestBuilder()
..uuids(["YOUR_USER_ID"])
)
.build();
// Get the response from calling the function
final GetUserTopicsResponse response = await lmFeedClient.getUserTopics(request);
// Process the response, as per requirement
if(response.success){
// your function to handle successful retrieval of topics
handleTopics(response.topics);
}else{
// your function to handle error message
handleTopicsError(response.errorMessage);
}
Models
GetUserTopicsRequest
List of parameters for the GetTopicsRequest
class
Variable | Type | Description | Optional |
---|---|---|---|
uuids | List<String> | List of user id who's followed topic to be fetched |
GetUserTopicsResponse
List of parameters for the GetUserTopicsResponse
class
Variable | Type | Description | Optional |
---|---|---|---|
success | bool | API success status | |
errorMessage | String? | Error message in case of failure | ✔ |
userTopics | Map<String, List<String>>? | Map of user IDs to their associated topics | ✔ |
topics | Map<String, Topic>? | Map of topic IDs to Topic entities | ✔ |
users | Map<String, User>? | Map of user IDs to User entities | ✔ |
widgets | Map<String, WidgetModel>? | Map of widget IDs to WidgetModel entities | ✔ |