<?php

namespace Fifa\ConnectId\Sdk\Tms;

use Fifa\ConnectId\Sdk\MessageHandlers\MessageHandlerInterface;
use Fifa\ConnectId\Sdk\Registration\CorrelationIdBasedItemContainerInterface;
use Fifa\ConnectId\Sdk\Tms\MessageHandlers\CorrelationIdContainerBasedMessageHandler;
use Fifa\ConnectId\Sdk\Util\Data\Message\TmsActionType;

class TmsFacadeMessageHandlersFactory
{
    /**
     * @param CorrelationIdBasedItemContainerInterface $responsesCache
     * @return MessageHandlerInterface[]
     */
    public static function createMessageHandlers(CorrelationIdBasedItemContainerInterface $responsesCache): array
    {
        $domesticTransferConfirmationHandler = new CorrelationIdContainerBasedMessageHandler(TmsActionType::DOMESTIC_TRANSFER_CONFIRMATION, $responsesCache,
            function ($xmlData) {
                return new DomesticTransferConfirmationMessageReceived($xmlData);
            }
        );
        $proofOfPaymentConfirmationHandler = new CorrelationIdContainerBasedMessageHandler(TmsActionType::PROOF_OF_PAYMENT_CONFIRMATION, $responsesCache,
            function ($xmlData) {
                return new ProofOfPaymentConfirmationMessageReceived($xmlData);
            }
        );
        $firstProRegistrationConfirmationHandler = new CorrelationIdContainerBasedMessageHandler(TmsActionType::FIRST_PRO_REGISTRATION_CONFIRMATION, $responsesCache,
            function ($xmlData) {
                return new FirstProRegistrationConfirmationMessageReceived($xmlData);
            }
        );
        return [$domesticTransferConfirmationHandler, $proofOfPaymentConfirmationHandler, $firstProRegistrationConfirmationHandler];
    }
}