From 38c828fbe65ea767d338493700fb2dfd8eec7cc9 Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Wed, 24 Apr 2019 12:56:26 +0200 Subject: [PATCH 01/15] Anchored search --- .../RequestOptions/Fare/MPAnchoredSegment.php | 35 ++++++++ .../RequestOptions/Fare/MPItinerary.php | 9 ++ .../Fare/MasterPricer/FlightInfoPNR.php | 62 +++++++++++++ .../MasterPricer/TravelResponseDetails.php | 35 ++++++++ .../Fare/MasterPricerTravelBoardSearch.php | 7 ++ .../MasterPricerTravelBoardSearchTest.php | 90 +++++++++++++++++++ 6 files changed, 238 insertions(+) create mode 100644 src/Amadeus/Client/RequestOptions/Fare/MPAnchoredSegment.php create mode 100644 src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php create mode 100644 src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php diff --git a/src/Amadeus/Client/RequestOptions/Fare/MPAnchoredSegment.php b/src/Amadeus/Client/RequestOptions/Fare/MPAnchoredSegment.php new file mode 100644 index 000000000..83c37adb9 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/Fare/MPAnchoredSegment.php @@ -0,0 +1,35 @@ + + */ +class MPAnchoredSegment extends SegmentOptions +{ +} diff --git a/src/Amadeus/Client/RequestOptions/Fare/MPItinerary.php b/src/Amadeus/Client/RequestOptions/Fare/MPItinerary.php index 945591995..b8c762293 100644 --- a/src/Amadeus/Client/RequestOptions/Fare/MPItinerary.php +++ b/src/Amadeus/Client/RequestOptions/Fare/MPItinerary.php @@ -160,4 +160,13 @@ class MPItinerary extends LoadParamsFromArray * @var string */ public $cabinOption; + + public $travelDetails; + + /** + * Anchored Search segment + * + * @var MPAnchoredSegment + */ + public $anchoredSegment; } diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php new file mode 100644 index 000000000..6f2c0a967 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php @@ -0,0 +1,62 @@ + + */ +class FlightInfoPNR +{ + /** + * Details for basic anchored mode + * + * @var TravelResponseDetails + */ + public $travelResponseDetails; + + /** + * FlightInfoPNR constructor. + * + * @param SegmentOptions $seg + */ + public function __construct(SegmentOptions $seg) + { + + $this->travelResponseDetails = new TravelResponseDetails( + $seg->departureDate, + $seg->from, + $seg->to, + $seg->companyCode, + $seg->flightNumber, + $seg->bookingClass, + $seg->arrivalDate, + $seg->arrivalTime, + $seg->dateVariation, + $seg->flightTypeDetails + ); + } +} diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php new file mode 100644 index 000000000..9545ae72c --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php @@ -0,0 +1,35 @@ + + */ +class TravelResponseDetails extends TravelProductInformation +{ +} diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php b/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php index d982b2b5a..56b575d2d 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php @@ -212,6 +212,13 @@ protected function loadItinerary($opt, &$counter) $tmpItinerary->departureLocalization = new MasterPricer\DepartureLocalization( $opt->departureLocation ); + + if($opt->anchoredSegment) { + $tmpItinerary->flightInfoPNR = new MasterPricer\FlightInfoPNR( + $opt->anchoredSegment + ); + } + $tmpItinerary->arrivalLocalization = new MasterPricer\ArrivalLocalization( $opt->arrivalLocation ); diff --git a/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php b/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php index f9bcb7b01..be4e701b3 100644 --- a/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php +++ b/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php @@ -36,6 +36,7 @@ use Amadeus\Client\RequestOptions\Fare\MPPassenger; use Amadeus\Client\RequestOptions\Fare\MPFeeId; use Amadeus\Client\RequestOptions\Fare\MPTicketingPriceScheme; +use Amadeus\Client\RequestOptions\Fare\MPAnchoredSegment; use Amadeus\Client\RequestOptions\FareMasterPricerTbSearch; use Amadeus\Client\Struct\Fare\MasterPricer\BooleanExpression; use Amadeus\Client\Struct\Fare\MasterPricer\CabinId; @@ -1834,4 +1835,93 @@ public function testCanSpecifyFormOfPayment() $this->assertEquals(100, $message->fareOptions->formOfPayment[0]->chargedAmount); $this->assertEquals('123456', $message->fareOptions->formOfPayment[0]->creditCardNumber); } + + public function testCanMakeAnchoredSearch() + { + $opt = new FareMasterPricerTbSearch(); + $opt->nrOfRequestedResults = 200; + $opt->nrOfRequestedPassengers = 1; + $opt->passengers[] = new MPPassenger([ + 'type' => MPPassenger::TYPE_ADULT, + 'count' => 1 + ]); + $opt->itinerary[] = new MPItinerary([ + 'departureLocation' => new MPLocation(['city' => 'BRU']), + 'arrivalLocation' => new MPLocation(['city' => 'LON']), + 'date' => new MPDate(['dateTime' => new \DateTime('2017-01-15T00:00:00+0000', new \DateTimeZone('UTC'))]), + 'anchoredSegment' => new MPAnchoredSegment([ + 'departureDate' => \DateTime::createFromFormat('Ymd Hi','20180315 1540', new \DateTimeZone('UTC')), + 'arrivalDate' => \DateTime::createFromFormat('Ymd Hi','20180316 0010', new \DateTimeZone('UTC')), + 'dateVariation' => '', + 'from' => 'SFO', + 'to' => 'JFK', + 'companyCode' => 'AA', + 'flightNumber' => '20' + ]) + ]); + + $message = new MasterPricerTravelBoardSearch($opt); + + $this->assertInternalType('array', $message->itinerary); + $this->assertCount(1, $message->itinerary); + $this->assertInstanceOf('Amadeus\Client\Struct\Fare\MasterPricer\Itinerary', $message->itinerary[0]); + $this->assertInstanceOf('Amadeus\Client\Struct\Fare\MasterPricer\TimeDetails', $message->itinerary[0]->timeDetails); + $this->assertInstanceOf('Amadeus\Client\Struct\Fare\MasterPricer\FirstDateTimeDetail', $message->itinerary[0]->timeDetails->firstDateTimeDetail); + $this->assertEquals('150117', $message->itinerary[0]->timeDetails->firstDateTimeDetail->date); + $this->assertNull($message->itinerary[0]->timeDetails->firstDateTimeDetail->time); + $this->assertNull($message->itinerary[0]->timeDetails->firstDateTimeDetail->timeQualifier); + $this->assertEquals('BRU', $message->itinerary[0]->departureLocalization->departurePoint->locationId); + $this->assertEquals('C', $message->itinerary[0]->departureLocalization->departurePoint->airportCityQualifier); + $this->assertEquals('LON', $message->itinerary[0]->arrivalLocalization->arrivalPointDetails->locationId); + $this->assertEquals('C', $message->itinerary[0]->arrivalLocalization->arrivalPointDetails->airportCityQualifier); + + $this->assertEquals(1, $message->itinerary[0]->requestedSegmentRef->segRef); + $this->assertNull($message->itinerary[0]->requestedSegmentRef->locationForcing); + + $this->assertNull($message->itinerary[0]->flightInfo); + $this->assertNull($message->itinerary[0]->attributes); + $this->assertNotNull($message->itinerary[0]->flightInfoPNR); + $this->assertNull($message->itinerary[0]->requestedSegmentAction); + + $this->assertEquals('150318', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->departureDate); + $this->assertEquals('1540', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->departureTime); + $this->assertEquals('160318', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->arrivalDate); + $this->assertEquals('0010', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->arrivalTime); + $this->assertEquals('SFO', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->boardPointDetails->trueLocationId); + $this->assertEquals('JFK', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->offpointDetails->trueLocationId); + $this->assertEquals('20', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightIdentification->flightNumber); + $this->assertNull($message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightIdentification->bookingClass); + $this->assertEquals('AA', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->companyDetails->marketingCompany); + + + + $this->assertCount(2, $message->numberOfUnit->unitNumberDetail); + $this->assertEquals(1, $message->numberOfUnit->unitNumberDetail[0]->numberOfUnits); + $this->assertEquals(UnitNumberDetail::TYPE_PASS, $message->numberOfUnit->unitNumberDetail[0]->typeOfUnit); + $this->assertEquals(200, $message->numberOfUnit->unitNumberDetail[1]->numberOfUnits); + $this->assertEquals(UnitNumberDetail::TYPE_RESULTS, $message->numberOfUnit->unitNumberDetail[1]->typeOfUnit); + + $this->assertCount(1, $message->paxReference); + $this->assertCount(1, $message->paxReference[0]->ptc); + $this->assertEquals('ADT', $message->paxReference[0]->ptc[0]); + $this->assertCount(1, $message->paxReference[0]->traveller); + $this->assertEquals(1, $message->paxReference[0]->traveller[0]->ref); + $this->assertNull($message->paxReference[0]->traveller[0]->infantIndicator); + + $this->assertEmpty($message->buckets); + $this->assertNull($message->combinationFareFamilies); + $this->assertNull($message->customerRef); + $this->assertEmpty($message->fareFamilies); + $this->assertNull($message->feeOption); + $this->assertNull($message->formOfPaymentByPassenger); + $this->assertNull($message->globalOptions); + $this->assertNull($message->officeIdDetails); + $this->assertEmpty($message->passengerInfoGrp); + $this->assertNull($message->priceToBeat); + $this->assertNull($message->solutionFamily); + $this->assertNull($message->taxInfo); + $this->assertNull($message->ticketChangeInfo); + $this->assertEmpty($message->valueSearch); + $this->assertNull($message->travelFlightInfo); + } } From 70cdf5da74164cb60d9ea6594a7e12997dbda9eb Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Wed, 24 Apr 2019 13:24:51 +0200 Subject: [PATCH 02/15] Fixes --- .../Struct/Fare/MasterPricer/FlightDate.php | 128 ++++++++++++++++++ .../MasterPricer/TravelResponseDetails.php | 68 +++++++++- .../MasterPricerTravelBoardSearchTest.php | 4 +- 3 files changed, 196 insertions(+), 4 deletions(-) create mode 100644 src/Amadeus/Client/Struct/Fare/MasterPricer/FlightDate.php diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightDate.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightDate.php new file mode 100644 index 000000000..f82b78e9c --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightDate.php @@ -0,0 +1,128 @@ + + */ +class FlightDate +{ + /** + * DDMMYY + * + * @var string + */ + public $departureDate; + /** + * HHMM + * + * @var string + */ + public $departureTime; + /** + * DDMMYY + * + * @var string + */ + public $arrivalDate; + /** + * HHMM + * + * @var string + */ + public $arrivalTime; + /** + * @var string|int + */ + public $dateVariation; + + /** + * FlightDate constructor. + * + * @param string|\DateTime|null $departureDate in format DDMMYY or \DateTime + * @param \DateTime|null $arrivalDate + * @param string|\DateTime|null $arrivalTime + * @param int|null $dateVariation + */ + public function __construct($departureDate, $arrivalDate = null, $arrivalTime = null, $dateVariation = null) + { + $this->loadDepartureDate($departureDate); + + $this->loadArrivalDate($arrivalDate, $arrivalTime); + + if (!is_null($dateVariation)) { + $this->dateVariation = $dateVariation; + } + } + + /** + * @param \DateTime|string|null $departureDate + */ + protected function loadDepartureDate($departureDate) + { + if ($departureDate instanceof \DateTime) { + $this->departureDate = ($departureDate->format('dmy') !== '000000') ? $departureDate->format('Ymd') : null; + $time = $departureDate->format('Hi'); + if ($time !== '0000') { + $this->departureTime = $time; + } + } elseif (!empty($departureDate)) { + $this->departureDate = $departureDate; + } + } + + /** + * @param \DateTime|null $arrivalDate + * @param string|\DateTime|null $arrivalTime + */ + protected function loadArrivalDate($arrivalDate, $arrivalTime) + { + if ($arrivalDate instanceof \DateTime) { + $this->setArrivalDate($arrivalDate); + } elseif ($arrivalTime instanceof \DateTime) { + $time = $arrivalTime->format('Hi'); + if ($time !== '0000') { + $this->arrivalTime = $time; + } + } elseif (is_string($arrivalTime) && !empty($arrivalTime)) { + $this->arrivalTime = $arrivalTime; + } + } + + /** + * Load Arrival date info from \DateTime + * + * @param \DateTime $arrivalDate + */ + public function setArrivalDate(\DateTime $arrivalDate) + { + $this->arrivalDate = ($arrivalDate->format('dmy') !== '000000') ? $arrivalDate->format('Ymd') : null; + $time = $arrivalDate->format('Hi'); + if ($time !== '0000') { + $this->arrivalTime = $time; + } + } +} diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php index 9545ae72c..6a16f3f14 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php @@ -22,7 +22,10 @@ namespace Amadeus\Client\Struct\Fare\MasterPricer; -use Amadeus\Client\Struct\Air\TravelProductInformation; +use Amadeus\Client\Struct\Air\PointDetails; +use Amadeus\Client\Struct\Air\CompanyDetails; +use Amadeus\Client\Struct\Air\FlightIdentification; +use Amadeus\Client\Struct\Air\FlightTypeDetails; /** * TravelResponseDetails @@ -30,6 +33,67 @@ * @package Amadeus\Client\Struct\Fare\MasterPricer * @author Mike Hernas */ -class TravelResponseDetails extends TravelProductInformation +class TravelResponseDetails { + + /** + * @var FlightDate + */ + public $flightDate; + /** + * @var PointDetails + */ + public $boardPointDetails; + /** + * @var PointDetails + */ + public $offpointDetails; + /** + * @var CompanyDetails + */ + public $companyDetails; + /** + * @var FlightIdentification + */ + public $flightIdentification; + /** + * @var FlightTypeDetails + */ + public $flightTypeDetails; + + /** + * TravelProductInformation constructor. + * + * @param \DateTime $departureDate + * @param string $from + * @param string $to + * @param string $company + * @param string $flightNumber + * @param string $bookingClass + * @param \DateTime|null $arrivalDate + * @param string|\DateTime|null $arrivalTime + * @param int|null $dateVariation + * @param string|null $flightTypeDetails + */ + public function __construct( + $departureDate, + $from, + $to, + $company, + $flightNumber, + $bookingClass, + $arrivalDate = null, + $arrivalTime = null, + $dateVariation = null, + $flightTypeDetails = null + ) { + $this->flightDate = new FlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation); + $this->boardPointDetails = new PointDetails($from); + $this->offpointDetails = new PointDetails($to); + $this->companyDetails = new CompanyDetails($company); + $this->flightIdentification = new FlightIdentification($flightNumber, $bookingClass); + if (!is_null($flightTypeDetails)) { + $this->flightTypeDetails = new FlightTypeDetails($flightTypeDetails); + } + } } diff --git a/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php b/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php index be4e701b3..262134a72 100644 --- a/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php +++ b/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php @@ -1883,9 +1883,9 @@ public function testCanMakeAnchoredSearch() $this->assertNotNull($message->itinerary[0]->flightInfoPNR); $this->assertNull($message->itinerary[0]->requestedSegmentAction); - $this->assertEquals('150318', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->departureDate); + $this->assertEquals('20180315', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->departureDate); $this->assertEquals('1540', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->departureTime); - $this->assertEquals('160318', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->arrivalDate); + $this->assertEquals('20180316', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->arrivalDate); $this->assertEquals('0010', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->arrivalTime); $this->assertEquals('SFO', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->boardPointDetails->trueLocationId); $this->assertEquals('JFK', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->offpointDetails->trueLocationId); From 0cc89fa16b0c222f4667445f8955e49043dfd764 Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Wed, 24 Apr 2019 18:15:59 +0200 Subject: [PATCH 03/15] Anchored segments --- docs/samples/masterpricertravelboard.rst | 47 +++++++++++++++++++ .../RequestOptions/Fare/MPItinerary.php | 6 +-- .../Fare/MasterPricerTravelBoardSearch.php | 10 ++-- .../MasterPricerTravelBoardSearchTest.php | 42 +++++++++-------- 4 files changed, 78 insertions(+), 27 deletions(-) diff --git a/docs/samples/masterpricertravelboard.rst b/docs/samples/masterpricertravelboard.rst index db31cda63..cc21d484a 100644 --- a/docs/samples/masterpricertravelboard.rst +++ b/docs/samples/masterpricertravelboard.rst @@ -208,6 +208,53 @@ Brussels - London with preferred airlines BA or SN: $message = new MasterPricerTravelBoardSearch($opt); +Anchored segments +================== + +Brussels - London with anchored segment: + +.. code-block:: php + + use Amadeus\Client\RequestOptions\FareMasterPricerTbSearch; + use Amadeus\Client\RequestOptions\Fare\MPItinerary; + use Amadeus\Client\RequestOptions\Fare\MPLocation; + use Amadeus\Client\RequestOptions\Fare\MPPassenger; + use Amadeus\Client\RequestOptions\Fare\MPDate; + use Amadeus\Client\RequestOptions\Fare\MPAnchoredSegment; + + $opt = new FareMasterPricerTbSearch([ + 'nrOfRequestedResults' => 30, + 'nrOfRequestedPassengers' => 1, + 'passengers' => [ + new MPPassenger([ + 'type' => MPPassenger::TYPE_ADULT, + 'count' => 1 + ]) + ], + 'itinerary' => [ + new MPItinerary([ + 'departureLocation' => new MPLocation(['city' => 'BRU']), + 'arrivalLocation' => new MPLocation(['city' => 'LON']), + 'date' => new MPDate([ + 'dateTime' => new \DateTime('2017-01-15T14:00:00+0000', new \DateTimeZone('UTC')) + ]) + ]) + ], + 'anchoredSegments' => [ + new MPAnchoredSegment([ + 'departureDate' => \DateTime::createFromFormat('Ymd Hi','20180315 1540', new \DateTimeZone('UTC')), + 'arrivalDate' => \DateTime::createFromFormat('Ymd Hi','20180316 0010', new \DateTimeZone('UTC')), + 'dateVariation' => '', + 'from' => 'BRU', + 'to' => 'LHR', + 'companyCode' => 'BA', + 'flightNumber' => '20' + ]) + ] + ]); + + $message = new MasterPricerTravelBoardSearch($opt); + Multi-city & airline exclusion ============================== diff --git a/src/Amadeus/Client/RequestOptions/Fare/MPItinerary.php b/src/Amadeus/Client/RequestOptions/Fare/MPItinerary.php index b8c762293..f49f86290 100644 --- a/src/Amadeus/Client/RequestOptions/Fare/MPItinerary.php +++ b/src/Amadeus/Client/RequestOptions/Fare/MPItinerary.php @@ -164,9 +164,9 @@ class MPItinerary extends LoadParamsFromArray public $travelDetails; /** - * Anchored Search segment + * Anchored Search segment (MPAnchoredSegment) * - * @var MPAnchoredSegment + * @var array[MPAnchoredSegment] */ - public $anchoredSegment; + public $anchoredSegments; } diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php b/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php index 56b575d2d..a37914fab 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php @@ -213,10 +213,12 @@ protected function loadItinerary($opt, &$counter) $opt->departureLocation ); - if($opt->anchoredSegment) { - $tmpItinerary->flightInfoPNR = new MasterPricer\FlightInfoPNR( - $opt->anchoredSegment - ); + if($opt->anchoredSegments) { + $tmpItinerary->flightInfoPNR = array_map(function($anchoredSegment) { + return new MasterPricer\FlightInfoPNR( + $anchoredSegment + ); + }, $opt->anchoredSegments); } $tmpItinerary->arrivalLocalization = new MasterPricer\ArrivalLocalization( diff --git a/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php b/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php index 262134a72..c08fc2626 100644 --- a/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php +++ b/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php @@ -97,7 +97,7 @@ public function testCanMakeBaseMasterPricerMessage() $this->assertNull($message->itinerary[0]->flightInfo); $this->assertNull($message->itinerary[0]->attributes); - $this->assertNull($message->itinerary[0]->flightInfoPNR); + $this->assertNull($message->itinerary[0]->flightInfoPNR[0]); $this->assertNull($message->itinerary[0]->requestedSegmentAction); $this->assertCount(2, $message->numberOfUnit->unitNumberDetail); @@ -1849,15 +1849,17 @@ public function testCanMakeAnchoredSearch() 'departureLocation' => new MPLocation(['city' => 'BRU']), 'arrivalLocation' => new MPLocation(['city' => 'LON']), 'date' => new MPDate(['dateTime' => new \DateTime('2017-01-15T00:00:00+0000', new \DateTimeZone('UTC'))]), - 'anchoredSegment' => new MPAnchoredSegment([ - 'departureDate' => \DateTime::createFromFormat('Ymd Hi','20180315 1540', new \DateTimeZone('UTC')), - 'arrivalDate' => \DateTime::createFromFormat('Ymd Hi','20180316 0010', new \DateTimeZone('UTC')), - 'dateVariation' => '', - 'from' => 'SFO', - 'to' => 'JFK', - 'companyCode' => 'AA', - 'flightNumber' => '20' - ]) + 'anchoredSegments' => [ + new MPAnchoredSegment([ + 'departureDate' => \DateTime::createFromFormat('Ymd Hi','20180315 1540', new \DateTimeZone('UTC')), + 'arrivalDate' => \DateTime::createFromFormat('Ymd Hi','20180316 0010', new \DateTimeZone('UTC')), + 'dateVariation' => '', + 'from' => 'SFO', + 'to' => 'JFK', + 'companyCode' => 'AA', + 'flightNumber' => '20' + ]) + ] ]); $message = new MasterPricerTravelBoardSearch($opt); @@ -1880,18 +1882,18 @@ public function testCanMakeAnchoredSearch() $this->assertNull($message->itinerary[0]->flightInfo); $this->assertNull($message->itinerary[0]->attributes); - $this->assertNotNull($message->itinerary[0]->flightInfoPNR); $this->assertNull($message->itinerary[0]->requestedSegmentAction); - $this->assertEquals('20180315', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->departureDate); - $this->assertEquals('1540', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->departureTime); - $this->assertEquals('20180316', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->arrivalDate); - $this->assertEquals('0010', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightDate->arrivalTime); - $this->assertEquals('SFO', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->boardPointDetails->trueLocationId); - $this->assertEquals('JFK', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->offpointDetails->trueLocationId); - $this->assertEquals('20', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightIdentification->flightNumber); - $this->assertNull($message->itinerary[0]->flightInfoPNR->travelResponseDetails->flightIdentification->bookingClass); - $this->assertEquals('AA', $message->itinerary[0]->flightInfoPNR->travelResponseDetails->companyDetails->marketingCompany); + $this->assertCount(1, $message->itinerary[0]->flightInfoPNR); + $this->assertEquals('20180315', $message->itinerary[0]->flightInfoPNR[0]->travelResponseDetails->flightDate->departureDate); + $this->assertEquals('1540', $message->itinerary[0]->flightInfoPNR[0]->travelResponseDetails->flightDate->departureTime); + $this->assertEquals('20180316', $message->itinerary[0]->flightInfoPNR[0]->travelResponseDetails->flightDate->arrivalDate); + $this->assertEquals('0010', $message->itinerary[0]->flightInfoPNR[0]->travelResponseDetails->flightDate->arrivalTime); + $this->assertEquals('SFO', $message->itinerary[0]->flightInfoPNR[0]->travelResponseDetails->boardPointDetails->trueLocationId); + $this->assertEquals('JFK', $message->itinerary[0]->flightInfoPNR[0]->travelResponseDetails->offpointDetails->trueLocationId); + $this->assertEquals('20', $message->itinerary[0]->flightInfoPNR[0]->travelResponseDetails->flightIdentification->flightNumber); + $this->assertNull($message->itinerary[0]->flightInfoPNR[0]->travelResponseDetails->flightIdentification->bookingClass); + $this->assertEquals('AA', $message->itinerary[0]->flightInfoPNR[0]->travelResponseDetails->companyDetails->marketingCompany); From d2ecb2ee384f53abaef0256b0e9474e32bec5468 Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Wed, 24 Apr 2019 18:37:50 +0200 Subject: [PATCH 04/15] Fix --- .../Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php b/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php index c08fc2626..c6c8f158e 100644 --- a/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php +++ b/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php @@ -97,7 +97,7 @@ public function testCanMakeBaseMasterPricerMessage() $this->assertNull($message->itinerary[0]->flightInfo); $this->assertNull($message->itinerary[0]->attributes); - $this->assertNull($message->itinerary[0]->flightInfoPNR[0]); + $this->assertNull($message->itinerary[0]->flightInfoPNR); $this->assertNull($message->itinerary[0]->requestedSegmentAction); $this->assertCount(2, $message->numberOfUnit->unitNumberDetail); From 95767c3e104dfbbf8ce80f2a7ef9561226bacebc Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Wed, 24 Apr 2019 18:46:03 +0200 Subject: [PATCH 05/15] StyleCI --- src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php | 2 +- .../Client/Struct/Fare/MasterPricerTravelBoardSearch.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php index 6f2c0a967..89c976e2f 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php @@ -46,7 +46,7 @@ class FlightInfoPNR public function __construct(SegmentOptions $seg) { - $this->travelResponseDetails = new TravelResponseDetails( + $this->travelResponseDetails = new TravelResponseDetails( $seg->departureDate, $seg->from, $seg->to, diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php b/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php index a37914fab..5f907f5f3 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php @@ -213,8 +213,8 @@ protected function loadItinerary($opt, &$counter) $opt->departureLocation ); - if($opt->anchoredSegments) { - $tmpItinerary->flightInfoPNR = array_map(function($anchoredSegment) { + if ($opt->anchoredSegments) { + $tmpItinerary->flightInfoPNR = array_map(function ($anchoredSegment) { return new MasterPricer\FlightInfoPNR( $anchoredSegment ); From 0015aac83e5e06afc409a8af4093a0e2a217d56f Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Wed, 18 Dec 2019 17:04:13 +0100 Subject: [PATCH 06/15] New endpoint service book price added --- src/Amadeus/Client.php | 19 +++++ .../Service/BookPriceServiceConv.php | 46 ++++++++++++ .../Service/BookPriceService/Identifier.php | 65 ++++++++++++++++ .../ServiceBookPriceServiceOptions.php | 57 ++++++++++++++ .../Struct/Service/BookPriceService.php | 51 +++++++++++++ .../Service/BookPriceService/Identifier.php | 75 +++++++++++++++++++ .../Service/BookPriceService/Product.php | 48 ++++++++++++ .../Service/BookPriceService/Service.php | 61 +++++++++++++++ .../BookPriceService/ServiceProvider.php | 46 ++++++++++++ 9 files changed, 468 insertions(+) create mode 100644 src/Amadeus/Client/RequestCreator/Converter/Service/BookPriceServiceConv.php create mode 100644 src/Amadeus/Client/RequestOptions/Service/BookPriceService/Identifier.php create mode 100644 src/Amadeus/Client/RequestOptions/ServiceBookPriceServiceOptions.php create mode 100644 src/Amadeus/Client/Struct/Service/BookPriceService.php create mode 100644 src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php create mode 100644 src/Amadeus/Client/Struct/Service/BookPriceService/Product.php create mode 100644 src/Amadeus/Client/Struct/Service/BookPriceService/Service.php create mode 100644 src/Amadeus/Client/Struct/Service/BookPriceService/ServiceProvider.php diff --git a/src/Amadeus/Client.php b/src/Amadeus/Client.php index b08398962..6705f17cd 100644 --- a/src/Amadeus/Client.php +++ b/src/Amadeus/Client.php @@ -1584,6 +1584,25 @@ public function serviceIntegratedCatalogue( return $this->callMessage($msgName, $options, $messageOptions); } + /** + * Service_BookPriceService + * + * @param RequestOptions\ServiceBookPriceServiceOptions $options + * @param array $messageOptions (OPTIONAL) + * @return Result + * @throws Client\InvalidMessageException + * @throws Client\RequestCreator\MessageVersionUnsupportedException + * @throws Exception + */ + public function serviceBookPriceService( + RequestOptions\ServiceBookPriceServiceOptions $options, + $messageOptions = [] + ) { + $msgName = 'Service_BookPriceService'; + + return $this->callMessage($msgName, $options, $messageOptions); + } + /** * SalesReports_DisplayorSummarizedReport * diff --git a/src/Amadeus/Client/RequestCreator/Converter/Service/BookPriceServiceConv.php b/src/Amadeus/Client/RequestCreator/Converter/Service/BookPriceServiceConv.php new file mode 100644 index 000000000..307b320ec --- /dev/null +++ b/src/Amadeus/Client/RequestCreator/Converter/Service/BookPriceServiceConv.php @@ -0,0 +1,46 @@ + + */ +class BookPriceServiceConv extends BaseConverter +{ + /** + * @param ServiceBookPriceServiceOptions $requestOptions + * @param int|string $version + * @return Struct\Service\BookPriceService + */ + public function convert($requestOptions, $version) + { + return new Struct\Service\BookPriceService($requestOptions); + } +} diff --git a/src/Amadeus/Client/RequestOptions/Service/BookPriceService/Identifier.php b/src/Amadeus/Client/RequestOptions/Service/BookPriceService/Identifier.php new file mode 100644 index 000000000..1f10ceaa9 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/Service/BookPriceService/Identifier.php @@ -0,0 +1,65 @@ + + */ +class Identifier extends LoadParamsFromArray +{ + const BOOKING_METHOD_SSR = 1; + const BOOKING_METHOD_SVC = 2; + + /** + * self::BOOKING_METHOD_* + * + * 01 SSR type of booking method + * 02 SVC type of booking method + * + * @var string + */ + public $bookingMethod; + + /** + * + * @var string + */ + public $RFIC; + + /** + * + * @var string + */ + public $RFISC; + + /** + * + * @var string + */ + public $code; +} diff --git a/src/Amadeus/Client/RequestOptions/ServiceBookPriceServiceOptions.php b/src/Amadeus/Client/RequestOptions/ServiceBookPriceServiceOptions.php new file mode 100644 index 000000000..96d42b9cb --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/ServiceBookPriceServiceOptions.php @@ -0,0 +1,57 @@ + + */ +class ServiceBookPriceServiceOptions extends Base +{ + + /** + * Booking carrier of the service + * + * @var string + */ + public $serviceProvider; + + /** + * + * @var Identifier + */ + public $identifier; + + /** + * Request ID + * @var string + */ + public $TID; +} diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService.php b/src/Amadeus/Client/Struct/Service/BookPriceService.php new file mode 100644 index 000000000..e9b751bb8 --- /dev/null +++ b/src/Amadeus/Client/Struct/Service/BookPriceService.php @@ -0,0 +1,51 @@ + + */ +class BookPriceService extends BaseWsMessage +{ + /** + * @var Product + */ + public $Product; + + /** + * BookPriceService constructor. + * + * @param ServiceBookPriceServiceOptions $options + */ + public function __construct($options) + { + $this->Product = new Product($options); + } +} diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php new file mode 100644 index 000000000..7d334581f --- /dev/null +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php @@ -0,0 +1,75 @@ + + */ +class Identifier +{ + /** + * @var int + */ + public $bookingMethod; + + /** + * @var string|null + */ + public $RFIC = null; + + /** + * @var string|null + */ + public $RFISC = null; + + /** + * @var string|null + */ + public $Code = null; + + /** + * Identifier constructor. + * + * @param Identifier $identifierOptions + */ + public function __construct($identifierOptions) + { + $this->bookingMethod = $identifierOptions->bookingMethod; + + if($identifierOptions->code) { + $this->Code = $identifierOptions->code; + } + + if($identifierOptions->RFISC) { + $this->RFISC = $identifierOptions->RFISC; + } + + if($identifierOptions->RFIC) { + $this->RFIC = $identifierOptions->RFIC; + } + } +} diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Product.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Product.php new file mode 100644 index 000000000..7aaaab183 --- /dev/null +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Product.php @@ -0,0 +1,48 @@ + + */ +class Product +{ + /** + * @var Service + */ + public $Service; + + /** + * Product constructor. + * + * @param ServiceBookPriceServiceOptions $options + */ + public function __construct($options) + { + $this->Service = new Service($options); + } +} diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php new file mode 100644 index 000000000..46d8dd8ff --- /dev/null +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php @@ -0,0 +1,61 @@ + + */ +class Service +{ + /** + * @var string + */ + public $TID; + + /** + * @var Identifier + */ + public $Identifier; + + /** + * @var ServiceProvider + */ + public $serviceProvider; + + /** + * Service constructor. + * + * @param ServiceBookPriceServiceOptions $options + */ + public function __construct($options) + { + $this->TID = $options->TID; + $this->Identifier = new Identifier($options->identifier); + $this->serviceProvider = new ServiceProvider($options->serviceProvider); + } +} diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/ServiceProvider.php b/src/Amadeus/Client/Struct/Service/BookPriceService/ServiceProvider.php new file mode 100644 index 000000000..3dc4eaecf --- /dev/null +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/ServiceProvider.php @@ -0,0 +1,46 @@ + + */ +class ServiceProvider +{ + /** + * @var string + */ + public $code; + + /** + * ServiceProvider constructor. + * + * @param string $code + */ + public function __construct($code) + { + $this->code = $code; + } +} From 5f137c2ed823f31b67344c49bb8bc4c25c45bfe9 Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Wed, 18 Dec 2019 17:58:30 +0100 Subject: [PATCH 07/15] Fix --- .../Client/Struct/Service/BookPriceService/Identifier.php | 4 ++-- .../Client/Struct/Service/BookPriceService/Product.php | 2 +- .../Client/Struct/Service/BookPriceService/Service.php | 2 +- .../Struct/Service/BookPriceService/ServiceProvider.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php index 7d334581f..5e606d0e2 100644 --- a/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php @@ -19,7 +19,7 @@ * @package Amadeus * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0 */ -namespace Amadeus\Client\Struct\Service\StandaloneCatalogue; +namespace Amadeus\Client\Struct\Service\BookPriceService; use Amadeus\Client\RequestOptions\Service\BookPriceService\Identifier; @@ -59,7 +59,7 @@ class Identifier public function __construct($identifierOptions) { $this->bookingMethod = $identifierOptions->bookingMethod; - + if($identifierOptions->code) { $this->Code = $identifierOptions->code; } diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Product.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Product.php index 7aaaab183..f2e9e0dfd 100644 --- a/src/Amadeus/Client/Struct/Service/BookPriceService/Product.php +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Product.php @@ -19,7 +19,7 @@ * @package Amadeus * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0 */ -namespace Amadeus\Client\Struct\Service\StandaloneCatalogue; +namespace Amadeus\Client\Struct\Service\BookPriceService; use Amadeus\Client\Struct\Service\BookPriceService\Service; diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php index 46d8dd8ff..b8d70c3db 100644 --- a/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php @@ -19,7 +19,7 @@ * @package Amadeus * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0 */ -namespace Amadeus\Client\Struct\Service\StandaloneCatalogue; +namespace Amadeus\Client\Struct\Service\BookPriceService; use Amadeus\Client\Struct\Service\BookPriceService\Identifier; use Amadeus\Client\Struct\Service\BookPriceService\ServiceProvider; diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/ServiceProvider.php b/src/Amadeus/Client/Struct/Service/BookPriceService/ServiceProvider.php index 3dc4eaecf..8c65d6ff8 100644 --- a/src/Amadeus/Client/Struct/Service/BookPriceService/ServiceProvider.php +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/ServiceProvider.php @@ -19,7 +19,7 @@ * @package Amadeus * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0 */ -namespace Amadeus\Client\Struct\Service\StandaloneCatalogue; +namespace Amadeus\Client\Struct\Service\BookPriceService; /** * ServiceProvider From 8b467e816bc388c4402d36a30cc9238206391ea1 Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Wed, 18 Dec 2019 18:06:26 +0100 Subject: [PATCH 08/15] Fix --- .../Client/Struct/Service/BookPriceService/Identifier.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php index 5e606d0e2..2a6eff805 100644 --- a/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php @@ -21,8 +21,6 @@ */ namespace Amadeus\Client\Struct\Service\BookPriceService; -use Amadeus\Client\RequestOptions\Service\BookPriceService\Identifier; - /** * Identifier * From cf38caebd241489172284db4e5eefcfa2811d567 Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Wed, 18 Dec 2019 23:11:30 +0100 Subject: [PATCH 09/15] Fix identifier error --- .../Client/Struct/Service/BookPriceService/Service.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php index b8d70c3db..620610074 100644 --- a/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php @@ -40,7 +40,7 @@ class Service /** * @var Identifier */ - public $Identifier; + public $identifier; /** * @var ServiceProvider @@ -55,7 +55,7 @@ class Service public function __construct($options) { $this->TID = $options->TID; - $this->Identifier = new Identifier($options->identifier); + $this->identifier = new Identifier($options->identifier); $this->serviceProvider = new ServiceProvider($options->serviceProvider); } } From 1493af22848a7222f533ad74da913c61c539246a Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Thu, 19 Dec 2019 14:12:28 +0100 Subject: [PATCH 10/15] Added tests --- .../Service/HandlerBookPriceService.php | 71 ++++++++++++++++ .../Client/ResponseHandler/BaseTest.php | 19 +++++ .../serviceBookPriceServiceErrorReply.txt | 10 +++ .../Struct/Service/BookPriceServiceTest.php | 80 +++++++++++++++++++ tests/Amadeus/ClientTest.php | 50 ++++++++++++ .../serviceBookPriceServiceReply.txt | 12 +++ 6 files changed, 242 insertions(+) create mode 100644 src/Amadeus/Client/ResponseHandler/Service/HandlerBookPriceService.php create mode 100644 tests/Amadeus/Client/ResponseHandler/testfiles/serviceBookPriceServiceErrorReply.txt create mode 100644 tests/Amadeus/Client/Struct/Service/BookPriceServiceTest.php create mode 100644 tests/Amadeus/testfiles/serviceBookPriceServiceReply.txt diff --git a/src/Amadeus/Client/ResponseHandler/Service/HandlerBookPriceService.php b/src/Amadeus/Client/ResponseHandler/Service/HandlerBookPriceService.php new file mode 100644 index 000000000..460241b82 --- /dev/null +++ b/src/Amadeus/Client/ResponseHandler/Service/HandlerBookPriceService.php @@ -0,0 +1,71 @@ + + */ +class HandlerBookPriceService extends StandardResponseHandler +{ + /** + * @param SendResult $response + * @return Result + */ + public function analyze(SendResult $response) + { + $analyzeResponse = new Result($response); + $domXpath = $this->makeDomXpath($response->responseXml); + + $errorCodeNodeList = $domXpath->query("//ama:Error"); + + if ($errorCodeNodeList->length > 0) { + $analyzeResponse->status = Result::STATUS_ERROR; + + $errorCatNode = $errorCodeNodeList->item(0); + foreach (iterator_to_array($errorCodeNodeList) as $msg) { + $analyzeResponse->messages[] = new Result\NotOk( + $msg->getAttribute('Code'), + trim($msg->getAttribute('ShortText')) + ); + } + + return $analyzeResponse; + } + + $success = $domXpath->query('//m:Success'); + if ($success->length > 0) { + $analyzeResponse->status = Result::STATUS_OK; + return $analyzeResponse; + } + + $analyzeResponse->status = Result::STATUS_UNKNOWN; + return $analyzeResponse; + } +} diff --git a/tests/Amadeus/Client/ResponseHandler/BaseTest.php b/tests/Amadeus/Client/ResponseHandler/BaseTest.php index 9da79f606..22023418a 100644 --- a/tests/Amadeus/Client/ResponseHandler/BaseTest.php +++ b/tests/Amadeus/Client/ResponseHandler/BaseTest.php @@ -1548,6 +1548,25 @@ public function testCanHandleSalesReportsDisplayNetRemitReport() $this->assertEquals("NO DATA FOUND", $result->messages[0]->text); } + public function testCanHandleServiceBookPriceServiceError() + { + $respHandler = new ResponseHandler\Base(); + + $sendResult = new SendResult(); + $sendResult->responseXml = $this->getTestFile('serviceBookPriceServiceErrorReply.txt'); + + $result = $respHandler->analyzeResponse($sendResult, 'Service_BookPriceService'); + + $this->assertEquals(Result::STATUS_ERROR, $result->status); + $this->assertEquals(2, count($result->messages)); + + $this->assertEquals('1', $result->messages[0]->code); + $this->assertEquals("CHECK FORMAT", $result->messages[0]->text); + + $this->assertEquals('33017', $result->messages[1]->code); + $this->assertEquals("SHOPPING BOX REJECT", $result->messages[1]->text); + } + public function testCanHandleServiceIntegratedPricing() { $respHandler = new ResponseHandler\Base(); diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/serviceBookPriceServiceErrorReply.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/serviceBookPriceServiceErrorReply.txt new file mode 100644 index 000000000..91cdc495f --- /dev/null +++ b/tests/Amadeus/Client/ResponseHandler/testfiles/serviceBookPriceServiceErrorReply.txt @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/tests/Amadeus/Client/Struct/Service/BookPriceServiceTest.php b/tests/Amadeus/Client/Struct/Service/BookPriceServiceTest.php new file mode 100644 index 000000000..6f6dd93c0 --- /dev/null +++ b/tests/Amadeus/Client/Struct/Service/BookPriceServiceTest.php @@ -0,0 +1,80 @@ + + */ +class BookPriceServiceTest extends BaseTestCase +{ + public function testCanMakeMessageRFIC() + { + $opt = new ServiceBookPriceServiceOptions([ + 'TID' => 'R1', + 'serviceProvider' => 'LH', + 'identifier' => new Identifier([ + 'bookingMethod' => 1, + 'RFIC' => 'F', + 'RFISC' => '040' + ]) + ]); + + $msg = new BookPriceService($opt); + + $this->assertEquals('1', $msg->Product->Service->identifier->bookingMethod); + $this->assertEquals('F', $msg->Product->Service->identifier->RFIC); + $this->assertEquals('040', $msg->Product->Service->identifier->RFISC); + $this->assertEmpty($msg->Product->Service->identifier->Code); + $this->assertEquals('LH', $msg->Product->Service->serviceProvider->code); + $this->assertEquals('R1', $msg->Product->Service->TID); + } + public function testCanMakeMessageCode() + { + $opt = new ServiceBookPriceServiceOptions([ + 'TID' => 'R1', + 'serviceProvider' => 'LH', + 'identifier' => new Identifier([ + 'bookingMethod' => 1, + 'code' => 'OXY', + ]) + ]); + + $msg = new BookPriceService($opt); + + $this->assertEquals('1', $msg->Product->Service->identifier->bookingMethod); + $this->assertEmpty($msg->Product->Service->identifier->RFIC); + $this->assertEmpty($msg->Product->Service->identifier->RFISC); + $this->assertEquals('OXY', $msg->Product->Service->identifier->Code); + $this->assertEquals('LH', $msg->Product->Service->serviceProvider->code); + $this->assertEquals('R1', $msg->Product->Service->TID); + } +} diff --git a/tests/Amadeus/ClientTest.php b/tests/Amadeus/ClientTest.php index 2398b3c2a..c5e13e794 100644 --- a/tests/Amadeus/ClientTest.php +++ b/tests/Amadeus/ClientTest.php @@ -4319,6 +4319,56 @@ public function testCanSendServiceIntegratedCatalogue() $this->assertEquals($messageResult, $response); } + public function testCanSendServiceBookPriceService() + { + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $mockedSendResult = new Client\Session\Handler\SendResult(); + $mockedSendResult->responseXml = $this->getTestFile('serviceBookPriceServiceReply.txt'); + + $messageResult = new Client\Result($mockedSendResult); + + $opts = new Client\RequestOptions\ServiceBookPriceServiceOptions([ + 'TID' => 1, + 'serviceProvider' => 'LH', + 'identifier' => new Client\RequestOptions\Service\BookPriceService\Identifier([ + 'bookingMethod' => 1, + 'RFIC' => 'F', + 'RFISC' => '040' + ]) + ]); + $expectedMessageResult = new Client\Struct\Service\BookPriceService($opts); + + $mockSessionHandler + ->expects($this->once()) + ->method('sendMessage') + ->with('Service_BookPriceService', $expectedMessageResult, ['endSession' => false, 'returnXml' => true]) + ->will($this->returnValue($mockedSendResult));; + $mockSessionHandler + ->expects($this->never()) + ->method('getLastResponse'); + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->will($this->returnValue(['Service_BookPriceService' => ['version' => "14.2", 'wsdl' => 'dc22e4ee']])); + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'BRUXXXXXX' + ]); + + $client = new Client($par); + + + $response = $client->serviceBookPriceService( + new Client\RequestOptions\ServiceBookPriceServiceOptions($opts) + ); + + $this->assertEquals($messageResult, $response); + } + public function testCanSendServiceStandaloneCatalogue() { $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); diff --git a/tests/Amadeus/testfiles/serviceBookPriceServiceReply.txt b/tests/Amadeus/testfiles/serviceBookPriceServiceReply.txt new file mode 100644 index 000000000..e74cf8c77 --- /dev/null +++ b/tests/Amadeus/testfiles/serviceBookPriceServiceReply.txt @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file From d331194e5043f89f08ee6b4e123534241017cfc2 Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Thu, 19 Dec 2019 14:24:44 +0100 Subject: [PATCH 11/15] Formatting --- .../Service/BookPriceService/Identifier.php | 2 +- .../ServiceBookPriceServiceOptions.php | 3 -- .../Struct/Service/BookPriceService.php | 2 +- .../Service/BookPriceService/Identifier.php | 12 ++++---- .../Service/BookPriceService/Service.php | 28 +++++++++---------- .../Client/ResponseHandler/BaseTest.php | 9 ++---- .../Struct/Service/BookPriceServiceTest.php | 20 ++++++------- 7 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/Amadeus/Client/RequestOptions/Service/BookPriceService/Identifier.php b/src/Amadeus/Client/RequestOptions/Service/BookPriceService/Identifier.php index 1f10ceaa9..bbeab8858 100644 --- a/src/Amadeus/Client/RequestOptions/Service/BookPriceService/Identifier.php +++ b/src/Amadeus/Client/RequestOptions/Service/BookPriceService/Identifier.php @@ -34,7 +34,7 @@ class Identifier extends LoadParamsFromArray { const BOOKING_METHOD_SSR = 1; const BOOKING_METHOD_SVC = 2; - + /** * self::BOOKING_METHOD_* * diff --git a/src/Amadeus/Client/RequestOptions/ServiceBookPriceServiceOptions.php b/src/Amadeus/Client/RequestOptions/ServiceBookPriceServiceOptions.php index 96d42b9cb..32b03920e 100644 --- a/src/Amadeus/Client/RequestOptions/ServiceBookPriceServiceOptions.php +++ b/src/Amadeus/Client/RequestOptions/ServiceBookPriceServiceOptions.php @@ -22,9 +22,6 @@ namespace Amadeus\Client\RequestOptions; -use Amadeus\Client\RequestOptions\Service\FormOfPayment; -use Amadeus\Client\RequestOptions\Service\FrequentFlyer; -use Amadeus\Client\RequestOptions\Service\PaxSegRef; use Amadeus\Client\RequestOptions\Service\BookPriceService\Identifier; /** diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService.php b/src/Amadeus/Client/Struct/Service/BookPriceService.php index e9b751bb8..898e8b758 100644 --- a/src/Amadeus/Client/Struct/Service/BookPriceService.php +++ b/src/Amadeus/Client/Struct/Service/BookPriceService.php @@ -23,8 +23,8 @@ namespace Amadeus\Client\Struct\Service; use Amadeus\Client\RequestOptions\ServiceBookPriceServiceOptions; -use Amadeus\Client\Struct\Service\BookPriceService\Product; use Amadeus\Client\Struct\BaseWsMessage; +use Amadeus\Client\Struct\Service\BookPriceService\Product; /** * Service_BookPriceService request structure diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php index 2a6eff805..a557acb84 100644 --- a/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php @@ -58,16 +58,16 @@ public function __construct($identifierOptions) { $this->bookingMethod = $identifierOptions->bookingMethod; - if($identifierOptions->code) { - $this->Code = $identifierOptions->code; + if ($identifierOptions->code) { + $this->Code = $identifierOptions->code; } - if($identifierOptions->RFISC) { - $this->RFISC = $identifierOptions->RFISC; + if ($identifierOptions->RFISC) { + $this->RFISC = $identifierOptions->RFISC; } - if($identifierOptions->RFIC) { - $this->RFIC = $identifierOptions->RFIC; + if ($identifierOptions->RFIC) { + $this->RFIC = $identifierOptions->RFIC; } } } diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php index 620610074..a3a46345e 100644 --- a/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php @@ -32,20 +32,20 @@ */ class Service { - /** - * @var string - */ - public $TID; - - /** - * @var Identifier - */ - public $identifier; - - /** - * @var ServiceProvider - */ - public $serviceProvider; + /** + * @var string + */ + public $TID; + + /** + * @var Identifier + */ + public $identifier; + + /** + * @var ServiceProvider + */ + public $serviceProvider; /** * Service constructor. diff --git a/tests/Amadeus/Client/ResponseHandler/BaseTest.php b/tests/Amadeus/Client/ResponseHandler/BaseTest.php index 22023418a..1cfa90a12 100644 --- a/tests/Amadeus/Client/ResponseHandler/BaseTest.php +++ b/tests/Amadeus/Client/ResponseHandler/BaseTest.php @@ -22,10 +22,10 @@ namespace Test\Amadeus\Client\ResponseHandler; +use Amadeus\Client\ResponseHandler; use Amadeus\Client\Result; use Amadeus\Client\Session\Handler\SendResult; use Test\Amadeus\BaseTestCase; -use Amadeus\Client\ResponseHandler; /** * BaseTest @@ -838,8 +838,6 @@ public function testCanHandleFareMasterPricerExpertSearchError() $this->assertEquals("Past date/time not allowed", $result->messages[0]->text); } - - public function testCanHandleFareMasterPricerCalendarError() { $respHandler = new ResponseHandler\Base(); @@ -960,7 +958,6 @@ public function testCanHandleFareCheckRulesError() $this->assertEquals("ENTRY REQUIRES PREVIOUS PRICING/FARE DISPLAY REQUEST", $result->messages[0]->text); } - public function testCanHandleFareGetFareRulesError() { $respHandler = new ResponseHandler\Base(); @@ -1096,7 +1093,6 @@ public function testCanHandleDocRefundInitRefundErrorResponse() $this->assertEquals("ATC REFUND NOT AUTHORIZED", $result->messages[0]->text); } - public function testCanHandleDocRefundUpdateRefundErrorResponse() { $respHandler = new ResponseHandler\Base(); @@ -1428,7 +1424,6 @@ public function testCanHandleMiniRuleGetFromPricingErrorResponse() $this->assertEquals("RESTRICTED", $result->messages[0]->text); } - public function testCanHandleMiniRuleGetFromETicketErrorResponse() { $respHandler = new ResponseHandler\Base(); @@ -1559,7 +1554,7 @@ public function testCanHandleServiceBookPriceServiceError() $this->assertEquals(Result::STATUS_ERROR, $result->status); $this->assertEquals(2, count($result->messages)); - + $this->assertEquals('1', $result->messages[0]->code); $this->assertEquals("CHECK FORMAT", $result->messages[0]->text); diff --git a/tests/Amadeus/Client/Struct/Service/BookPriceServiceTest.php b/tests/Amadeus/Client/Struct/Service/BookPriceServiceTest.php index 6f6dd93c0..ee9ae433a 100644 --- a/tests/Amadeus/Client/Struct/Service/BookPriceServiceTest.php +++ b/tests/Amadeus/Client/Struct/Service/BookPriceServiceTest.php @@ -1,4 +1,5 @@ 'R1', 'serviceProvider' => 'LH', 'identifier' => new Identifier([ - 'bookingMethod' => 1, - 'RFIC' => 'F', - 'RFISC' => '040' - ]) + 'bookingMethod' => 1, + 'RFIC' => 'F', + 'RFISC' => '040', + ]), ]); $msg = new BookPriceService($opt); @@ -63,9 +63,9 @@ public function testCanMakeMessageCode() 'TID' => 'R1', 'serviceProvider' => 'LH', 'identifier' => new Identifier([ - 'bookingMethod' => 1, - 'code' => 'OXY', - ]) + 'bookingMethod' => 1, + 'code' => 'OXY', + ]), ]); $msg = new BookPriceService($opt); From c0506d515d7254402b5dcd8e276fb683d63211f2 Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Thu, 19 Dec 2019 14:28:33 +0100 Subject: [PATCH 12/15] Formatting --- .../Fare/MasterPricer/FlightInfoPNR.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php index 89c976e2f..4b0412ad7 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightInfoPNR.php @@ -21,6 +21,7 @@ */ namespace Amadeus\Client\Struct\Fare\MasterPricer; + use Amadeus\Client\RequestOptions\Air\SellFromRecommendation\Segment as SegmentOptions; /** @@ -45,18 +46,17 @@ class FlightInfoPNR */ public function __construct(SegmentOptions $seg) { - $this->travelResponseDetails = new TravelResponseDetails( - $seg->departureDate, - $seg->from, - $seg->to, - $seg->companyCode, - $seg->flightNumber, - $seg->bookingClass, - $seg->arrivalDate, - $seg->arrivalTime, - $seg->dateVariation, - $seg->flightTypeDetails - ); + $seg->departureDate, + $seg->from, + $seg->to, + $seg->companyCode, + $seg->flightNumber, + $seg->bookingClass, + $seg->arrivalDate, + $seg->arrivalTime, + $seg->dateVariation, + $seg->flightTypeDetails + ); } } From 636f709d7e5ee23ccc8bf84402d98f94826a5f7e Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Thu, 19 Dec 2019 16:13:23 +0100 Subject: [PATCH 13/15] Fixed scrutinizer issues --- .../Service/HandlerBookPriceService.php | 1 - src/Amadeus/Client/Struct/Air/FlightDate.php | 6 +- .../Struct/Air/TravelProductInformation.php | 6 +- .../Struct/Fare/MasterPricer/FlightDate.php | 100 +----------------- .../MasterPricer/TravelResponseDetails.php | 71 ++----------- .../Service/BookPriceService/Identifier.php | 10 +- .../Service/BookPriceService/Product.php | 1 + .../Service/BookPriceService/Service.php | 1 + 8 files changed, 27 insertions(+), 169 deletions(-) diff --git a/src/Amadeus/Client/ResponseHandler/Service/HandlerBookPriceService.php b/src/Amadeus/Client/ResponseHandler/Service/HandlerBookPriceService.php index 460241b82..cd840d44b 100644 --- a/src/Amadeus/Client/ResponseHandler/Service/HandlerBookPriceService.php +++ b/src/Amadeus/Client/ResponseHandler/Service/HandlerBookPriceService.php @@ -48,7 +48,6 @@ public function analyze(SendResult $response) if ($errorCodeNodeList->length > 0) { $analyzeResponse->status = Result::STATUS_ERROR; - $errorCatNode = $errorCodeNodeList->item(0); foreach (iterator_to_array($errorCodeNodeList) as $msg) { $analyzeResponse->messages[] = new Result\NotOk( $msg->getAttribute('Code'), diff --git a/src/Amadeus/Client/Struct/Air/FlightDate.php b/src/Amadeus/Client/Struct/Air/FlightDate.php index 1e973ca29..b56282844 100644 --- a/src/Amadeus/Client/Struct/Air/FlightDate.php +++ b/src/Amadeus/Client/Struct/Air/FlightDate.php @@ -30,6 +30,8 @@ */ class FlightDate { + protected $dateFormat = 'dmy'; + /** * DDMMYY * @@ -84,7 +86,7 @@ public function __construct($departureDate, $arrivalDate = null, $arrivalTime = protected function loadDepartureDate($departureDate) { if ($departureDate instanceof \DateTime) { - $this->departureDate = ($departureDate->format('dmy') !== '000000') ? $departureDate->format('dmy') : null; + $this->departureDate = ($departureDate->format('dmy') !== '000000') ? $departureDate->format($this->dateFormat) : null; $time = $departureDate->format('Hi'); if ($time !== '0000') { $this->departureTime = $time; @@ -119,7 +121,7 @@ protected function loadArrivalDate($arrivalDate, $arrivalTime) */ public function setArrivalDate(\DateTime $arrivalDate) { - $this->arrivalDate = ($arrivalDate->format('dmy') !== '000000') ? $arrivalDate->format('dmy') : null; + $this->arrivalDate = ($arrivalDate->format('dmy') !== '000000') ? $arrivalDate->format($this->dateFormat) : null; $time = $arrivalDate->format('Hi'); if ($time !== '0000') { $this->arrivalTime = $time; diff --git a/src/Amadeus/Client/Struct/Air/TravelProductInformation.php b/src/Amadeus/Client/Struct/Air/TravelProductInformation.php index 913b1cc83..7b994d6fd 100644 --- a/src/Amadeus/Client/Struct/Air/TravelProductInformation.php +++ b/src/Amadeus/Client/Struct/Air/TravelProductInformation.php @@ -148,7 +148,7 @@ public function __construct( $dateVariation = null, $flightTypeDetails = null ) { - $this->flightDate = new FlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation); + $this->flightDate = $this->parseFlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation); $this->boardPointDetails = new PointDetails($from); $this->offpointDetails = new PointDetails($to); $this->companyDetails = new CompanyDetails($company); @@ -157,4 +157,8 @@ public function __construct( $this->flightTypeDetails = new FlightTypeDetails($flightTypeDetails); } } + + protected function parseFlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation) { + return new FlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation); + } } diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightDate.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightDate.php index f82b78e9c..3c43a136d 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightDate.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/FlightDate.php @@ -22,107 +22,15 @@ namespace Amadeus\Client\Struct\Fare\MasterPricer; +use Amadeus\Client\Struct\Air; + /** * FlightDate * * @package Amadeus\Client\Struct\Fare\MasterPricer * @author Mike Hernas */ -class FlightDate +class FlightDate extends Air\FlightDate { - /** - * DDMMYY - * - * @var string - */ - public $departureDate; - /** - * HHMM - * - * @var string - */ - public $departureTime; - /** - * DDMMYY - * - * @var string - */ - public $arrivalDate; - /** - * HHMM - * - * @var string - */ - public $arrivalTime; - /** - * @var string|int - */ - public $dateVariation; - - /** - * FlightDate constructor. - * - * @param string|\DateTime|null $departureDate in format DDMMYY or \DateTime - * @param \DateTime|null $arrivalDate - * @param string|\DateTime|null $arrivalTime - * @param int|null $dateVariation - */ - public function __construct($departureDate, $arrivalDate = null, $arrivalTime = null, $dateVariation = null) - { - $this->loadDepartureDate($departureDate); - - $this->loadArrivalDate($arrivalDate, $arrivalTime); - - if (!is_null($dateVariation)) { - $this->dateVariation = $dateVariation; - } - } - - /** - * @param \DateTime|string|null $departureDate - */ - protected function loadDepartureDate($departureDate) - { - if ($departureDate instanceof \DateTime) { - $this->departureDate = ($departureDate->format('dmy') !== '000000') ? $departureDate->format('Ymd') : null; - $time = $departureDate->format('Hi'); - if ($time !== '0000') { - $this->departureTime = $time; - } - } elseif (!empty($departureDate)) { - $this->departureDate = $departureDate; - } - } - - /** - * @param \DateTime|null $arrivalDate - * @param string|\DateTime|null $arrivalTime - */ - protected function loadArrivalDate($arrivalDate, $arrivalTime) - { - if ($arrivalDate instanceof \DateTime) { - $this->setArrivalDate($arrivalDate); - } elseif ($arrivalTime instanceof \DateTime) { - $time = $arrivalTime->format('Hi'); - if ($time !== '0000') { - $this->arrivalTime = $time; - } - } elseif (is_string($arrivalTime) && !empty($arrivalTime)) { - $this->arrivalTime = $arrivalTime; - } - } - - /** - * Load Arrival date info from \DateTime - * - * @param \DateTime $arrivalDate - */ - public function setArrivalDate(\DateTime $arrivalDate) - { - $this->arrivalDate = ($arrivalDate->format('dmy') !== '000000') ? $arrivalDate->format('Ymd') : null; - $time = $arrivalDate->format('Hi'); - if ($time !== '0000') { - $this->arrivalTime = $time; - } - } + protected $dateFormat = 'Ymd'; } diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php index 6a16f3f14..020b21880 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php @@ -22,78 +22,19 @@ namespace Amadeus\Client\Struct\Fare\MasterPricer; -use Amadeus\Client\Struct\Air\PointDetails; -use Amadeus\Client\Struct\Air\CompanyDetails; -use Amadeus\Client\Struct\Air\FlightIdentification; -use Amadeus\Client\Struct\Air\FlightTypeDetails; - +use Amadeus\Client\Struct\Air; /** * TravelResponseDetails * * @package Amadeus\Client\Struct\Fare\MasterPricer * @author Mike Hernas */ -class TravelResponseDetails +class TravelResponseDetails extends Air\TravelProductInformation { - /** - * @var FlightDate - */ - public $flightDate; - /** - * @var PointDetails - */ - public $boardPointDetails; - /** - * @var PointDetails - */ - public $offpointDetails; - /** - * @var CompanyDetails - */ - public $companyDetails; - /** - * @var FlightIdentification - */ - public $flightIdentification; - /** - * @var FlightTypeDetails - */ - public $flightTypeDetails; - - /** - * TravelProductInformation constructor. - * - * @param \DateTime $departureDate - * @param string $from - * @param string $to - * @param string $company - * @param string $flightNumber - * @param string $bookingClass - * @param \DateTime|null $arrivalDate - * @param string|\DateTime|null $arrivalTime - * @param int|null $dateVariation - * @param string|null $flightTypeDetails - */ - public function __construct( - $departureDate, - $from, - $to, - $company, - $flightNumber, - $bookingClass, - $arrivalDate = null, - $arrivalTime = null, - $dateVariation = null, - $flightTypeDetails = null - ) { - $this->flightDate = new FlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation); - $this->boardPointDetails = new PointDetails($from); - $this->offpointDetails = new PointDetails($to); - $this->companyDetails = new CompanyDetails($company); - $this->flightIdentification = new FlightIdentification($flightNumber, $bookingClass); - if (!is_null($flightTypeDetails)) { - $this->flightTypeDetails = new FlightTypeDetails($flightTypeDetails); - } + protected function parseFlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation) { + // We are using Amadeus\Client\Struct\Fare\MasterPricer\FlightDate + return new FlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation); } + } diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php index a557acb84..c7eceff29 100644 --- a/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Identifier.php @@ -21,6 +21,8 @@ */ namespace Amadeus\Client\Struct\Service\BookPriceService; +use Amadeus\Client\RequestOptions\Service\BookPriceService\Identifier as IdentifierOptions; + /** * Identifier * @@ -52,21 +54,21 @@ class Identifier /** * Identifier constructor. * - * @param Identifier $identifierOptions + * @param IdentifierOptions $identifierOptions */ public function __construct($identifierOptions) { $this->bookingMethod = $identifierOptions->bookingMethod; - if ($identifierOptions->code) { + if (!empty($identifierOptions->code)) { $this->Code = $identifierOptions->code; } - if ($identifierOptions->RFISC) { + if (!empty($identifierOptions->RFISC)) { $this->RFISC = $identifierOptions->RFISC; } - if ($identifierOptions->RFIC) { + if (!empty($identifierOptions->RFIC)) { $this->RFIC = $identifierOptions->RFIC; } } diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Product.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Product.php index f2e9e0dfd..5e09289c6 100644 --- a/src/Amadeus/Client/Struct/Service/BookPriceService/Product.php +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Product.php @@ -22,6 +22,7 @@ namespace Amadeus\Client\Struct\Service\BookPriceService; use Amadeus\Client\Struct\Service\BookPriceService\Service; +use Amadeus\Client\RequestOptions\ServiceBookPriceServiceOptions; /** * Product diff --git a/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php b/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php index a3a46345e..9bde51d55 100644 --- a/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php +++ b/src/Amadeus/Client/Struct/Service/BookPriceService/Service.php @@ -23,6 +23,7 @@ use Amadeus\Client\Struct\Service\BookPriceService\Identifier; use Amadeus\Client\Struct\Service\BookPriceService\ServiceProvider; +use Amadeus\Client\RequestOptions\ServiceBookPriceServiceOptions; /** * Service From 31e805c72ba2c0f8c8569085db4eb240a5da9445 Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Thu, 19 Dec 2019 16:15:15 +0100 Subject: [PATCH 14/15] Fix styling --- src/Amadeus/Client/Struct/Air/TravelProductInformation.php | 3 ++- .../Struct/Fare/MasterPricer/TravelResponseDetails.php | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Amadeus/Client/Struct/Air/TravelProductInformation.php b/src/Amadeus/Client/Struct/Air/TravelProductInformation.php index 7b994d6fd..279a036a3 100644 --- a/src/Amadeus/Client/Struct/Air/TravelProductInformation.php +++ b/src/Amadeus/Client/Struct/Air/TravelProductInformation.php @@ -158,7 +158,8 @@ public function __construct( } } - protected function parseFlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation) { + protected function parseFlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation) + { return new FlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation); } } diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php index 020b21880..0205dce5e 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php @@ -23,6 +23,7 @@ namespace Amadeus\Client\Struct\Fare\MasterPricer; use Amadeus\Client\Struct\Air; + /** * TravelResponseDetails * @@ -32,9 +33,10 @@ class TravelResponseDetails extends Air\TravelProductInformation { - protected function parseFlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation) { + protected function parseFlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation) + { // We are using Amadeus\Client\Struct\Fare\MasterPricer\FlightDate return new FlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation); } - + } From d006266bda5f0259cf23e5c71f2d0d77847e929d Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Thu, 19 Dec 2019 16:16:55 +0100 Subject: [PATCH 15/15] Fix styling again --- .../Client/Struct/Fare/MasterPricer/TravelResponseDetails.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php index 0205dce5e..2c8448355 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/TravelResponseDetails.php @@ -32,11 +32,9 @@ */ class TravelResponseDetails extends Air\TravelProductInformation { - protected function parseFlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation) { // We are using Amadeus\Client\Struct\Fare\MasterPricer\FlightDate return new FlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation); } - }