getReactionsByTarget method

Future<List<ReactionBody>> getReactionsByTarget(
  1. String targetUrl,
  2. ReactionType? reactionType,
  3. int? pageSize,
  4. String? pageToken,
  5. bool? reverse,
)

Implementation

Future<List<ReactionBody>> getReactionsByTarget(
  String targetUrl,
  ReactionType? reactionType,
  int? pageSize,
  String? pageToken,
  bool? reverse,
) async {
  ReactionsByTargetRequest request = ReactionsByTargetRequest();
  request.targetUrl = targetUrl;
  if (reactionType != null) {
    request.reactionType = reactionType;
  }
  request.pageSize = pageSize ?? 0;
  if (pageToken != null) {
    request.pageToken = utf8.encode(pageToken);
  }
  request.reverse = reverse ?? false;

  MessagesResponse response =
      await _hubService.hubClient.getReactionsByTarget(request);

  return response.messages.map((e) => e.data.reactionBody).toList();
}