Add Poll Option
The addPollOption() method allows you to add an option to a poll in a specific conversation. The request requires the poll text and the conversationId. The response provides the added poll option.
Steps to Add a Poll Option
- Create an
AddPollOptionRequestobject with the required parameters:poll(poll option text) andconversationId. - Call the
addPollOption()function using the instance of theLMChatClientclass. - Use the response LMResponse<
AddPollOptionResponse> to retrieve the newly added poll option.
AddPollOptionRequest request = (AddPollOptionRequestBuilder()
..poll('ENTER_POLL_TEXT') // Provide the poll option text
..conversationId("ENTER_CONVERSATION_ID")) // Provide the conversation ID
.build();
final LMResponse<AddPollOptionResponse> response =
await lmChatClient.addPollOption(request);
if (response.success) {
// Handle the added poll option
PollOption addedPollOption = response.data?.poll ?? PollOption();
handleAddedPollOption(addedPollOption);
} else {
// Handle error
handleError(response);
}
tip
Ensure that both poll (poll option text) and conversationId are provided to add a new option to the poll.
Models
AddPollOptionRequest
List of parameters for the AddPollOptionRequest class:
| Variable | Type | Description | Optional |
|---|---|---|---|
poll | String | The text of the poll option | |
conversationId | int | The ID of the conversation |
AddPollOptionResponse
List of parameters for the AddPollOptionResponse class:
| Variable | Type | Description | Optional |
|---|---|---|---|
poll | PollOption | The added poll option | ✔️ |