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

/**
 * Add Itinerary Remarks - multiple at once
 * https://developer.sabre.com/docs/soap_apis/management/itinerary/Add_Itinerary_Remark
 *
 * @author Dan Baluta
 */
class AddBulkRemarks extends \App\Sabre\Api\Soap\Operation\GeneralAbstract
{
	protected $Version = '2.1.1';

	protected $Service = 'AddRemarkLLSRQ';

	protected $Action = 'AddRemarkLLSRQ';


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

	protected function getRequestBody()
	{
		$AddRemarkRQ = new \Engine\SimpleXmlElement("<?xml version=\"1.0\" encoding=\"UTF-8\"?><AddRemarkRQ
			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\"></AddRemarkRQ>");

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

		$RemarkInfo = $AddRemarkRQ->addChild('RemarkInfo');

		foreach ($this->params['Texts'] as $Text) {
    		$Remark = $RemarkInfo->addChild('Remark');
    		$Remark->addAttribute('Type', $this->params['Type']);
    		$Remark->addChild('Text', $Text);
		}

		// TODO XSD

		return $AddRemarkRQ->asStr();
	}

	// TODO check errors

}
