1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DJStarCOM\BookingComSDK\Query; |
4
|
|
|
|
5
|
|
|
use DJStarCOM\BookingComSDK\Models\Autocomplete; |
6
|
|
|
|
7
|
|
|
class AutocompleteQuery extends Query |
8
|
|
|
{ |
9
|
|
|
public const EXTRAS_ID_FORECAST = 'forecast'; |
10
|
|
|
public const EXTRAS_ID_TIMEZONES = 'timezones'; |
11
|
|
|
public const EXTRAS_ID_THEMES = 'themes'; |
12
|
|
|
public const EXTRAS_ID_ENDORSEMENTS = 'endorsements'; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
protected static $uri = '/autocomplete'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Search text. |
21
|
|
|
* It is part or full name of a hotel, another destination or a theme. |
22
|
|
|
* It must be at least 3 characters long. |
23
|
|
|
* |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
protected $text; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Language code in which to display the results. |
30
|
|
|
* |
31
|
|
|
* @var string like 'en' |
32
|
|
|
*/ |
33
|
|
|
protected $language; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Partner affiliate id that will be appended to the search page URLs. |
37
|
|
|
* |
38
|
|
|
* @var string like '000000' |
39
|
|
|
*/ |
40
|
|
|
protected $affiliate_id; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Specify here what extra items of the result should be included. |
44
|
|
|
* See the endpoint description for more detailed information about each extra. |
45
|
|
|
* |
46
|
|
|
* @var array |
47
|
|
|
*/ |
48
|
|
|
protected $extras; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return string |
52
|
|
|
*/ |
53
|
|
|
public function getText(): string |
54
|
|
|
{ |
55
|
|
|
return $this->text; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $text |
60
|
|
|
* @return AutocompleteQuery |
61
|
|
|
*/ |
62
|
|
|
public function setText(string $text): self |
63
|
|
|
{ |
64
|
|
|
$this->text = $text; |
65
|
|
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
public function getLanguage(): string |
72
|
|
|
{ |
73
|
|
|
return $this->language; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param string $language |
78
|
|
|
* @return AutocompleteQuery |
79
|
|
|
*/ |
80
|
|
|
public function setLanguage(string $language): self |
81
|
|
|
{ |
82
|
|
|
$this->language = $language; |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return string |
88
|
|
|
*/ |
89
|
|
|
public function getAffiliateId(): string |
90
|
|
|
{ |
91
|
|
|
return $this->affiliate_id; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param string $affiliate_id |
96
|
|
|
* @return AutocompleteQuery |
97
|
|
|
*/ |
98
|
|
|
public function setAffiliateId(string $affiliate_id): self |
99
|
|
|
{ |
100
|
|
|
$this->affiliate_id = $affiliate_id; |
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return null|array |
106
|
|
|
*/ |
107
|
|
|
public function getExtras(): ?array |
108
|
|
|
{ |
109
|
|
|
return $this->extras; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param array $extras |
114
|
|
|
* @return AutocompleteQuery |
115
|
|
|
*/ |
116
|
|
|
public function setExtras(array $extras): self |
117
|
|
|
{ |
118
|
|
|
$this->extras = $extras; |
119
|
|
|
|
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return self |
125
|
|
|
*/ |
126
|
|
|
public function withExtras(): self |
127
|
|
|
{ |
128
|
|
|
$this->extras = [ |
129
|
|
|
self::EXTRAS_ID_FORECAST, |
130
|
|
|
self::EXTRAS_ID_TIMEZONES, |
131
|
|
|
self::EXTRAS_ID_THEMES, |
132
|
|
|
self::EXTRAS_ID_ENDORSEMENTS, |
133
|
|
|
]; |
134
|
|
|
|
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @return array |
140
|
|
|
*/ |
141
|
|
|
protected function getAttributeMap(): array |
142
|
|
|
{ |
143
|
|
|
return [ |
144
|
|
|
'text' => 'string', |
145
|
|
|
'language' => 'string', |
146
|
|
|
'affiliate_id' => 'string', |
147
|
|
|
'extras' => 'array', |
148
|
|
|
]; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return bool |
153
|
|
|
*/ |
154
|
|
|
protected function isSecure(): bool |
155
|
|
|
{ |
156
|
|
|
return false; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @return string |
161
|
|
|
*/ |
162
|
|
|
protected function model(): string |
163
|
|
|
{ |
164
|
|
|
return Autocomplete::class; |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
|