create method
Future<WebhookEntity>
create({
- required String targetUrl,
- required WebhookEvent event,
- bool? isActive,
- String? signingSecret,
- String? version,
Create and subscribe to a webhook. You can use webhooks to receive notifications about your uploads. For instance, once a file gets uploaded to your project, we can notify you by sending a message to a target URL
Implementation
Future<WebhookEntity> create({
required String targetUrl,
required WebhookEvent event,
bool? isActive,
String? signingSecret,
String? version,
}) async {
_ensureRightVersionForWebhooks();
final request = createMultipartRequest(
'POST',
buildUri('$apiUrl/webhooks/'),
)..fields.addAll({
'target_url': targetUrl,
'event': event.toString(),
if (isActive != null) 'is_active': isActive.toString(),
if (signingSecret != null) 'signing_secret': signingSecret,
if (version != null) 'version': version,
});
final response = await resolveStreamedResponse(request.send());
return WebhookEntity.fromJson(response as Map<String, dynamic>);
}