getNotifications method
This API is used to paginate through the list of events that the user has been, or would have been notified about.
from
Pagination token to continue from. This should be the next_token
returned from an earlier call to this endpoint.
limit
Limit on the number of events to return in this request.
only
Allows basic filtering of events returned. Supply highlight
to return only events where the notification had the highlight
tweak set.
Implementation
Future<GetNotificationsResponse> getNotifications(
{String? from, int? limit, String? only}) async {
final requestUri =
Uri(path: '_api/client/v3/notifications', queryParameters: {
if (from != null) 'from': from,
if (limit != null) 'limit': limit.toString(),
if (only != null) 'only': only,
});
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 GetNotificationsResponse.fromJson(json as Map<String, Object?>);
}