getPostsForChannel method

Future<MmPostList?> getPostsForChannel(
  1. String channelId, {
  2. int? page,
  3. int? perPage,
  4. int? since,
  5. String? before,
  6. String? after,
})

Get posts for a channel

Get a page of posts in a channel. Use the query parameters to modify the behaviour of this endpoint. The parameter since must not be used with any of before, after, page, and per_page parameters. If since is used, it will always return all posts modified since that time, ordered by their create time limited till 1000. A caveat with this parameter is that there is no guarantee that the returned posts will be consecutive. It is left to the clients to maintain state and fill any missing holes in the post order. ##### Permissions Must have read_channel permission for the channel.

Parameters:

  • String channelId (required): The channel ID to get the posts for

  • int page: The page to select

  • int perPage: The number of posts per page

  • int since: Provide a non-zero value in Unix time milliseconds to select posts modified after that time

  • String before: A post id to select the posts that came before this one

  • String after: A post id to select the posts that came after this one

Implementation

Future<MmPostList?> getPostsForChannel(
  String channelId, {
  int? page,
  int? perPage,
  int? since,
  String? before,
  String? after,
}) async {
  final response = await getPostsForChannelWithHttpInfo(
    channelId,
    page: page,
    perPage: perPage,
    since: since,
    before: before,
    after: after,
  );
  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),
      'MmPostList',
    ) as MmPostList;
  }
  return null;
}