getPushers method

Future<List<Pusher>?> getPushers()
inherited

Gets all currently active pushers for the authenticated user.

returns pushers: An array containing the current pushers for the user

Implementation

Future<List<Pusher>?> getPushers() async {
  final requestUri = Uri(path: '_api/client/v3/pushers');
  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 ((v) => v != null
      ? (v as List)
          .map((v) => Pusher.fromJson(v as Map<String, Object?>))
          .toList()
      : null)(json['pushers']);
}