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\Info; |
24
|
|
|
|
25
|
|
|
use Amadeus\Client\RequestCreator\MessageVersionUnsupportedException; |
26
|
|
|
use Amadeus\Client\RequestOptions\InfoEncodeDecodeCityOptions; |
27
|
|
|
use Amadeus\Client\Struct\BaseWsMessage; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Info_EncodeDecodeCity |
31
|
|
|
* |
32
|
|
|
* @package Amadeus\Client\Struct\Info |
33
|
|
|
*/ |
34
|
|
|
class EncodeDecodeCity extends BaseWsMessage |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* @var LocationInformation |
38
|
|
|
*/ |
39
|
|
|
public $locationInformation; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var RequestOption |
43
|
|
|
*/ |
44
|
|
|
public $requestOption; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var Language |
48
|
|
|
*/ |
49
|
|
|
public $language; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var CountryStateRestriction |
53
|
|
|
*/ |
54
|
|
|
public $countryStateRestriction; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* EncodeDecodeCity constructor. |
58
|
|
|
* |
59
|
|
|
* @param InfoEncodeDecodeCityOptions $params |
60
|
|
|
* @throws MessageVersionUnsupportedException |
61
|
|
|
*/ |
62
|
35 |
|
public function __construct(InfoEncodeDecodeCityOptions $params) |
63
|
|
|
{ |
64
|
35 |
|
if (!empty($params->locationCode)) { |
65
|
20 |
|
$this->locationInformation = new LocationInformation( |
66
|
20 |
|
LocationInformation::TYPE_LOCATION, |
67
|
20 |
|
strtoupper($params->locationCode), |
68
|
12 |
|
null |
69
|
8 |
|
); |
70
|
23 |
|
} elseif (!empty($params->locationName)) { |
71
|
|
|
//Only allow lowercase input for phonetic searches |
72
|
17 |
|
if ($params->searchMode !== InfoEncodeDecodeCityOptions::SEARCHMODE_PHONETIC) { |
73
|
5 |
|
$params->locationName = strtoupper($params->locationName); |
74
|
2 |
|
} |
75
|
|
|
|
76
|
15 |
|
$this->locationInformation = new LocationInformation( |
77
|
15 |
|
LocationInformation::TYPE_ALL, |
78
|
15 |
|
null, |
79
|
15 |
|
$params->locationName |
80
|
6 |
|
); |
81
|
6 |
|
} |
82
|
|
|
|
83
|
35 |
|
if (!empty($params->searchMode)) { |
84
|
30 |
|
$this->requestOption = new RequestOption( |
85
|
30 |
|
$params->searchMode, |
86
|
18 |
|
SelectionDetails::OPT_SEARCH_ALGORITHM |
87
|
12 |
|
); |
88
|
12 |
|
} |
89
|
|
|
|
90
|
35 |
|
if (!empty($params->selectResult)) { |
91
|
10 |
|
$selDet = new SelectionDetails( |
92
|
10 |
|
$params->selectResult, |
93
|
6 |
|
SelectionDetails::OPT_LOCATION_TYPE |
94
|
4 |
|
); |
95
|
|
|
|
96
|
10 |
|
if (!($this->requestOption instanceof RequestOption)) { |
|
|
|
|
97
|
5 |
|
$this->requestOption = new RequestOption(); |
98
|
5 |
|
$this->requestOption->selectionDetails = $selDet; |
99
|
2 |
|
} else { |
100
|
5 |
|
$this->requestOption->otherSelectionDetails[] = $selDet; |
101
|
|
|
} |
102
|
4 |
|
} |
103
|
|
|
|
104
|
35 |
|
if (!is_null($params->restrictCountry) || !is_null($params->restrictState)) { |
|
|
|
|
105
|
5 |
|
$params->restrictState = $this->upperOrNull($params->restrictState); |
106
|
|
|
|
107
|
5 |
|
$params->restrictCountry = $this->upperOrNull($params->restrictCountry); |
108
|
|
|
|
109
|
5 |
|
$this->countryStateRestriction = new CountryStateRestriction( |
110
|
5 |
|
$params->restrictCountry, |
111
|
5 |
|
$params->restrictState |
112
|
2 |
|
); |
113
|
2 |
|
} |
114
|
35 |
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Converts string to uppercase or null if null. |
118
|
|
|
* |
119
|
|
|
* @param string|null $param |
120
|
|
|
* @return string|null |
121
|
|
|
*/ |
122
|
5 |
|
protected function upperOrNull($param) |
123
|
|
|
{ |
124
|
5 |
|
return (!is_null($param)) ? strtoupper($param) : $param; |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|