searchFiles method

Future<MmFileInfoList?> searchFiles(
  1. String teamId,
  2. String terms,
  3. bool isOrSearch, {
  4. int? timeZoneOffset,
  5. bool? includeDeletedChannels,
  6. int? page,
  7. int? perPage,
})

Search files in a team

Search for files in a team based on file name, extention and file content (if file content extraction is enabled and supported for the files). Minimum server version: 5.34 ##### Permissions Must be authenticated and have the view_team permission.

Parameters:

  • String teamId (required): Team GUID

  • String terms (required): The search terms as inputed by the user. To search for files from a user include from:someusername, using a user's username. To search in a specific channel include in:somechannel, using the channel name (not the display name). To search for specific extensions included ext:extension.

  • bool isOrSearch (required): Set to true if an Or search should be performed vs an And search.

  • int timeZoneOffset: Offset from UTC of user timezone for date searches.

  • bool includeDeletedChannels: Set to true if deleted channels should be included in the search. (archived channels)

  • int page: The page to select. (Only works with Elasticsearch)

  • int perPage: The number of posts per page. (Only works with Elasticsearch)

Implementation

Future<MmFileInfoList?> searchFiles(
  String teamId,
  String terms,
  bool isOrSearch, {
  int? timeZoneOffset,
  bool? includeDeletedChannels,
  int? page,
  int? perPage,
}) async {
  final response = await searchFilesWithHttpInfo(
    teamId,
    terms,
    isOrSearch,
    timeZoneOffset: timeZoneOffset,
    includeDeletedChannels: includeDeletedChannels,
    page: page,
    perPage: perPage,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw MmApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(
      await _decodeBodyBytes(response),
      'MmFileInfoList',
    ) as MmFileInfoList;
  }
  return null;
}