<?php
namespace App\Galileo\StructureParser\Structures\LCCTicketing;

class Itinerary extends \App\Galileo\StructureParser\Structures\NDCTicketing\Itinerary
{
    use LCCTrait;

    protected function _getData()
	{
		list($parsedStructure, , $transactionIndexes, ) = $this->getTransactionDetails();

		$A14FlightDetailsForSegment = $this->getA14FlightDetailsForSegment($parsedStructure, $transactionIndexes);

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

		foreach ($A14FlightDetailsForSegment as $seg) {
			$segment = new \App\Galileo\StructureParser\Types\ItinerarySegment();

			// departure
			$dep = new \App\Galileo\StructureParser\Types\ItineraryLocation();
			$match = $this->match([
				'airportCode' => [ $seg['FlightDetailsForSegment']['origin'], ],
			]);

			$dep->suggest("airportCode", $seg['FlightDetailsForSegment']['origin']);

			$dep->airportCode = 	$seg['FlightDetailsForSegment']['origin'];
			$dep->cityId = 			$match->cityId;
			$dep->countryCode = 	$match->countryCode;
			$dep->date = 			$seg['FlightDetailsForSegment']['date'];
			$dep->time = 			$seg['FlightDetailsForSegment']['departureTime'];

			$segment->departure = $dep;


			// destination
			$dest = new \App\Galileo\StructureParser\Types\ItineraryLocation();
			$match = $this->match([
				'airportCode' => [ $seg['FlightDetailsForSegment']['destination'], ],
			]);

			$dest->suggest("airportCode", $seg['FlightDetailsForSegment']['destination']);

			$dest->airportCode = 	$match->airportCode;
			$dest->cityId = 		$match->cityId;
			$dest->countryCode = 	$match->countryCode;
			$dest->date = 			$seg['FlightDetailsForSegment']['date'];
			$dest->time = 			$seg['FlightDetailsForSegment']['arrivalTime'];

			$segment->destination = $dest;

			$segment->supplier->codeAirline = 	$seg['FlightDetailsForSegment']['carrierCode'];

			$segment->transportNumber = 		$seg['FlightDetailsForSegment']['flightNumber'];

			$segment->serviceClassCode = 		$seg['FlightDetailsForSegment']['classCode'];

			$item->appendSegment($segment);
		}

		return $item;
	}

}
