|
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\PointOfRef; |
|
24
|
|
|
|
|
25
|
|
|
use Amadeus\Client\RequestOptions\PointOfRefSearchOptions; |
|
26
|
|
|
use Amadeus\Client\Struct\BaseWsMessage; |
|
27
|
|
|
use Amadeus\Client\Struct\PointOfRef\Search\Area; |
|
28
|
|
|
use Amadeus\Client\Struct\PointOfRef\Search\BusinessId; |
|
29
|
|
|
use Amadeus\Client\Struct\PointOfRef\Search\GeoCode; |
|
30
|
|
|
use Amadeus\Client\Struct\PointOfRef\Search\Name; |
|
31
|
|
|
use Amadeus\Client\Struct\PointOfRef\Search\PorFndQryParams; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* PointOfRef_Search request message structure |
|
35
|
|
|
* |
|
36
|
|
|
* @package Amadeus\Client\Struct\PointOfRef |
|
37
|
|
|
* @author Dieter Devlieghere <[email protected]> |
|
38
|
|
|
*/ |
|
39
|
|
|
class Search extends BaseWsMessage |
|
40
|
|
|
{ |
|
41
|
|
|
/** |
|
42
|
|
|
* @var PorFndQryParams |
|
43
|
|
|
*/ |
|
44
|
|
|
public $porFndQryParams; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Search constructor. |
|
48
|
|
|
* |
|
49
|
|
|
* @param PointOfRefSearchOptions $params |
|
50
|
|
|
*/ |
|
51
|
6 |
|
public function __construct(PointOfRefSearchOptions $params) |
|
52
|
|
|
{ |
|
53
|
6 |
|
$this->loadBasic($params); |
|
54
|
6 |
|
$this->loadGeoCode($params); |
|
55
|
6 |
|
$this->loadCountryStateIata($params); |
|
56
|
6 |
|
$this->loadBusinessId($params); |
|
57
|
6 |
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param PointOfRefSearchOptions $params |
|
61
|
|
|
*/ |
|
62
|
6 |
|
protected function loadBasic($params) |
|
63
|
|
|
{ |
|
64
|
6 |
|
$this->porFndQryParams = new PorFndQryParams($params->targetCategoryCode); |
|
65
|
|
|
|
|
66
|
6 |
|
if ($params->listType !== null) { |
|
67
|
1 |
|
$this->porFndQryParams->resultListType = $params->listType; |
|
68
|
1 |
|
} |
|
69
|
|
|
|
|
70
|
6 |
|
if ($params->searchRadius !== null) { |
|
71
|
3 |
|
$this->porFndQryParams->radius = $params->searchRadius; |
|
|
|
|
|
|
72
|
3 |
|
} |
|
73
|
|
|
|
|
74
|
6 |
|
if ($params->name !== null) { |
|
75
|
2 |
|
$this->porFndQryParams->name = new Name($params->name); |
|
76
|
2 |
|
} |
|
77
|
|
|
|
|
78
|
6 |
|
if ($params->maxNrOfResults !== null) { |
|
79
|
1 |
|
$this->porFndQryParams->resultMaxItems = $params->maxNrOfResults; |
|
80
|
1 |
|
} |
|
81
|
6 |
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Search by geocode? |
|
85
|
|
|
* |
|
86
|
|
|
* @param PointOfRefSearchOptions $params |
|
87
|
|
|
*/ |
|
88
|
6 |
|
protected function loadGeoCode(PointOfRefSearchOptions $params) |
|
89
|
|
|
{ |
|
90
|
6 |
|
if ($this->checkAllNotEmpty($params->latitude, $params->longitude)) { |
|
91
|
3 |
|
$this->porFndQryParams->geoCode = new GeoCode( |
|
92
|
3 |
|
$params->longitude, |
|
93
|
3 |
|
$params->latitude |
|
94
|
3 |
|
); |
|
95
|
3 |
|
} |
|
96
|
6 |
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Search by country/state/iata code? |
|
100
|
|
|
* |
|
101
|
|
|
* @param PointOfRefSearchOptions $params |
|
102
|
|
|
*/ |
|
103
|
6 |
|
protected function loadCountryStateIata(PointOfRefSearchOptions $params) |
|
104
|
|
|
{ |
|
105
|
6 |
|
if ($this->checkAnyNotEmpty($params->country, $params->state, $params->iata)) { |
|
106
|
2 |
|
$this->porFndQryParams->area = new Area( |
|
107
|
2 |
|
$params->country, |
|
108
|
2 |
|
$params->state, |
|
109
|
2 |
|
$params->iata |
|
110
|
2 |
|
); |
|
111
|
2 |
|
} |
|
112
|
6 |
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Search by Business ID? |
|
116
|
|
|
* |
|
117
|
|
|
* @param PointOfRefSearchOptions $params |
|
118
|
|
|
*/ |
|
119
|
6 |
|
protected function loadBusinessId(PointOfRefSearchOptions $params) |
|
120
|
|
|
{ |
|
121
|
6 |
|
if ($this->checkAnyNotEmpty($params->businessCategory, $params->businessForeignKey)) { |
|
122
|
1 |
|
$this->porFndQryParams->businessId = new BusinessId( |
|
123
|
1 |
|
$params->businessCategory, |
|
124
|
1 |
|
$params->businessForeignKey |
|
125
|
1 |
|
); |
|
126
|
1 |
|
} |
|
127
|
6 |
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.