diff --git a/src/Amadeus/Client/RequestOptions/PnrCancelOptions.php b/src/Amadeus/Client/RequestOptions/PnrCancelOptions.php index f5976e05b..480f8a776 100644 --- a/src/Amadeus/Client/RequestOptions/PnrCancelOptions.php +++ b/src/Amadeus/Client/RequestOptions/PnrCancelOptions.php @@ -36,7 +36,6 @@ class PnrCancelOptions extends PnrBase */ public $recordLocator; - /** * How to handle the PNR after doing the Cancel operation * @@ -95,4 +94,11 @@ class PnrCancelOptions extends PnrBase * @var int[] */ public $groupPassengers = []; + + /** + * All tattoos of PNR Segments to be removed + * + * @var int[] + */ + public $segments = []; } diff --git a/src/Amadeus/Client/Struct/Pnr/Cancel.php b/src/Amadeus/Client/Struct/Pnr/Cancel.php index 8c101a3f5..4c3412ecd 100644 --- a/src/Amadeus/Client/Struct/Pnr/Cancel.php +++ b/src/Amadeus/Client/Struct/Pnr/Cancel.php @@ -78,6 +78,16 @@ public function __construct(PnrCancelOptions $params) $this->cancelElements[] = $tmp; } + if (!empty($params->segments)) { + $tmp = new Cancel\Elements(Elements::ENTRY_ELEMENT); + + foreach ($params->segments as $tatoo) { + $tmp->element[] = new Element($tatoo, Element::IDENT_SEGMENT_TATOO); + } + + $this->cancelElements[] = $tmp; + } + if (!empty($params->groupPassengers)) { $tmp = new Cancel\Elements(Elements::ENTRY_NAME_INTEGRATION); diff --git a/tests/Amadeus/Client/Struct/Pnr/CancelTest.php b/tests/Amadeus/Client/Struct/Pnr/CancelTest.php index 4813f4855..6722983ad 100644 --- a/tests/Amadeus/Client/Struct/Pnr/CancelTest.php +++ b/tests/Amadeus/Client/Struct/Pnr/CancelTest.php @@ -129,5 +129,21 @@ public function testCanMakeCancelGroupPassengerMessage() $this->assertEquals(6, $message->cancelElements[0]->element[1]->number); } + public function testCanMakeCancelSegmentsMessage() + { + $message = new Cancel( + new PnrCancelOptions([ + 'actionCode' => 0, + 'segments' => [3,4] + ]) + ); + $this->assertEquals(1, count($message->cancelElements)); + $this->assertEquals(Cancel\Elements::ENTRY_ELEMENT, $message->cancelElements[0]->entryType); + $this->assertEquals(2, count($message->cancelElements[0]->element)); + $this->assertEquals(Cancel\Element::IDENT_SEGMENT_TATOO, $message->cancelElements[0]->element[0]->identifier); + $this->assertEquals(3, $message->cancelElements[0]->element[0]->number); + $this->assertEquals(Cancel\Element::IDENT_SEGMENT_TATOO, $message->cancelElements[0]->element[1]->identifier); + $this->assertEquals(4, $message->cancelElements[0]->element[1]->number); + } }