getPostsByIds method

Future<List<MmPost>?> getPostsByIds(
  1. List<String> requestBody
)

Get posts by a list of ids

Fetch a list of posts based on the provided postIDs ##### Permissions Must have read_channel permission for the channel the post is in or if the channel is public, have the read_public_channels permission for the team.

Parameters:

  • List<String> requestBody (required): List of post ids

Implementation

Future<List<MmPost>?> getPostsByIds(
  List<String> requestBody,
) async {
  final response = await getPostsByIdsWithHttpInfo(
    requestBody,
  );
  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) {
    final responseBody = await _decodeBodyBytes(response);
    return (await apiClient.deserializeAsync(responseBody, 'List<MmPost>') as List).cast<MmPost>().toList();
  }
  return null;
}