Webhook::is_webhook_exist()
Summary
Check by destination and scope if webhook is already added to BigCommerce.
Description
Returns the id of the webhook
Return
(mixed|null)
Source
File: src/BigCommerce/Webhooks/Webhook.php
public function is_webhook_exist() { $webhooks = $this->api_client->listWebhooks(); $scope = $this->scope(); $destination = $this->destination(); $found_hooks = array_map(function ( $hook ) use ( $scope, $destination ) { $exists = $hook->scope === $scope && $hook->destination === $destination; $is_active = $hook->is_active === true; return $exists && $is_active ? $hook->id : false; }, $webhooks ); if ( empty( $found_hooks ) ) { return null; } // Filter out empty values $filtered_result = array_filter( $found_hooks ); return array_pop( $filtered_result ); }