|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* amadeus-ws-client |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright 2015 Amadeus Benelux NV |
|
6
|
|
|
* |
|
7
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
8
|
|
|
* you may not use this file except in compliance with the License. |
|
9
|
|
|
* You may obtain a copy of the License at |
|
10
|
|
|
* |
|
11
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
12
|
|
|
* |
|
13
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
14
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
15
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16
|
|
|
* See the License for the specific language governing permissions and |
|
17
|
|
|
* limitations under the License. |
|
18
|
|
|
* |
|
19
|
|
|
* @package Amadeus |
|
20
|
|
|
* @license https://opensource.org/licenses/Apache-2.0 Apache 2.0 |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace Amadeus\Client\Struct\Pnr; |
|
24
|
|
|
|
|
25
|
|
|
use Amadeus\Client\RequestOptions\PnrCancelOptions; |
|
26
|
|
|
use Amadeus\Client\Struct\BaseWsMessage; |
|
27
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\PnrActions; |
|
28
|
|
|
use Amadeus\Client\Struct\Pnr\Cancel\Element; |
|
29
|
|
|
use Amadeus\Client\Struct\Pnr\Cancel\Elements; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* PNR_Cancel message structure |
|
33
|
|
|
* |
|
34
|
|
|
* @package Amadeus\Client\Struct\Pnr |
|
35
|
|
|
* @author Dieter Devlieghere <[email protected]> |
|
36
|
|
|
*/ |
|
37
|
|
|
class Cancel extends BaseWsMessage |
|
38
|
|
|
{ |
|
39
|
|
|
/** |
|
40
|
|
|
* @var ReservationInfo |
|
41
|
|
|
*/ |
|
42
|
|
|
public $reservationInfo; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var PnrActions |
|
46
|
|
|
*/ |
|
47
|
|
|
public $pnrActions; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var Cancel\Elements[] |
|
51
|
|
|
*/ |
|
52
|
|
|
public $cancelElements = []; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Cancel constructor. |
|
56
|
|
|
* |
|
57
|
|
|
* @param PnrCancelOptions $params |
|
58
|
|
|
*/ |
|
59
|
|
|
public function __construct(PnrCancelOptions $params) |
|
60
|
|
|
{ |
|
61
|
|
|
if (is_string($params->recordLocator) && strlen($params->recordLocator) >= 6) { |
|
62
|
|
|
$this->reservationInfo = new ReservationInfo($params->recordLocator); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
$this->pnrActions = new PnrActions($params->actionCode); |
|
66
|
|
|
|
|
67
|
|
|
if ($params->cancelItinerary === true) { |
|
68
|
|
|
$this->cancelElements[] = new Cancel\Elements(Elements::ENTRY_ITINERARY); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
$this->loadElements($params); |
|
72
|
|
|
|
|
73
|
|
|
$this->loadSegments($params); |
|
74
|
|
|
|
|
75
|
|
|
$this->loadGroupPassengers($params); |
|
76
|
|
|
|
|
77
|
|
|
$this->loadPassengers($params); |
|
78
|
|
|
|
|
79
|
|
|
$this->loadOffers($params); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param PnrCancelOptions $params |
|
84
|
|
|
* @return void |
|
85
|
|
|
*/ |
|
86
|
|
View Code Duplication |
protected function loadElements(PnrCancelOptions $params) |
|
|
|
|
|
|
87
|
|
|
{ |
|
88
|
|
|
if (!empty($params->elementsByTattoo)) { |
|
89
|
|
|
$tmp = new Cancel\Elements(Elements::ENTRY_ELEMENT); |
|
90
|
|
|
|
|
91
|
|
|
foreach ($params->elementsByTattoo as $tattoo) { |
|
92
|
|
|
$tmp->element[] = new Element($tattoo, Element::IDENT_OTHER_TATTOO); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
$this->cancelElements[] = $tmp; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param PnrCancelOptions $params |
|
101
|
|
|
* @return void |
|
102
|
|
|
*/ |
|
103
|
|
View Code Duplication |
protected function loadSegments(PnrCancelOptions $params) |
|
|
|
|
|
|
104
|
|
|
{ |
|
105
|
|
|
if (!empty($params->segments)) { |
|
106
|
|
|
$tmp = new Cancel\Elements(Elements::ENTRY_ELEMENT); |
|
107
|
|
|
|
|
108
|
|
|
foreach ($params->segments as $tatoo) { |
|
109
|
|
|
$tmp->element[] = new Element($tatoo, Element::IDENT_SEGMENT_TATTOO); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
$this->cancelElements[] = $tmp; |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @param PnrCancelOptions $params |
|
118
|
|
|
* @return void |
|
119
|
|
|
*/ |
|
120
|
|
View Code Duplication |
protected function loadGroupPassengers(PnrCancelOptions $params) |
|
|
|
|
|
|
121
|
|
|
{ |
|
122
|
|
|
if (!empty($params->groupPassengers)) { |
|
123
|
|
|
$tmp = new Cancel\Elements(Elements::ENTRY_NAME_INTEGRATION); |
|
124
|
|
|
|
|
125
|
|
|
foreach ($params->groupPassengers as $offerRef) { |
|
126
|
|
|
$tmp->element[] = new Element($offerRef, Element::IDENT_PASSENGER_TATTOO); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
$this->cancelElements[] = $tmp; |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @param PnrCancelOptions $params |
|
135
|
|
|
* @return void |
|
136
|
|
|
*/ |
|
137
|
|
View Code Duplication |
protected function loadPassengers(PnrCancelOptions $params) |
|
|
|
|
|
|
138
|
|
|
{ |
|
139
|
|
|
if (!empty($params->passengers)) { |
|
140
|
|
|
$tmp = new Cancel\Elements(Elements::ENTRY_ELEMENT); |
|
141
|
|
|
|
|
142
|
|
|
foreach ($params->passengers as $offerRef) { |
|
143
|
|
|
$tmp->element[] = new Element($offerRef, Element::IDENT_PASSENGER_TATTOO); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
$this->cancelElements[] = $tmp; |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @param PnrCancelOptions $params |
|
152
|
|
|
* @return void |
|
153
|
|
|
* |
|
154
|
|
|
*/ |
|
155
|
|
View Code Duplication |
protected function loadOffers(PnrCancelOptions $params) |
|
|
|
|
|
|
156
|
|
|
{ |
|
157
|
|
|
if (!empty($params->offers)) { |
|
158
|
|
|
$tmp = new Cancel\Elements(Elements::ENTRY_ELEMENT); |
|
159
|
|
|
|
|
160
|
|
|
foreach ($params->offers as $offerRef) { |
|
161
|
|
|
$tmp->element[] = new Element($offerRef, Element::IDENT_OFFER_TATTOO); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
$this->cancelElements[] = $tmp; |
|
165
|
|
|
} |
|
166
|
|
|
} |
|
167
|
|
|
} |
|
168
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.