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

/**
 * Create Session
 * https://developer.sabre.com/docs/soap_apis/session_management/create_session
 *
 * @author Dan Baluta
 */
class SessionCreate extends \App\Sabre\Api\Soap\Operation\GeneralAbstract
{

	protected $Service = 'Session';

	protected $Action = 'SessionCreateRQ';


	protected function getRequestBody()
	{}

	/**
	 * {@inheritDoc}
	 * @see \App\Sabre\Api\Soap\Operation\GeneralAbstract::getRequestXml()
	 */
	protected function getRequestXml()
	{
		$CFG = \Engine\Loader_Cfg::getInstance()->getGlobal();

		// namespaces
		$soapenv = $this->soapenv;
		$sec 	 = $this->sec;
		$mes 	 = $this->mes;
		$ns  	 = $this->ns;

		$Envelope = new \Engine\SimpleXmlElement("<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope
		    xmlns:soapenv=\"{$soapenv}\"
		    xmlns:sec=\"{$sec}\"
		    xmlns:mes=\"{$mes}\"
		    xmlns:ns=\"{$ns}\"></soapenv:Envelope>");

		$this->getRequestHeader($Envelope);

		$Body = $Envelope->addChild('Body', null, $soapenv);

		$SessionCreateRQ = $Body->addChild('SessionCreateRQ', null, $ns);
		$SessionCreateRQ->addAttribute('returnContextID', "");
		$POS = $SessionCreateRQ->addChild('POS', null, $ns);
		$Source = $POS->addChild('Source', null, $ns);
		$Source->addAttribute('PseudoCityCode', $CFG['sabre']['Api']['credentials']['Organization']);

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

		return $Envelope->asXML();
	}



}
