putRoomKeys method
Store several keys in the backup.
version
The backup in which to store the keys. Must be the current backup.
backupData
The backup data.
Implementation
Future<RoomKeysUpdateResponse> putRoomKeys(
String version, RoomKeys backupData) async {
final requestUri =
Uri(path: '_api/client/v3/room_keys/keys', 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(backupData.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?>);
}