deegitalbe / laravel-trustup-io-messaging-webhooks-listeners
Our package used to listen to messaging webhooks
v1.1.3
2023-02-24 16:59 UTC
Requires
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.5
README
Prerequisite
This package uses deegitalbe/server-authorization
package to authenticate requests. Refer to its documentation to make sure it's correctly configured on your project.
Installation
composer require deegitalbe/laravel-trustup-io-messaging-webhooks-listeners
Publish configuration
php artisan vendor:publish --provider="Deegitalbe\LaravelTrustupIoMessagingWebhooksListeners\Providers\LaravelTrustupIoMessagingWebhooksListenersServiceProvider" --tag="config"
Available listeners
Message created
Define your listener
use Deegitalbe\LaravelTrustupIoMessagingWebhooksListeners\Contracts\Listeners\Messages\TrustupIoMessagingMessageCreatedListenerContract; class MessageCreatedListener implements TrustupIoMessagingMessageCreatedListenerContract { public function onMessageCreated(array $webhookData): void { } }
Register your listener in config
/** * Messaging microservice listeners. */ "listeners" => [ /** * Message related listeners. */ "messages" => [ /** * Message created listener. * * @implements \Deegitalbe\LaravelTrustupIoMessagingWebhooksListeners\Contracts\Listeners\Messages\TrustupIoMessagingMessageCreatedListenerContract */ "created" => MessageCreatedListener::class ] ]
Webhook data structure
{ "message": { "id": 4339, "type": "text", "text": "The order of the message is not really good", "status": null, "user_id": 38943, "conversation_id": 2767, "conversation": { "id": 2767, "app_name": "trustup-io-ticketing", "type": "conversation", "title": "null", "model": "ticket", "model_id": "840942e5-b63e-4ab5-8f72-079e7a35be0e", "user_id": 38943, "meta": null, "deleted_at": null, "created_at": "2023-02-23T15:59:08.000000Z", "updated_at": "2023-02-23T15:59:08.000000Z" }, "seen_by": [], "deleted_at": null, "created_at": "2023-02-24T14:54:37.000000Z", "updated_at": "2023-02-24T14:54:37.000000Z" } }
Listener configuration
Add any of those interfaces to your listener to customize it.
Limit to your current app only
use Deegitalbe\LaravelTrustupIoMessagingWebhooksListeners\Contracts\Listeners\Config\ListenToCorrespondingAppKey; class MessageCreatedListener implements ListenToCorrespondingAppKey