getNotifications method

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

Implementation

Future<PaginatedResponse<InboxNotification>> getNotifications({
  bool archived = false,
  int page = 0,
  int limit = 10,
  List<String>? tags,
}) async {
  Map<String, dynamic> response = await request(
    method: ApiMethod.GET,
    endpoint: 'inbox/notifications',
    query: {
      'offset': page * limit,
      'limit': limit,
      'archived': archived,
      if (tags?.isNotEmpty == true) 'tags': tags!.join(','),
    }
  );
  return PaginatedResponse<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(),
  );
}