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

/**
 * End Transaction
 * https://developer.sabre.com/docs/soap_apis/management/itinerary/End_Transaction
 *
 * @author Dan Baluta
 */
class EndTransaction extends \App\Sabre\Api\Soap\Operation\GeneralAbstract
{
	protected $Version = '2.1.0';

	protected $Service = 'EndTransactionLLSRQ';

	protected $Action = 'EndTransactionLLSRQ';


	public function __construct($ConversationId, $BinarySecurityToken, $ReceivedFrom)
	{
	    $this->params = [];
	    $this->params['ConversationId'] = $ConversationId;
	    $this->params['BinarySecurityToken'] = $BinarySecurityToken;
	    $this->params['ReceivedFrom'] = $ReceivedFrom;
	}

	protected function getRequestBody()
	{
	    $EndTransactionRQ  = new \Engine\SimpleXmlElement("<?xml version=\"1.0\" encoding=\"UTF-8\"?><EndTransactionRQ
			xmlns=\"http://webservices.sabre.com/sabreXML/2011/10\"
			xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"
			xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></EndTransactionRQ>");

	    $EndTransactionRQ->addAttribute('Version', $this->Version);
	    //$IgnoreTransactionRQ->addAttribute('ReturnHostCommand', 'true');

	    $EndTransaction = $EndTransactionRQ->addChild('EndTransaction');
	    $EndTransaction->addAttribute('Ind', 'true');

	    $Source = $EndTransactionRQ->addChild('Source');
	    $Source->addAttribute('ReceivedFrom', $this->params['ReceivedFrom']);

	    // TODO XSD

	    return $EndTransactionRQ->asStr();
	}

}
