services:
    akeneo_connectivity.connection.webhook.guzzle_handler:
        class: GuzzleHttp\HandlerStack
        factory: ['GuzzleHttp\HandlerStack', 'create']

    akeneo_connectivity.connection.webhook.guzzle_client:
        class: GuzzleHttp\Client
        arguments:
            -
                handler: '@akeneo_connectivity.connection.webhook.guzzle_handler'
                headers: {User-Agent: ~}

    akeneo_connectivity.connection.webhook.serializer.json_encoder:
        class: Symfony\Component\Serializer\Encoder\JsonEncoder

    akeneo_connectivity.connection.webhook.webhook_client:
        class: Akeneo\Connectivity\Connection\Infrastructure\Webhook\Client\GuzzleWebhookClient
        arguments:
            - '@akeneo_connectivity.connection.webhook.guzzle_client'
            - '@akeneo_connectivity.connection.webhook.serializer.json_encoder'
            - '@akeneo_connectivity.connection.webhook.send_api_event_request_logger'
            - '@akeneo_connectivity.connection.webhook.events_api_debug_logger'
            - '@event_dispatcher'
            -
                concurrency: '%webhook_concurrency%'
                timeout: '%webhook_timeout%'

    akeneo_connectivity.connection.webhook.webhook_event_builder:
        class: Akeneo\Connectivity\Connection\Application\Webhook\WebhookEventBuilder
        arguments:
            - !tagged akeneo_connectivity.connection.webhook.event_data_builder
            - '@akeneo_connectivity.connection.webhook.events_api_debug_logger'

    akeneo_connectivity.connection.webhook.webhook_user_authenticator:
        class: Akeneo\Connectivity\Connection\Application\Webhook\WebhookUserAuthenticator
        arguments:
            - '@pim_user.repository.user'
            - '@security.token_storage'

    akeneo_connectivity.connection.webhook.events_api_debug_logger:
        class: Akeneo\Connectivity\Connection\Application\Webhook\Service\EventsApiDebugLogger
        arguments:
            - '@akeneo_connectivity.connection.persistence.repository.events_api_debug'
            - '@akeneo_connectivity.connection.clock'
            - !tagged akeneo_connectivity.connection.webhook.event_normalizer

    akeneo_connectivity.connection.webhook.reach_request_limit_logger:
        class: Akeneo\Connectivity\Connection\Application\Webhook\Service\Logger\ReachRequestLimitLogger
        arguments:
            - '@monolog.logger.event_api'

    akeneo_connectivity.connection.webhook.send_api_event_request_logger:
        class: Akeneo\Connectivity\Connection\Application\Webhook\Service\Logger\SendApiEventRequestLogger
        arguments:
            - '@monolog.logger.event_api'
