Search Conversation
Searches for conversations based on the provided search term, follow status, and pagination parameters. This function retrieves conversations that match the given criteria and returns a response containing the search results.
Steps to search for conversations
- Create a SearchConversationRequest object using the builder pattern.
- Call the
searchConversation()
function using the instance ofLMChatClient
, passing therequest
object and an optional response handler. - Process the response LMResponse<SearchConversationResponse> to handle the list of matching conversations or any errors.
let request = SearchConversationRequest.builder()
.search("ENTER_SEARCH_TERM")
.followStatus(true) // Filter by followed conversations
.page(1)
.pageSize(20)
.build()
LMChatClient.shared.searchConversation(with: request) { response in
if let result = response?.data {
// Handle success
print("Conversations found: \(result.conversations)")
} else if let error = response?.error {
// Handle error
print("Error searching conversations: \(error.localizedDescription)")
}
}
Models
SearchConversationRequest
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
search | String | Search term to query conversations | |
followStatus | Bool | Whether to filter by followed conversations | |
page | Int | Page number for pagination | |
pageSize | Int | Number of results per page |
SearchConversationResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
conversations | [SearchConversation] | Array of conversations matching the search criteria |
SearchConversation
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
answer | String | The answer or text content of the conversation | |
attachmentCount | Int | Number of attachments in the conversation | |
attachments | [Attachment] | List of attachments associated with the conversation | |
attachmentsUploaded | Bool | Whether the attachments are fully uploaded | |
chatroom | Chatroom | The chatroom the conversation belongs to | |
community | Community | Community where the conversation took place | |
createdAt | TimeInterval | Timestamp when the conversation was created | |
id | Int | Unique identifier of the conversation | |
isDeleted | Bool | Indicates if the conversation was deleted | |
isEdited | Bool | Indicates if the conversation was edited | |
lastUpdated | TimeInterval | Timestamp when the conversation was last updated | |
member | Member | The member who posted the conversation | |
state | Int | State of the conversation (e.g., active, archived) |