Skip to main content

Update User Topics

The updateUserTopics() function is used to update the topics associated with a specific user.

Steps to Update User Topics

  1. Build an UpdateUserTopicsRequest object using the UpdateUserTopicsRequestBuilder class.
  2. Call the updateUserTopics() function using an instance of the LMFeedClient class.
  3. Use the response to confirm if the topics were updated successfully.
note

The topicsId field in the request is a Map<String, bool>. Set the value as true to add the topic and false to remove the topic.

// Build the request object
UpdateUserTopicsRequest request = (UpdateUserTopicsRequestBuilder()
..topicsId({"topic_id_1": true, "topic_id_2": false})
..uuid("YOUR_USER_ID"))
.build();

// Get the response from calling the function
final UpdateUserTopicsResponse response =
await lmFeedClient.updateUserTopics(request);

// Process the response, as per your requirement
if (response.success) {
// Handle success scenario
handleUpdateSuccess();
} else {
// Handle error scenario
handleUpdateError(response.errorMessage);
}

Models

UpdateUserTopicsRequest

List of parameters for the UpdateUserTopicsRequest class

VariableTypeDescriptionOptional
topicsIdMap<String, bool>Map of topic IDs with boolean values indicating add/remove
uuidStringUser ID whose topics are to be updated

UpdateUserTopicsResponse

List of parameters for the UpdateUserTopicsResponse class

VariableTypeDescriptionOptional
successboolAPI success status
errorMessageString?Error message in case of failure

This documentation ensures that you understand how to correctly update user topics using the updateUserTopics function, providing a clear guide on how to structure requests and handle responses.