<?php

namespace Fifa\ConnectId\Sdk\Util\MessageSerializers;

use Fifa\ConnectId\Sdk\Model\Transfer\DomesticTransferConfirmation;
use Fifa\ConnectId\Sdk\Model\Transfer\DomesticTransferDeclarationResponse;
use Fifa\ConnectId\Sdk\Model\Transfer\ErrorType;
use Fifa\ConnectId\Sdk\Util\Serialization\Configurations\CommonXmlSerializerConfiguration;
use Fifa\ConnectId\Sdk\Util\Serialization\ValidatingXmlSerializerBase;
use Fifa\ConnectId\Sdk\Util\XmlDeserializer\XmlDeserializer;
use XML_Serializer;

class DomesticTransferDeclarationResponseXmlSerializer extends ValidatingXmlSerializerBase
{
    public function __construct()
    {
        $deserializer = new XmlDeserializer(DomesticTransferDeclarationResponse::class, [
            'Confirmation' => DomesticTransferConfirmation::class,
            'Error' => ErrorType::class,
        ]);

        $serializer = new XML_Serializer();
        $serializer->setOptions(CommonXmlSerializerConfiguration::buildOptions('DomesticTransferDeclarationResponse',
            [
                XML_SERIALIZER_OPTION_SCALAR_AS_ATTRIBUTES => [
                    'Confirmation' => ['TmsTransferId'],
                    'Error' => ['Message']
                ]
            ])
        );

        parent::__construct($serializer, $deserializer);
    }
}