toJson method

  1. @override
Map<String, dynamic> toJson()
override

Implementation

@override
Map<String, dynamic> toJson() {
  Map<String, dynamic> result = {
    ...super.toJson(),
    'notification_type': notificationType,
    'environment': environment,
    'message': message
  };

  if (!isEmpty(eventType)) result['event_type'] = eventType;
  if (!isEmpty(name)) result['name'] = name;
  if (date != null) result['date'] = date;
  if (endDate != null) result['end_date'] = endDate;
  if (period != null) result['period'] = period;

  if (eventUser != null && eventUser!.toJson().isNotEmpty) {
    result['user'] = eventUser;
  }

  if (externalUser != null && externalUser!.toJson().isNotEmpty) {
    result['external_user'] = externalUser;
  }

  if (!isEmpty(notificationChannel)) {
    result['notification_channel'] = notificationChannel;
  }
  if (userId != null) result['user_id'] = userId;

  return result;
}