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

/**
 * Read Sabre Profiles Objects
 * https://developer.sabre.com/docs/soap_apis/management/itinerary/Retrieve_Itinerary
 *
 * @author Dan Baluta
 */
class GetReservation extends \App\Sabre\Api\Soap\Operation\GeneralAbstract
{
	protected $Version = '1.19.16';

	protected $Service = 'GetReservationRQ';

	protected $Action = 'GetReservationRQ';


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

	protected function getRequestBody()
	{
	    $GetReservationRQ = new \Engine\SimpleXmlElement("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns8:GetReservationRQ
            xmlns:ns9=\"http://services.sabre.com/res/or/v1_14\"
            xmlns:ns8=\"http://webservices.sabre.com/pnrbuilder/v1_19\"
            xmlns:ns7=\"http://schemas.xmlsoap.org/ws/2002/12/secext\"
            xmlns:ns6=\"http://www.w3.org/2000/09/xmldsig#\"
            xmlns:ns5=\"http://www.w3.org/1999/xlink\"
            xmlns:ns4=\"http://www.ebxml.org/namespaces/messageHeader\"></ns8:GetReservationRQ>");

	    $GetReservationRQ->addAttribute('Version', $this->Version);
	    $GetReservationRQ->addChild('Locator', $this->params['Locator']);
	    $GetReservationRQ->addChild('RequestType', 'Stateful');	// TODO Stateless

	    $ReturnOptions = $GetReservationRQ->addChild('ReturnOptions');
	    $SubjectAreas = $ReturnOptions->addChild('SubjectAreas');
	    $SubjectAreas->addChild('SubjectArea', 'CORPORATE_ID');
	    $SubjectAreas->addChild('SubjectArea', 'DK_NUMBER');
	    $SubjectAreas->addChild('SubjectArea', 'PASSENGERDETAILS');
	    $SubjectAreas->addChild('SubjectArea', 'RECEIVED');
	    $SubjectAreas->addChild('SubjectArea', 'RECORD_LOCATOR');
	    $SubjectAreas->addChild('SubjectArea', 'PRICE_QUOTE');
	    $SubjectAreas->addChild('SubjectArea', 'ADD_HOTEL_LINK_CODE');     // TODO needed?

	    // TODO XSD

	    return $GetReservationRQ->asStr();
	}

	// TODO check errors

}
