Add Poll Option
Adds a new option to an existing poll in a conversation. This function allows users to contribute additional options to a poll that supports the addition of new choices.
Steps to add a poll option
- Create an AddPollOptionRequest object using the builder pattern.
- Call the
addPollOption()
function using the instance ofLMChatClient
, passing therequest
object and an optional response handler. - Process the response LMResponse<AddPollOptionResponse> to handle the added poll option or any errors.
let request = AddPollOptionRequest.builder()
.conversationId("ENTER_CONVERSATION_ID")
.poll(Poll.Builder().option("New Option").build())
.build()
PollClient.shared.addPollOption(request: request) { response in
if let result = response?.data {
// Handle success
print("Poll option added: \(result.poll)")
} else if let error = response?.error {
// Handle error
print("Error adding poll option: \(error.localizedDescription)")
}
}
Models
AddPollOptionRequest
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
conversationId | String | ID of the conversation the poll belongs to | |
poll | Poll | The poll option being added |
AddPollOptionResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
poll | Poll | The newly added poll option |