Get Topics
The getTopics()
function is used to fetch a list of topics, which can be utilized for creating posts or other interactions within the community.
Steps to Get Topics
- Build a
GetTopicsRequest
object using theGetTopicsRequestBuilder
class. - Call the
getTopics()
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
GetTopicsRequest request = (GetTopicsRequestBuilder()
..isEnabled(true)
..page(1)
..pageSize(10)
..search("example")
..searchType("type")
)
.build();
// Get the response from calling the function
final GetTopicsResponse response = await lmFeedClient.getTopics(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);
}
tip
Fetching topics is essential for creating posts and engaging with the community. You can use the retrieved topics to provide users with relevant content and discussions.
Models
GetTopicsRequest
List of parameters for the GetTopicsRequest
class
Variable | Type | Description | Optional |
---|---|---|---|
isEnabled | bool | Flag indicating whether topics are enabled | ✔ |
page | int | Page number for pagination | |
pageSize | int | Number of items per page | |
search | String | Search query for filtering topics | ✔ |
searchType | String | Type of search query | ✔ |
parentIds | List<String> | A list of parent topic IDs that this topic is associated with. | ✔ |
orderBy | List<String> | Specifies the order in which topics should be sorted. | ✔ |
GetTopicsResponse
List of parameters for the GetTopicsResponse
class
Variable | Type | Description | Optional |
---|---|---|---|
success | bool | API success status | |
errorMessage | String | Error message in case of failure | ✔ |
topics | List<Topic > | List of topic models | ✔ |
widgets | Map<String, WidgetModel > | Map of widget IDs to WidgetModel entities | |
childTopics | Map<String,List< Topic >> | Map of parent topic IDs to List of child topics |