getJoinedRooms method

Future<List<String>> getJoinedRooms()
inherited

This API returns a list of the user's current rooms.

returns joined_rooms: The ID of each room in which the user has joined membership.

Implementation

Future<List<String>> getJoinedRooms() async {
  final requestUri = Uri(path: '_api/client/v3/joined_rooms');
  final request = Request('GET', baseUri!.resolveUri(requestUri));
  request.headers['authorization'] = 'Bearer ${bearerToken!}';
  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['joined_rooms'] as List).map((v) => v as String).toList();
}