<?php
namespace App\Sabre\Api\Soap\Operation;

/**
 * Delete Sabre Profiles Objects
 * https://developer.sabre.com/docs/soap_apis/profiles/profiles_management/Delete_Profile_Objects
 *
 * @author Dan Baluta
 */
class ProfileDelete extends \App\Sabre\Api\Soap\Operation\GeneralAbstract
{

	protected $Service = 'EPS_EXT_ProfileDeleteRQ';

	protected $Action = 'EPS_EXT_ProfileDeleteRQ';

	protected $Version = '6.61.4';

	/**
	 * TVL, CRP
	 * @var string
	 */
	protected $ProfileTypeCode;


	public function __construct($ConversationId, $BinarySecurityToken, $ProfileTypeCode, $UniqueID, $DomainID, \App\Entity\GeneralAbstract $entity)
	{
		$this->params = [];
		$this->params['ConversationId'] = $ConversationId;
		$this->params['BinarySecurityToken'] = $BinarySecurityToken;
		$this->params['UniqueID'] = $UniqueID;
		$this->params['DomainID'] = $DomainID;
		$this->params['entity'] = $entity;

		$this->ProfileTypeCode = $ProfileTypeCode;
	}

	protected function getRequestBody()
	{
		$Sabre_OTA_ProfileDeleteRQ = new \Engine\SimpleXmlElement("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Sabre_OTA_ProfileDeleteRQ
			xsi:schemaLocation=\"http://www.sabre.com/eps/schemas \schemas\Sabre_OTA_ProfileDeleteRQ.xsd\"
			xmlns=\"http://www.sabre.com/eps/schemas\"
			xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></Sabre_OTA_ProfileDeleteRQ>");

		$Sabre_OTA_ProfileDeleteRQ->addAttribute('Version', $this->Version);

		$Delete = $Sabre_OTA_ProfileDeleteRQ->addChild('Delete');

		$Profile = $Delete->addChild('Profile');
		$Profile->addAttribute('PurgeDays', 0);

		$TPA_Identity = $Profile->addChild('TPA_Identity');
		$TPA_Identity->addAttribute('UniqueID', $this->params['UniqueID']);
		$TPA_Identity->addAttribute('DomainID', $this->params['DomainID']);
		$TPA_Identity->addAttribute('ClientCode', $this->ClientCode);
		$TPA_Identity->addAttribute('ProfileTypeCode', $this->ProfileTypeCode);
		$TPA_Identity->addAttribute('ClientContextCode', $this->ClientContextCode);

		//debug($Sabre_OTA_ProfileDeleteRQ->asPretty()); die;

		/*
		// Validate XML against XSD
		$msgs = \App\MessagesCollector::create();
		$msgs = $Sabre_OTA_ProfileDeleteRQ->validateAgainstXsd(__DIR__.'/_xsd/Sabre_OTA_ProfileDeleteRQ.xsd', $msgs);

		if ($msgs->hasErrorOrWarning()) {
			throw new \App\MessagesException($msgs);
		}
		*/

		return $Sabre_OTA_ProfileDeleteRQ->asStr();
	}

}
