getNotifications method

Future<PaginatedResponse<InboxNotification>> getNotifications({
  1. bool archived = false,
  2. bool? read,
  3. int page = 0,
  4. int limit = 10,
  5. List<String> tags = const [],
})

Implementation

Future<Dot.PaginatedResponse<InboxNotification>> getNotifications({
  bool archived = false,
  bool? read,
  int page = 0,
  int limit = 10,
  List<String> tags = const [],
}) async {
  var response = (await _client.get<Map<String, dynamic>>(
      'notifications',
      queryParameters: {
        'offset': page * limit,
        'limit': limit,
        'archived': archived,
        if (read != null) 'read': read,
        if (tags.isNotEmpty == true) 'tags[]': tags,
      }
  )).data!;
  return Dot.PaginatedResponse<Dot.InboxNotification>(
    page: response['page'] ?? page,
    totalCount: response['totalCount'] ?? 0,
    pageSize: limit,
    hasMore: response['hasMore'],
    data: response['data'].map<InboxNotification>((var r) => InboxNotification.fromJson(r)).toList(),
  );
}