getPushRule method

Future<PushRule> getPushRule(
  1. String scope,
  2. PushRuleKind kind,
  3. String ruleId
)
inherited

Retrieve a single specified push rule.

scope global to specify global rules.

kind The kind of rule

ruleId The identifier for the rule.

Implementation

Future<PushRule> getPushRule(
    String scope, PushRuleKind kind, String ruleId) async {
  final requestUri = Uri(
      path:
          '_matrix/client/v3/pushrules/${Uri.encodeComponent(scope)}/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}');
  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 PushRule.fromJson(json as Map<String, Object?>);
}