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

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

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