getNotifications method

Future<PaginatedResponse<Notification>> getNotifications({
  1. List<String>? channels,
  2. List<String>? emails,
  3. List<String>? subscriberIds,
  4. String? search,
  5. int page = 0,
  6. int limit = 10,
  7. String? transactionId,
})

Implementation

Future<PaginatedResponse<Notification>> getNotifications({
  List<String>? channels,
  List<String>? emails,
  List<String>? subscriberIds,
  String? search,
  int page = 0,
  int limit = 10,
  String? transactionId,
}) async {
  Map<String, dynamic> response = await request(
    method: ApiMethod.GET,
    endpoint: 'notifications',
    query: {
      if (channels != null) 'channels': channels.join(','),
      if (emails != null) 'emails': emails.join(','),
      if (subscriberIds != null) 'subscriberIds': subscriberIds.join(','),
      if (search != null) 'search': search,
      'page': page,
      'limit': limit,
      if (transactionId != null) 'transactionId': transactionId,
    }
  );
  return PaginatedResponse<Notification>(
    page: response['page'],
    totalCount: response['totalCount'],
    pageSize: response['pageSize'],
    hasMore: response['hasMore'],
    data: response['data'].map<Notification>((var r) => Notification.fromJson(r)).toList(),
  );
}