54 lines
1.5 KiB
Dart
54 lines
1.5 KiB
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
import 'package:marianum_mobile/api/apiResponse.dart';
|
|
import 'package:marianum_mobile/api/marianumcloud/talk/room/getRoomResponse.dart';
|
|
|
|
part 'getChatResponse.g.dart';
|
|
|
|
@JsonSerializable(explicitToJson: true)
|
|
class GetChatResponse extends ApiResponse {
|
|
Set<GetChatResponseObject> data;
|
|
|
|
GetChatResponse(this.data);
|
|
|
|
factory GetChatResponse.fromJson(Map<String, dynamic> json) => _$GetChatResponseFromJson(json);
|
|
Map<String, dynamic> toJson() => _$GetChatResponseToJson(this);
|
|
|
|
List<GetChatResponseObject> sortByTimestamp() {
|
|
List<GetChatResponseObject> sorted = data.toList();
|
|
sorted.sort((a, b) => a.timestamp.compareTo(b.timestamp));
|
|
return sorted;
|
|
}
|
|
}
|
|
|
|
@JsonSerializable(explicitToJson: true)
|
|
class GetChatResponseObject {
|
|
int id;
|
|
String token;
|
|
GetRoomResponseObjectMessageActorType actorType;
|
|
String actorId;
|
|
String actorDisplayName;
|
|
int timestamp;
|
|
String systemMessage;
|
|
GetRoomResponseObjectMessageType messageType;
|
|
bool isReplyable;
|
|
String referenceId;
|
|
String message;
|
|
|
|
GetChatResponseObject(
|
|
this.id,
|
|
this.token,
|
|
this.actorType,
|
|
this.actorId,
|
|
this.actorDisplayName,
|
|
this.timestamp,
|
|
this.systemMessage,
|
|
this.messageType,
|
|
this.isReplyable,
|
|
this.referenceId,
|
|
this.message);
|
|
|
|
factory GetChatResponseObject.fromJson(Map<String, dynamic> json) => _$GetChatResponseObjectFromJson(json);
|
|
Map<String, dynamic> toJson() => _$GetChatResponseObjectToJson(this);
|
|
}
|
|
|