putRoomKeysVersion method

Future<Map<String, Object?>> putRoomKeysVersion(
  1. String version,
  2. BackupAlgorithm algorithm,
  3. Map<String, Object?> authData
)
inherited

Update information about an existing backup. Only auth_data can be modified.

version The backup version to update, as returned in the version parameter in the response of POST /_api/client/v3/room_keys/version or GET /_api/client/v3/room_keys/version/{version}.

algorithm The algorithm used for storing backups. Must be the same as the algorithm currently used by the backup.

authData Algorithm-dependent data. See the documentation for the backup algorithms in Server-side key backups for more information on the expected format of the data.

Implementation

Future<Map<String, Object?>> putRoomKeysVersion(String version,
    BackupAlgorithm algorithm, Map<String, Object?> authData) async {
  final requestUri = Uri(
      path:
          '_api/client/v3/room_keys/version/${Uri.encodeComponent(version)}');
  final request = Request('PUT', baseUri!.resolveUri(requestUri));
  request.headers['authorization'] = 'Bearer ${bearerToken!}';
  request.headers['content-type'] = 'application/json';
  request.bodyBytes = utf8.encode(jsonEncode({
    'algorithm': algorithm.name,
    'auth_data': authData,
  }));
  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 json as Map<String, Object?>;
}