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

class Extradata extends \App\Sabre\StructureParser\Structures\Base\Base
{
	/**
	 * Reason for issuance codes.
	 * see Galileo docs, page 147. I suspect that thes are the same across all GDS's
	 * see A16RFI, RFIC
	 */
	protected $reasonCodes = [
		'A' => 'Air transportation',
		'B' => 'Surface transportation/Non-air services',
		'C' => 'Baggage',
		'D' => 'Financial Impact',
		'E' => 'Airport Services',
		'F' => 'Merchandise',
		'G' => 'In-flight services',
	];


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

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

		$MG = $parsedStructure['MG'][$transactionIndexes['kmg']];

		$item->reasonCode = 		$MG['MG']['IUGRFI'];
		$item->reasonCode_text = 	$this->reasonCodes[$MG['MG']['IUGRFI']];

		$item->reasonSubCode = 		$MG['IUGCIN'][0]['IUGCIN']['IUGCSR'];
		$item->reasonSubCode_text = $MG['IUGCIN'][0]['IUGCIN']['IUGCNR'];

		return $item;
	}
}
