services:
    akeneo_connectivity.connection.application.handler.create_connection:
        class: 'Akeneo\Connectivity\Connection\Application\Settings\Command\CreateConnectionHandler'
        public: true
        arguments:
            - '@validator'
            - '@akeneo_connectivity.connection.persistence.repository.connection'
            - '@akeneo_connectivity.connection.service.client.create_client'
            - '@akeneo_connectivity.connection.service.user.create_user'
            - '@akeneo_connectivity.connection.application.handler.find_a_connection'

    akeneo_connectivity.connection.application.handler.fetch_connections:
        class: 'Akeneo\Connectivity\Connection\Application\Settings\Query\FetchConnectionsHandler'
        arguments:
            - '@akeneo_connectivity.connection.persistence.query.select_connections'

    akeneo_connectivity.connection.application.handler.find_a_connection:
        class: 'Akeneo\Connectivity\Connection\Application\Settings\Query\FindAConnectionHandler'
        arguments:
            - '@akeneo_connectivity.connection.persistence.query.select_connection_with_credentials_by_code'

    akeneo_connectivity.connection.application.handler.update_connection:
        class: 'Akeneo\Connectivity\Connection\Application\Settings\Command\UpdateConnectionHandler'
        arguments:
            - '@validator'
            - '@akeneo_connectivity.connection.persistence.repository.connection'
            - '@akeneo_connectivity.connection.service.user.update_user_permissions'

    akeneo_connectivity.connection.application.handler.delete_connection:
        class: 'Akeneo\Connectivity\Connection\Application\Settings\Command\DeleteConnectionHandler'
        arguments:
            - '@akeneo_connectivity.connection.persistence.repository.connection'
            - '@akeneo_connectivity.connection.service.client.delete_client'
            - '@akeneo_connectivity.connection.service.user.delete_user'

    akeneo_connectivity.connection.application.handler.regenerate_connection_secret:
        class: 'Akeneo\Connectivity\Connection\Application\Settings\Command\RegenerateConnectionSecretHandler'
        arguments:
            - '@akeneo_connectivity.connection.persistence.repository.connection'
            - '@akeneo_connectivity.connection.service.client.regenerate_client_secret'

    akeneo_connectivity.connection.application.handler.regenerate_connection_password:
        class: 'Akeneo\Connectivity\Connection\Application\Settings\Command\RegenerateConnectionPasswordHandler'
        arguments:
            - '@akeneo_connectivity.connection.persistence.repository.connection'
            - '@akeneo_connectivity.connection.service.user.regenerate_user_password'

    akeneo_connectivity.connection.application.audit.handler.get_period_event_count_per_connection:
        class: 'Akeneo\Connectivity\Connection\Application\Audit\Query\GetPeriodEventCountPerConnectionHandler'
        arguments:
            - '@akeneo_connectivity.connection.persistence.query.select_period_event_count_per_connection'

    akeneo_connectivity.connection.application.audit.handler.update_data_source_product_event_count:
        class: Akeneo\Connectivity\Connection\Application\Audit\Command\UpdateDataSourceProductEventCountHandler
        arguments:
            - '@akeneo_connectivity.connection.persistence.query.extract_connections_product_event_count'
            - '@akeneo_connectivity.connection.persistence.repository.event_count'

    akeneo_connectivity.connection.application.audit.handler.update_data_destination_product_event_count:
        class: Akeneo\Connectivity\Connection\Application\Audit\Command\UpdateDataDestinationProductEventCountHandler
        arguments:
            - '@akeneo_connectivity.connection.persistence.repository.event_count'

    akeneo_connectivity.connection.application.audit.handler.get_error_count_per_connection:
        class: Akeneo\Connectivity\Connection\Application\Audit\Query\GetErrorCountPerConnectionHandler
        arguments:
            - '@akeneo_connectivity_connection.persistence.query.select_error_count_per_connection'

    akeneo_connectivity.connection.application.audit.handler.get_period_error_count_per_connection:
        class: Akeneo\Connectivity\Connection\Application\Audit\Query\GetPeriodErrorCountPerConnectionHandler
        arguments:
            - '@akeneo_connectivity_connection.persistence.query.select_period_error_count_per_connection'

    akeneo_connectivity.connection.application.error_management.handler.get_connection_business_errors:
        class: Akeneo\Connectivity\Connection\Application\ErrorManagement\Query\GetConnectionBusinessErrorsHandler
        arguments:
            - '@akeneo_connectivity_connection.persistence.query.select_last_connection_business_errors'

    akeneo_connectivity.connection.application.error_management.handler.update_connection_error_count:
        class: Akeneo\Connectivity\Connection\Application\ErrorManagement\Command\UpdateConnectionErrorCountHandler
        arguments:
            - '@akeneo_connectivity.connection.persistence.repository.error_count'

    akeneo_connectivity.connection.application.webhook.handler.check_url_reachability:
        class: Akeneo\Connectivity\Connection\Application\Webhook\Command\CheckWebhookReachabilityHandler
        arguments:
            - '@akeneo_connectivity.connection.webhook.service.url_reachability_checker'

    akeneo_connectivity.connection.application.webhook.handler.get_connection_webhook:
        class: Akeneo\Connectivity\Connection\Application\Webhook\Query\GetAConnectionWebhookHandler
        arguments:
            - '@akeneo_connectivity.connection.persistence.query.get_connection_webhook'
            - '%webhook_active_event_subscriptions_limit%'
            - '@akeneo_connectivity.connection.persistence.query.count_active_event_subscriptions'

    akeneo_connectivity.connection.application.webhook.handler.send_business_event_to_webhooks:
        class: Akeneo\Connectivity\Connection\Application\Webhook\Command\SendBusinessEventToWebhooksHandler
        arguments:
            - '@akeneo_connectivity.connection.persistence.query.select_active_webhooks'
            - '@akeneo_connectivity.connection.webhook.webhook_user_authenticator'
            - '@akeneo_connectivity.connection.webhook.webhook_client'
            - '@akeneo_connectivity.connection.webhook.webhook_event_builder'
            - '@monolog.logger.event_api'
            - '@akeneo_connectivity.connection.webhook.events_api_debug_logger'
            - '%env(AKENEO_PIM_URL)%'

    akeneo_connectivity.connection.application.webhook.handler.update_connection_webhook:
        class: Akeneo\Connectivity\Connection\Application\Webhook\Command\UpdateWebhookHandler
        arguments:
            - '@akeneo_connectivity.connection.persistence.repository.webhook'
            - '@validator'
            - '@akeneo_connectivity.connection.persistence.query.select_webhook_secret'
            - '@akeneo_connectivity.connection.application.webhook.handler.generate_webhook_secret'

    akeneo_connectivity.connection.application.webhook.handler.generate_webhook_secret:
        class: Akeneo\Connectivity\Connection\Application\Webhook\Command\GenerateWebhookSecretHandler
        arguments:
            - '@akeneo_connectivity.connection.webhook.generate_secret'
            - '@akeneo_connectivity.connection.persistence.query.save_webhook_secret'
