putRoomKeysByRoomId method
Future<RoomKeysUpdateResponse>
putRoomKeysByRoomId(
- String roomId,
- String version,
- RoomKeyBackup body
Store several keys in the backup for a given room.
roomId
The ID of the room that the keys are for.
version
The backup in which to store the keys. Must be the current backup.
body
The backup data
Implementation
Future<RoomKeysUpdateResponse> putRoomKeysByRoomId(
String roomId,
String version,
RoomKeyBackup body,
) async {
final requestUri = Uri(
path: '_matrix/client/v3/room_keys/keys/${Uri.encodeComponent(roomId)}',
queryParameters: {
'version': version,
},
);
final request = Request('PUT', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}';
request.headers['content-type'] = 'application/json';
request.bodyBytes = utf8.encode(jsonEncode(body.toJson()));
final response = await httpClient.send(request);
final responseBody = await response.stream.toBytes();
if (response.statusCode != 200) unexpectedResponse(response, responseBody);
final responseString = utf8.decode(responseBody);
final json = jsonDecode(responseString);
return RoomKeysUpdateResponse.fromJson(json as Map<String, Object?>);
}