<?php

namespace Fifa\ConnectId\Sdk\Util\MessageSerializers;

use Fifa\ConnectId\Sdk\Model\Transfer\ErrorType;
use Fifa\ConnectId\Sdk\Model\Transfer\FirstProRegistrationConfirmation;
use Fifa\ConnectId\Sdk\Model\Transfer\FirstProRegistrationResponse;
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 FirstProRegistrationResponseXmlSerializer extends ValidatingXmlSerializerBase
{
    public function __construct()
    {
        $deserializer = new XmlDeserializer(FirstProRegistrationResponse::class, [
            'Confirmation' => FirstProRegistrationConfirmation::class,
            'Error' => ErrorType::class,
        ]);

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

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