upgradeRoom method
Upgrades the given room to a particular room version.
roomId
The ID of the room to upgrade.
newVersion
The new version for the room.
returns replacement_room
:
The ID of the new room.
Implementation
Future<String> upgradeRoom(String roomId, String newVersion) async {
final requestUri = Uri(
path: '_api/client/v3/rooms/${Uri.encodeComponent(roomId)}/upgrade');
final request = Request('POST', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}';
request.headers['content-type'] = 'application/json';
request.bodyBytes = utf8.encode(jsonEncode({
'new_version': newVersion,
}));
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['replacement_room'] as String;
}