convertEventNotificationToJson static method

String convertEventNotificationToJson(
  1. EventNotificationModel eventNotification
)

converts an EventNotificationModel object to a JSON string representation

Implementation

static String convertEventNotificationToJson(
    EventNotificationModel eventNotification) {
  var notification = json.encode({
    'title': eventNotification.title != null
        ? eventNotification.title.toString()
        : '',
    'isCancelled': eventNotification.isCancelled.toString(),
    'isSharing': eventNotification.isSharing.toString(),
    'isUpdate': eventNotification.isUpdate.toString(),
    'atsignCreator': eventNotification.atsignCreator.toString(),
    'key': '${eventNotification.key}',
    'group': json.encode(eventNotification.group),
    'lat': eventNotification.lat.toString(),
    'long': eventNotification.long.toString(),

    /// Update ['group']['updatedAt'] with DateTime.now()
    'venue': json.encode({
      'latitude': eventNotification.venue!.latitude.toString(),
      'longitude': eventNotification.venue!.longitude.toString(),
      'label': eventNotification.venue!.label
    }),
    'event': json.encode({
      'isRecurring': eventNotification.event!.isRecurring.toString(),
      'date': eventNotification.event!.date.toString(),
      'endDate': eventNotification.event!.endDate.toString(),
      'startTime': eventNotification.event!.startTime?.toUtc().toString(),
      'endTime': eventNotification.event!.endTime?.toUtc().toString(),
      'repeatDuration': eventNotification.event!.repeatDuration.toString(),
      'repeatCycle': eventNotification.event!.repeatCycle.toString(),
      'occursOn': eventNotification.event!.occursOn.toString(),
      'endsOn': eventNotification.event!.endsOn.toString(),
      'endEventOnDate': eventNotification.event!.endEventOnDate.toString(),
      'endEventAfterOccurrence':
          eventNotification.event!.endEventAfterOccurance.toString()
    })
  });
  return notification;
}