famedlysdk/lib/matrix_api/model/room_keys_keys.dart

102 lines
2.8 KiB
Dart
Raw Normal View History

2020-06-12 14:17:00 +00:00
/*
* Famedly Matrix SDK
* Copyright (C) 2020 Famedly GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
class RoomKeysSingleKey {
int firstMessageIndex;
int forwardedCount;
bool isVerified;
Map<String, dynamic> sessionData;
2020-08-17 12:25:48 +00:00
RoomKeysSingleKey(
{this.firstMessageIndex,
this.forwardedCount,
this.isVerified,
this.sessionData});
2020-06-12 14:17:00 +00:00
RoomKeysSingleKey.fromJson(Map<String, dynamic> json) {
firstMessageIndex = json['first_message_index'];
forwardedCount = json['forwarded_count'];
isVerified = json['is_verified'];
sessionData = json['session_data'];
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['first_message_index'] = firstMessageIndex;
data['forwarded_count'] = forwardedCount;
data['is_verified'] = isVerified;
data['session_data'] = sessionData;
return data;
}
}
class RoomKeysRoom {
Map<String, RoomKeysSingleKey> sessions;
2020-08-17 12:25:48 +00:00
RoomKeysRoom({this.sessions}) {
sessions ??= <String, RoomKeysSingleKey>{};
}
2020-06-12 14:17:00 +00:00
RoomKeysRoom.fromJson(Map<String, dynamic> json) {
2020-06-12 14:17:28 +00:00
sessions = (json['sessions'] as Map)
.map((k, v) => MapEntry(k, RoomKeysSingleKey.fromJson(v)));
2020-06-12 14:17:00 +00:00
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['sessions'] = sessions.map((k, v) => MapEntry(k, v.toJson()));
return data;
}
}
class RoomKeys {
Map<String, RoomKeysRoom> rooms;
2020-08-17 12:25:48 +00:00
RoomKeys({this.rooms}) {
rooms ??= <String, RoomKeysRoom>{};
}
2020-06-12 14:17:00 +00:00
RoomKeys.fromJson(Map<String, dynamic> json) {
2020-06-12 14:17:28 +00:00
rooms = (json['rooms'] as Map)
.map((k, v) => MapEntry(k, RoomKeysRoom.fromJson(v)));
2020-06-12 14:17:00 +00:00
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['rooms'] = rooms.map((k, v) => MapEntry(k, v.toJson()));
return data;
}
}
class RoomKeysUpdateResponse {
String etag;
int count;
RoomKeysUpdateResponse.fromJson(Map<String, dynamic> json) {
etag = json['etag']; // synapse replies an int but docs say string?
count = json['count'];
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['etag'] = etag;
data['count'] = count;
return data;
}
}