Search Chatrooms
Searches for chatrooms based on the specified request. This function allows users to search for chatrooms using various parameters like search terms, follow status, and pagination, and returns a response with the matching chatrooms.
Steps to search for chatrooms
- Create a SearchChatroomRequest object using the builder pattern.
- Call the
searchChatroom()
function using the instance ofSearchClient
, passing therequest
object and an optional response handler. - Process the response LMResponse<SearchChatroomResponse> to handle the found chatrooms or any errors.
let request = SearchChatroomRequest.builder()
.search("ENTER_SEARCH_TERM")
.followStatus(true)
.page(1)
.pageSize(20)
.searchType("ENTER_SEARCH_TYPE")
.build()
SearchClient.shared.searchChatroom(request: request) { response in
if let result = response?.data {
// Handle success
print("Chatrooms found: \(result.conversations)")
} else if let error = response?.error {
// Handle error
print("Error searching chatrooms: \(error.localizedDescription)")
}
}
Models
SearchChatroomRequest
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
search | String | The search term to query chatrooms | |
followStatus | Bool | Whether to filter by followed chatrooms | ✔️ |
page | Int | Page number for pagination | |
pageSize | Int | Number of results per page | |
searchType | String | On which key, search to be happen (e.g., "header", "title") | ✔️ |
SearchChatroomResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
chatrooms | [SearchChatroom] | Array of chatrooms matching the search criteria |
SearchChatroom
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
attachments | [Attachment] | List of attachments associated with the chatroom | |
attendingStatus | Bool | Whether the user is attending the chatroom | |
chatroom | Chatroom | The chatroom object | |
community | Community | Community where the chatroom exists | |
followStatus | Bool | Whether the user follows the chatroom | |
id | Int | Unique identifier of the chatroom | |
isGuest | Bool | Whether the user is a guest in the chatroom | |
isTagged | Bool | Whether the chatroom is tagged | |
member | Member | The member associated with the chatroom | |
muteStatus | Bool | Whether the chatroom is muted | |
secretChatroomLeft | Bool | Whether the secret chatroom has been left | |
state | Int | State of the chatroom (e.g., active, archived) | |
updatedAt | TimeInterval | Last updated timestamp of the chatroom | |
isDisabled | Bool? | Whether the chatroom is disabled | ✔️ |