getPushRules method

Future<PushRuleSet> getPushRules()
inherited

Retrieve all push rulesets for this user. Clients can "drill-down" on the rulesets by suffixing a scope to this path e.g. /pushrules/global/. This will return a subset of this data under the specified key e.g. the global key.

returns global: The global ruleset.

Implementation

Future<PushRuleSet> getPushRules() async {
  final requestUri = Uri(path: '_api/client/v3/pushrules/');
  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 PushRuleSet.fromJson(json['global'] as Map<String, Object?>);
}