getNotifications method

Future<List<UserNotificationVO>> getNotifications({
  1. int limit = 50,
  2. DocumentSnapshot<Object?>? startAt,
  3. String? orderBy,
  4. bool descending = false,
  5. required String userId,
})

Implementation

Future<List<UserNotificationVO>> getNotifications({
  int limit = 50,
  DocumentSnapshot? startAt,
  String? orderBy,
  bool descending = false,
  required String userId,
}) async {
  try {
    final models = await _userNotificationsDataService.getNotifications(
      limit: limit,
      startAt: startAt,
      userId: userId,
      orderBy: orderBy,
      descending: descending,
    );
    final vos = models.map((e) {
      final vo = UserNotificationVO.fromModel(e);
      return vo;
    }).toList();

    return vos;
  } catch (e) {
    if (e is RdevException) {
      throw UserNotificationsServiceException(
          code: e.code, message: e.message, stackTrace: e.stackTrace);
    }
    throw UserNotificationsServiceException(message: e.toString());
  }
}