getFeed method

Future<Feed> getFeed({
  1. required String projectId,
  2. required String feedId,
})

Implementation

Future<Feed> getFeed({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');
  final response = await httpClient.get(uri);

  if (response.statusCode == 404) {
    throw NotFoundException('Feed not found: $feedId');
  }

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

  final data = jsonDecode(response.body) as Map<String, dynamic>;
  return Feed.fromJson(data['feed'] as Map<String, dynamic>);
}