filter method

Future<List<Reaction>> filter(
  1. LookupAttribute lookupAttr,
  2. String lookupValue, {
  3. Filter? filter,
  4. EnrichmentFlags? flags,
  5. int? limit,
  6. String? kind,
})

You can read reactions and filter them based on their user_id or activity_id values. Further filtering can be done with the kind parameter (e.g. retrieve all likes by one user, retrieve all comments for one activity, etc.).

Reactions are returned in descending order (newest to oldest) by default and when using id_lte , and in ascending order (oldest to newest) when using id_gte.

Examples

  • retrieve all kind of reactions for an activity
var reactions = await client.reactions.filter(
  LookupAttribute.activityId,
  'ed2837a6-0a3b-4679-adc1-778a1704852d',
);

Note: passing both id_lteandid_gte is not supported.

Note: when using id_lte the reactions are ordered by the created_at field, in descending order.

Note: when using id_gte the reactions are ordered by the created_at field, in ascending order.

Implementation

Future<List<Reaction>> filter(
  LookupAttribute lookupAttr,
  String lookupValue, {
  //TODO: check if it is a valid UUID with package uuid isValidUUID
  Filter? filter,
  EnrichmentFlags? flags,
  int? limit,
  String? kind,
}) {
  final token =
      userToken ?? TokenHelper.buildReactionToken(secret!, TokenAction.read);
  final options = {
    'limit': limit ?? Default.limit,
    ...filter?.params ?? Default.filter.params,
    if (flags != null) ...flags.params,
    'with_activity_data': lookupAttr == LookupAttribute.activityId,
  };
  return _reactions.filter(
    token,
    lookupAttr,
    lookupValue,
    filter ?? Default.filter,
    limit ?? Default.limit,
    kind ?? '',
    options,
  );
}