listWebhooks method

Future<List<Map<String, dynamic>>> listWebhooks(
  1. String projectId
)

Implementation

Future<List<Map<String, dynamic>>> listWebhooks(String projectId) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/webhooks');
  final response = await httpClient.get(uri);

  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to list project webhooks. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }
  final data = jsonDecode(response.body) as Map<String, dynamic>;
  final list = data['webhooks'] as List<dynamic>? ?? [];
  return list.whereType<Map>().map((m) => m.cast<String, dynamic>()).toList();
}