getPost method

Future<MmPost?> getPost(
  1. String postId, {
  2. bool? includeDeleted,
})

Get a post

Get a single post. ##### 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:

  • String postId (required): ID of the post to get

  • bool includeDeleted: Defines if result should include deleted posts, must have 'manage_system' (admin) permission.

Implementation

Future<MmPost?> getPost(
  String postId, {
  bool? includeDeleted,
}) async {
  final response = await getPostWithHttpInfo(
    postId,
    includeDeleted: includeDeleted,
  );
  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),
      'MmPost',
    ) as MmPost;
  }
  return null;
}