getEnrichedActivities<A, Ob, T, Or> method

Future<List<GenericEnrichedActivity<A, Ob, T, Or>>> getEnrichedActivities<A, Ob, T, Or>({
  1. int? limit,
  2. int? offset,
  3. String? session,
  4. Filter? filter,
  5. EnrichmentFlags? flags,
  6. String? ranking,
})

Retrieve activities with reaction enrichment

Examples

  • read bob's timeline and include most recent reactions to all activities and their total count
await client.flatFeed('timeline', 'bob').getEnrichedActivities(
  flags: EnrichmentFlags().withRecentReactions().withReactionCounts(),
);
  • read bob's timeline and include most recent reactions to all activities and her own reactions
await client.flatFeed('timeline', 'bob').getEnrichedActivities(
  flags: EnrichmentFlags()
    .withOwnReactions()
    .withRecentReactions()
    .withReactionCounts(),
);

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<GenericEnrichedActivity<A, Ob, T, Or>>>
    getEnrichedActivities<A, Ob, T, Or>({
  int? limit,
  int? offset,
  String? session,
  Filter? filter,
  EnrichmentFlags? flags,
  String? ranking, //TODO: no way to parameterized marker?
}) async {
  final options = {
    'limit': limit ?? Default.limit,
    'offset': offset ?? Default.offset, //TODO:add session everywhere
    ...filter?.params ?? Default.filter.params,
    ...Default.marker.params,
    if (flags != null) ...flags.params,
    if (ranking != null) 'ranking': ranking,
    if (session != null) 'session': session,
  };
  final token = userToken ??
      TokenHelper.buildFeedToken(secret!, TokenAction.read, feedId);
  final result = await feed.getEnrichedActivities(token, feedId, options);
  final data = (result.data['results'] as List)
      .map((e) => GenericEnrichedActivity<A, Ob, T, Or>.fromJson(e))
      .toList(growable: false);
  return data;
}