getProtocols method

Future<Map<String, Protocol>> getProtocols()

Fetches the overall metadata about protocols supported by the homeserver. Includes both the available protocols and all fields required for queries against each protocol.

Implementation

Future<Map<String, Protocol>> getProtocols() async {
  final requestUri = Uri(path: '_matrix/client/v3/thirdparty/protocols');
  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 as Map<String, Object?>).map(
    (k, v) => MapEntry(k, Protocol.fromJson(v as Map<String, Object?>)),
  );
}