listFeedSubscriptions method

Future<List<FeedSubscription>> listFeedSubscriptions({
  1. required String projectId,
  2. required String feedId,
})

Implementation

Future<List<FeedSubscription>> listFeedSubscriptions({required String projectId, required String feedId}) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final encodedFeedId = Uri.encodeComponent(feedId);
  final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/feeds/$encodedFeedId/subscriptions');
  final response = await httpClient.get(uri);

  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to list feed subscriptions. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }

  final data = jsonDecode(response.body) as Map<String, dynamic>;
  final list = data['subscriptions'] as List<dynamic>? ?? [];
  return list.whereType<Map<String, dynamic>>().map(FeedSubscription.fromJson).toList();
}