<?php
namespace App\Sabre\StructureParser\Structures\Car;

class Itinerary extends \App\Sabre\StructureParser\Structures\Base\Itinerary
{
	protected function _getData()
	{
		list($parsedStructure, , $transactionIndexes, ) = $this->getTransactionDetails();

		$M3 = $parsedStructure['M3'][$transactionIndexes['km3']];

		$item = new \App\Sabre\StructureParser\Types\Itinerary();

		$segment = new \App\Sabre\StructureParser\Types\ItinerarySegment();

		// departure

		$dep = new \App\Sabre\StructureParser\Types\ItineraryLocation();
		$match = $this->match([
			'cityCode' => [$M3['M3Oths']['IU3VR4_']['pickupPoint'],],
		]);
		$dep->suggest('cityCode', $M3['M3Oths']['IU3VR4_']['pickupPoint']);
		$dep->suggest('airportCode', $M3['M3Oths']['IU3VR4_']['PUP']);

		$dep->airportCode = 	$match->airportCode;
		$dep->cityId = 			$match->cityId;
		$dep->countryCode = 	$match->countryCode;
		$dep->date = 			$M3['M3Oths']['IU3DDT'];
		$dep->time = 			$M3['M3Oths']['IU3VR4_']['ARR']['time'];
		$segment->departure = $dep;

		// destination
		$dest = new \App\Sabre\StructureParser\Types\ItineraryLocation();
		$match = $this->match([
			'cityCode' => [$M3['M3Oths']['IU3VR4_']['DO'],],
		]);
		$dest->suggest('cityCode', $M3['M3Oths']['IU3VR4_']['DO']);

		$dest->airportCode = 	$match->airportCode;
		$dest->cityId = 		$match->cityId;
		$dest->countryCode = 	$match->countryCode;
		$dest->date = 			$M3['M3Oths']['IU3VR4_']['dropOffDate'];
		$dest->time = 			$M3['M3Oths']['IU3VR4_']['RET']['time'];
		$segment->destination = $dest;

		$item->appendSegment($segment);
		return $item;
	}
}
