<?php
namespace App\Amadeus\StructureParser\Structures\Insurance; class ServiceDetails extends \App\Amadeus\StructureParser\Parser\ServiceDetails { public function getDetails() { if($this->CACHE[__METHOD__]) return $this->CACHE[__METHOD__]; $indexType = $this->transaction->getIndexType(); if($indexType=='IVD'){ $price = $this->getDetails_IVD(); if($price){ $this->CACHE[__METHOD__] = $price; return $price; } } if($indexType=='U'){ $price = $this->getDetails_U(); if($price){ $this->CACHE[__METHOD__] = $price; return $price; } } return null; } public function getRemarks() { if($this->CACHE[__METHOD__]) return $this->CACHE[__METHOD__]; $parsedStructure = $this->transaction->getParsedStructure(); $indexType = $this->transaction->getIndexType(); $index = $this->transaction->getIndex(); $item = new \App\Amadeus\StructureParser\Types\Remarks(); if ($indexType=='U') { $U = $parsedStructure['U'][$index->segment]; $I = \App\Amadeus\StructureParser\Helpers::internal_insurance_U_to_I($parsedStructure, $U); $item = $this->getRemarksFromPassenger($parsedStructure, $index, $item, $I); } if ($indexType=='IVD') { $I = $parsedStructure['I'][0]; $item = $this->getRemarksFromPassenger($parsedStructure, $index, $item, $I); } $this->CACHE[__METHOD__] = $item; return $item; } public function getDetails_IVD() { $parsedStructure = $this->transaction->getParsedStructure(); $item = null; $IVD = $parsedStructure['IVD']; if ($IVD['GEOZNDATA']) { $item = new \App\Amadeus\StructureParser\Types\ServiceDetails(); $item->occupancy = count($parsedStructure['I']); $item->insurance_validityArea = $IVD['GEOZNDATA']; $item->insurance_providerCode = $IVD['INPVCODE']; $item->insurance_providerCode_text = $IVD['INPVNAME']; $item->insurance_productCode = $IVD['INPDCODE']; $item->insurance_productCode_text = $IVD['INPDNAME']; $extensions = []; foreach($IVD['EXTN'] as $EXTN){ $ext = new \App\Amadeus\StructureParser\Types\InsuranceExtension(); $ext->code = $EXTN['EXTNCODE']; $ext->type = $EXTN['EXTTYPE']; $ext->name = $EXTN['EXTNNAME']; $extensions[] = $ext; } $item->insurance_extensions = $extensions; } $item = $this->extractCommonServiceDetails($parsedStructure, $item); return $item; } public function getDetails_U() { $parsedStructure = $this->transaction->getParsedStructure(); $index = $this->transaction->getIndex(); $item = null; $U = $parsedStructure['U'][$index->segment]; $item = new \App\Amadeus\StructureParser\Types\ServiceDetails(); if ($U['GEOZNDATA']) { $item->occupancy = count($parsedStructure['I']); $item->insurance_validityArea = $U['GEOZNDATA']; } $item->insurance_providerCode = $U['INPVCODE']; $item->insurance_providerCode_text =$U['INPVNAME']; $item->insurance_productCode = $U['INPDCODE']; $item->insurance_productCode_text = $U['INPDNAME']; if ($U['EXTN']) { $extensions = []; foreach($U['EXTN'] as $EXTN){ $ext = new \App\Amadeus\StructureParser\Types\InsuranceExtension(); $ext->code = $EXTN['EXTNCODE']; $ext->type = $EXTN['EXTTYPE']; $ext->name = $EXTN['EXTNNAME']; $extensions[] = $ext; } $item->insurance_extensions = $extensions; } $item = $this->extractCommonServiceDetails($parsedStructure, $item); return $item; } } 