getDiscussionsBy method

Future<List<DiscussionBy>> getDiscussionsBy(
  1. DiscussionBySort sort, {
  2. required String tag,
  3. int? limit,
  4. List<String>? filterTags,
  5. List<String>? selectAuthors,
  6. List<String>? selectTags,
  7. int? truncateBody,
})

Return a discussion with the given parameters. Throws a NotFoundFailure if a post could not be found.

Implementation

Future<List<DiscussionBy>> getDiscussionsBy(
  DiscussionBySort sort, {
  required String tag,
  int? limit,
  List<String>? filterTags,
  List<String>? selectAuthors,
  List<String>? selectTags,
  int? truncateBody,
}) async {
  final params = _buildParamsObj(<String, dynamic>{
    'tag': tag,
    'limit': limit,
    'filter_tags': filterTags,
    'select_authors': selectAuthors,
    'select_tags': selectTags
  });

  final bodyJson = await _fetchPostData(
    method: 'condenser_api.get_discussions_by_${sort.name}',
    params: [params],
  );

  final list = bodyJson['result'] as List<dynamic>;

  return [
    for (final f in list) DiscussionBy.fromJson(f as Map<String, dynamic>),
  ];
}