formAtKey method

AtKey? formAtKey(
  1. ATKEY_TYPE_ENUM keyType,
  2. String atkeyMicrosecondId,
  3. String? sharedWith,
  4. String sharedBy,
  5. EventNotificationModel eventData,
)

forms and returns an AtKey object based on the given keyType, atkeyMicrosecondId, sharedWith, sharedBy, and eventData

Implementation

AtKey? formAtKey(ATKEY_TYPE_ENUM keyType, String atkeyMicrosecondId,
    String? sharedWith, String sharedBy, EventNotificationModel eventData) {
  switch (keyType) {
    case ATKEY_TYPE_ENUM.CREATEEVENT:
      AtKey? atKey;

      // ignore: avoid_function_literals_in_foreach_calls
      allEventNotifications.forEach((event) {
        if (event.eventNotificationModel!.key == eventData.key) {
          atKey = EventService().getAtKey(event.eventNotificationModel!.key!);
        }
      });
      return atKey;

    case ATKEY_TYPE_ENUM.ACKNOWLEDGEEVENT:
      var key = AtKey()
        ..metadata = Metadata()
        ..metadata.ttr = -1
        ..metadata.ccd = true
        ..sharedWith = sharedWith
        ..sharedBy = sharedBy;

      key.key = 'eventacknowledged-$atkeyMicrosecondId';
      return key;
  }
}