bitbirddev / trustkey-webhook-bundle
Installs: 392
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- symfony/config: ^6.0|^7.0
- symfony/dependency-injection: ^6.0|^7.0
- symfony/http-foundation: ^6.0|^7.0
- symfony/remote-event: ^6.0|^7.0
- symfony/webhook: ^6.0|^7.0
README
composer require bitbirddev/trustkey-webhook-bundle
Add configuration
config/packages/trustkey_webhooks.yaml
framework: webhook: routing: trustkey: service: "bitbirddev.webhook.request_parser.trustkey" secret: "YourTrustkeyWebhookSecret" # secret: "%env(TRUSTKEY_WEBHOOK_SECRET)%" # or use environment variable
Example Consumer
src/Webhooks/Consumer/TrustkeyWebhookConsumer.php
<?php namespace App\Webhooks\Consumer; /* * In case Messages are delivered Async * make sure bin/console messenger:consume async is running */ use bitbirddev\TrustkeyWebhookBundle\Events\ActionPackEvent; use bitbirddev\TrustkeyWebhookBundle\Events\ComponentEvent; use bitbirddev\TrustkeyWebhookBundle\Events\ResourceEvent; use bitbirddev\TrustkeyWebhookBundle\Events\SectionEvent; use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer; use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface; use Symfony\Component\RemoteEvent\Exception\LogicException; use Symfony\Component\RemoteEvent\RemoteEvent; #[AsRemoteEventConsumer('trustkey')] class TrustkeyWebhookConsumer implements ConsumerInterface { public function consume(RemoteEvent $event): void { match ($event->getName()) { // Resources ResourceEvent::CREATED => $this->handle($event), ResourceEvent::UPDATED => $this->handle($event), ResourceEvent::ARCHIVED => $this->handle($event), // ActionPacks ActionPackEvent::LAUNCHED => $this->handle($event), ActionPackEvent::COMPLETE => $this->handle($event), ActionPackEvent::REOPEN => $this->handle($event), // Components ComponentEvent::PROGRESS_DONE => $this->handle($event), ComponentEvent::PROGRESS_REOPEN => $this->handle($event), // Sections SectionEvent::PROGRESS_DONE => $this->handle($event), SectionEvent::PROGRESS_REOPEN => $this->handle($event), default => throw new LogicException('Unhandled TrustkeyEvent: '.$event->getName()) }; } protected function handle(RemoteEvent $event): void { dd($event); } }
Example Json Payload
To test your Webhook you can use the following json payload. Send the payload via POST to https://yourdomain/webhook/trustkey
{ "event": "SECTION_PROGRESS_REOPEN", "webhook": "https://test.x.pipedream.net", "sectionSeriesId": "C-33", "completed": false, "id": "A-14538", "url": "https://test.trustkey.eu/view/board/actionpack/A-15266" }