|
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\DocIssuance; |
|
24
|
|
|
|
|
25
|
|
|
use Amadeus\Client\RequestOptions\DocIssuanceIssueTicketOptions; |
|
26
|
|
|
use Amadeus\Client\Struct\BaseWsMessage; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* DocIssuance_IssueTicket |
|
30
|
|
|
* |
|
31
|
|
|
* @package Amadeus\Client\Struct\DocIssuance |
|
32
|
|
|
* @author Dieter Devlieghere <[email protected]> |
|
33
|
|
|
*/ |
|
34
|
|
|
class IssueTicket extends BaseWsMessage |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* @var AgentInfo |
|
38
|
|
|
*/ |
|
39
|
|
|
public $agentInfo; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var OverrideDate |
|
43
|
|
|
*/ |
|
44
|
|
|
public $overrideDate; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var Selection[] |
|
48
|
|
|
*/ |
|
49
|
|
|
public $selection = []; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var PaxSelection[] |
|
53
|
|
|
*/ |
|
54
|
|
|
public $paxSelection = []; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var Stock |
|
58
|
|
|
*/ |
|
59
|
|
|
public $stock; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @var OptionGroup[] |
|
63
|
|
|
*/ |
|
64
|
|
|
public $optionGroup = []; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @var InfantOrAdultAssociation |
|
68
|
|
|
*/ |
|
69
|
|
|
public $infantOrAdultAssociation; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @var OtherCompoundOptions[] |
|
73
|
|
|
*/ |
|
74
|
|
|
public $otherCompoundOptions = []; |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* IssueTicket constructor. |
|
78
|
|
|
* |
|
79
|
|
|
* @param DocIssuanceIssueTicketOptions $options |
|
80
|
|
|
*/ |
|
81
|
|
|
public function __construct(DocIssuanceIssueTicketOptions $options) |
|
82
|
|
|
{ |
|
83
|
|
View Code Duplication |
if (!empty($options->tsts)) { |
|
|
|
|
|
|
84
|
|
|
foreach ($options->tsts as $tst) { |
|
85
|
|
|
$this->addSelectionItem( |
|
86
|
|
|
new ReferenceDetails( |
|
87
|
|
|
$tst, |
|
88
|
|
|
ReferenceDetails::TYPE_TST |
|
89
|
|
|
) |
|
90
|
|
|
); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
$this->loadOverrideDate($options); |
|
95
|
|
|
|
|
96
|
|
|
$this->loadReferences($options); |
|
97
|
|
|
|
|
98
|
|
|
$this->loadOptions($options); |
|
99
|
|
|
|
|
100
|
|
|
if (!empty($options->agentCode)) { |
|
101
|
|
|
$this->agentInfo = new AgentInfo($options->agentCode); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
if (!empty($options->passengerType)) { |
|
105
|
|
|
$this->infantOrAdultAssociation = new InfantOrAdultAssociation($options->passengerType); |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @param ReferenceDetails $ref |
|
111
|
|
|
*/ |
|
112
|
|
|
protected function addSelectionItem(ReferenceDetails $ref) |
|
113
|
|
|
{ |
|
114
|
|
|
if (is_null($this->selection) || empty($this->selection)) { |
|
115
|
|
|
$this->selection[] = new Selection(); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
$this->selection[0]->referenceDetails[] = $ref; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @param DocIssuanceIssueTicketOptions $options |
|
123
|
|
|
*/ |
|
124
|
|
|
protected function loadOverrideDate(DocIssuanceIssueTicketOptions $options) |
|
125
|
|
|
{ |
|
126
|
|
|
if ($options->alternateDateValidation instanceof \DateTime) { |
|
127
|
|
|
$this->overrideDate = new OverrideDate( |
|
128
|
|
|
OverrideDate::OPT_ALTERNATE_DATE_VALIDATION, |
|
129
|
|
|
$options->alternateDateValidation |
|
130
|
|
|
); |
|
131
|
|
|
} elseif ($options->overridePastDateTst === true) { |
|
132
|
|
|
$this->overrideDate = new OverrideDate(OverrideDate::OPT_OVERRIDE_PAST_DATE_TST); |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* @param DocIssuanceIssueTicketOptions $options |
|
138
|
|
|
*/ |
|
139
|
|
|
protected function loadReferences(DocIssuanceIssueTicketOptions $options) |
|
140
|
|
|
{ |
|
141
|
|
|
if (!empty($options->passengerTattoos)) { |
|
142
|
|
|
foreach ($options->passengerTattoos as $passengerTattoo) { |
|
143
|
|
|
$this->paxSelection[] = new PaxSelection($passengerTattoo); |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
View Code Duplication |
if (!empty($options->segmentTattoos)) { |
|
|
|
|
|
|
148
|
|
|
foreach ($options->segmentTattoos as $segmentTattoo) { |
|
149
|
|
|
$this->addSelectionItem( |
|
150
|
|
|
new ReferenceDetails( |
|
151
|
|
|
$segmentTattoo, |
|
152
|
|
|
ReferenceDetails::TYPE_SEGMENT_TATTOO |
|
153
|
|
|
) |
|
154
|
|
|
); |
|
155
|
|
|
} |
|
156
|
|
|
} |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* @param DocIssuanceIssueTicketOptions $options |
|
161
|
|
|
*/ |
|
162
|
|
|
protected function loadOptions(DocIssuanceIssueTicketOptions $options) |
|
163
|
|
|
{ |
|
164
|
|
|
if (!empty($options->options)) { |
|
165
|
|
|
foreach ($options->options as $option) { |
|
166
|
|
|
$this->optionGroup[] = new OptionGroup($option); |
|
167
|
|
|
} |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
if (!empty($options->compoundOptions)) { |
|
171
|
|
|
foreach ($options->compoundOptions as $compoundOption) { |
|
172
|
|
|
$this->otherCompoundOptions[] = new OtherCompoundOptions( |
|
173
|
|
|
$compoundOption->type, |
|
174
|
|
|
$compoundOption->details |
|
175
|
|
|
); |
|
176
|
|
|
} |
|
177
|
|
|
} |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
|
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.