class QueuedMessage { final String id; final String topic; final Map payload; final DateTime createdAt; final int retryCount; QueuedMessage({ required this.id, required this.topic, required this.payload, required this.createdAt, this.retryCount = 0, }); factory QueuedMessage.fromJson(Map json) { return QueuedMessage( id: json['id'], topic: json['topic'], payload: Map.from(json['payload']), createdAt: DateTime.parse(json['createdAt']), retryCount: json['retryCount'] ?? 0, ); } Map toJson() { return { 'id': id, 'topic': topic, 'payload': payload, 'createdAt': createdAt.toIso8601String(), 'retryCount': retryCount, }; } QueuedMessage copyWith({ String? id, String? topic, Map? payload, DateTime? createdAt, int? retryCount, }) { return QueuedMessage( id: id ?? this.id, topic: topic ?? this.topic, payload: payload ?? this.payload, createdAt: createdAt ?? this.createdAt, retryCount: retryCount ?? this.retryCount, ); } }