getPushRuleActions method

Future<List<Object?>> getPushRuleActions(
  1. String scope,
  2. PushRuleKind kind,
  3. String ruleId
)
inherited

This endpoint get the actions for the specified push rule.

scope Either global or device/<profile_tag> to specify global rules or device rules for the given profile_tag.

kind The kind of rule

ruleId The identifier for the rule.

returns actions: The action(s) to perform for this rule.

Implementation

Future<List<Object?>> getPushRuleActions(
    String scope, PushRuleKind kind, String ruleId) async {
  final requestUri = Uri(
      path:
          '_api/client/v3/pushrules/${Uri.encodeComponent(scope)}/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}/actions');
  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['actions'] as List).map((v) => v as Object?).toList();
}