updateWebhook method
Corresponds to: PUT /accounts/projects/{project_id}/webhooks/{webhook_id} Body: { "name", "description", "url", "events" } Returns the updated resource JSON or an empty object (depends on your server).
Implementation
Future<Map<String, dynamic>> updateWebhook(
String projectId,
String webhookId, {
required String name,
required String url,
required List<String> events,
String description = '',
String? action,
String? payload,
}) async {
final uri = Uri.parse('$baseUrl/accounts/projects/$projectId/webhooks/$webhookId');
final body = {'name': name, 'description': description, 'url': url, 'events': events, 'payload': payload, 'action': action};
final response = await http.put(uri, headers: _getHeaders(), body: jsonEncode(body));
if (response.statusCode >= 400) {
throw MeshagentException(
'Failed to update project webhook. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
return jsonDecode(response.body) as Map<String, dynamic>;
}