dtoToAppNotification function
Implementation
AppNotification? dtoToAppNotification(NotificationDTO notification) {
final message = notification.message;
final deviceId = notification.deviceId;
if (message == null) {
if (kDebugMode) {
print('**WARNING** - Unsupported API message: $notification');
}
return null;
}
return AppNotification(
id: notification.id ?? notification.hashCode,
type: switch (notification.type) {
NotificationTypeDTO.shutdown => AppNotificationType.shutdown,
NotificationTypeDTO.warning => AppNotificationType.warning,
NotificationTypeDTO.maintenancenotice =>
AppNotificationType.maintenanceNotice,
NotificationTypeDTO.longrunningnotice =>
AppNotificationType.longRunningNotice,
NotificationTypeDTO.enginestartednotice =>
AppNotificationType.engineStartedNotice,
NotificationTypeDTO.enginestoppednotice =>
AppNotificationType.engineStoppedNotice,
NotificationTypeDTO.exercisestartednotice =>
AppNotificationType.exerciseStartedNotice,
NotificationTypeDTO.exerciseendednotice =>
AppNotificationType.exerciseEndedNotice,
NotificationTypeDTO.onlinenotice => AppNotificationType.onlineNotice,
NotificationTypeDTO.offlinenotice => AppNotificationType.offlineNotice,
NotificationTypeDTO.notice => AppNotificationType.notice,
NotificationTypeDTO.swaggerGeneratedUnknown => AppNotificationType.notice,
null => AppNotificationType.notice
},
showSystemNotification: true,
action: deviceId != null ? NavToDeviceAction.id(deviceId) : null,
message: message,
timestamp: notification.timestamp,
deviceId: deviceId,
displayName: notification.displayName,
serialNumber: notification.serialNumber,
);
}