setPushRuleEnabled method
This endpoint allows clients to enable or disable the specified push rule.
kind
The kind of rule
ruleId
The identifier for the rule.
enabled
Whether the push rule is enabled or not.
Implementation
Future<void> setPushRuleEnabled(
PushRuleKind kind,
String ruleId,
bool enabled,
) async {
final requestUri = Uri(
path:
'_matrix/client/v3/pushrules/global/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}/enabled',
);
final request = Request('PUT', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}';
request.headers['content-type'] = 'application/json';
request.bodyBytes = utf8.encode(
jsonEncode({
'enabled': enabled,
}),
);
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 ignore(json);
}