createPost method

Future<MmPost?> createPost(
  1. MmCreatePostRequest mmCreatePostRequest, {
  2. bool? setOnline,
})

Create a post

Create a new post in a channel. To create the post as a comment on another post, provide root_id. ##### Permissions Must have create_post permission for the channel the post is being created in.

Parameters:

  • MmCreatePostRequest mmCreatePostRequest (required): Post object to create

  • bool setOnline: Whether to set the user status as online or not.

Implementation

Future<MmPost?> createPost(
  MmCreatePostRequest mmCreatePostRequest, {
  bool? setOnline,
}) async {
  final response = await createPostWithHttpInfo(
    mmCreatePostRequest,
    setOnline: setOnline,
  );
  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;
}