setPushRuleActions method
Future<void>
setPushRuleActions(
- String scope,
- PushRuleKind kind,
- String ruleId,
- List<
Object?> actions,
inherited
This endpoint allows clients to change the actions of a push rule. This can be used to change the actions of builtin rules.
scope
global
to specify global rules.
kind
The kind of rule
ruleId
The identifier for the rule.
actions
The action(s) to perform for this rule.
Implementation
Future<void> setPushRuleActions(String scope, PushRuleKind kind,
String ruleId, List<Object?> actions) async {
final requestUri = Uri(
path:
'_api/client/v3/pushrules/${Uri.encodeComponent(scope)}/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}/actions');
final request = Request('PUT', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}';
request.headers['content-type'] = 'application/json';
request.bodyBytes = utf8.encode(jsonEncode({
'actions': actions.map((v) => v).toList(),
}));
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);
}