52 lines
1.2 KiB
Dart
52 lines
1.2 KiB
Dart
class QueuedMessage {
|
|
final String id;
|
|
final String topic;
|
|
final Map<String, dynamic> 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<String, dynamic> json) {
|
|
return QueuedMessage(
|
|
id: json['id'],
|
|
topic: json['topic'],
|
|
payload: Map<String, dynamic>.from(json['payload']),
|
|
createdAt: DateTime.parse(json['createdAt']),
|
|
retryCount: json['retryCount'] ?? 0,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'topic': topic,
|
|
'payload': payload,
|
|
'createdAt': createdAt.toIso8601String(),
|
|
'retryCount': retryCount,
|
|
};
|
|
}
|
|
|
|
QueuedMessage copyWith({
|
|
String? id,
|
|
String? topic,
|
|
Map<String, dynamic>? 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,
|
|
);
|
|
}
|
|
}
|