1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NStack; |
4
|
|
|
|
5
|
|
|
use NStack\Clients\CollectionsClient; |
6
|
|
|
use NStack\Clients\ContinentsClient; |
7
|
|
|
use NStack\Clients\CountriesClient; |
8
|
|
|
use NStack\Clients\FilesClient; |
9
|
|
|
use NStack\Clients\IpAddressesClient; |
10
|
|
|
use NStack\Clients\LanguagesClient; |
11
|
|
|
use NStack\Clients\LocalizeClient; |
12
|
|
|
use NStack\Clients\ProposalsClient; |
13
|
|
|
use NStack\Clients\PushLogClient; |
14
|
|
|
use NStack\Clients\TimezoneClient; |
15
|
|
|
use NStack\Clients\ValidatorsClient; |
16
|
|
|
use NStack\Clients\VersionControlClient; |
17
|
|
|
use NStack\Exceptions\MissingMasterKeyException; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class NStack |
21
|
|
|
* |
22
|
|
|
* @package NStack |
23
|
|
|
* @author Casper Rasmussen <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class NStack |
26
|
|
|
{ |
27
|
|
|
/** @var \NStack\Config */ |
28
|
|
|
protected $config; |
29
|
|
|
|
30
|
|
|
/** @var CollectionsClient */ |
31
|
|
|
protected $collectionClient; |
32
|
|
|
|
33
|
|
|
/** @var ContinentsClient */ |
34
|
|
|
protected $continentsClient; |
35
|
|
|
|
36
|
|
|
/** @var CountriesClient */ |
37
|
|
|
protected $countriesClient; |
38
|
|
|
|
39
|
|
|
/** @var FilesClient */ |
40
|
|
|
protected $filesClient; |
41
|
|
|
|
42
|
|
|
/** @var IpAddressesClient */ |
43
|
|
|
protected $ipAddressClient; |
44
|
|
|
|
45
|
|
|
/** @var LanguagesClient */ |
46
|
|
|
protected $languageClient; |
47
|
|
|
|
48
|
|
|
/** @var LocalizeClient */ |
49
|
|
|
protected $localizeClient; |
50
|
|
|
|
51
|
|
|
/** @var VersionControlClient */ |
52
|
|
|
protected $versionControlClient; |
53
|
|
|
|
54
|
|
|
/** @var ProposalsClient */ |
55
|
|
|
protected $proposalClient; |
56
|
|
|
|
57
|
|
|
/** @var TimezoneClient */ |
58
|
|
|
protected $timezoneClient; |
59
|
|
|
|
60
|
|
|
/** @var PushLogClient */ |
61
|
|
|
protected $pushLogClient; |
62
|
|
|
|
63
|
|
|
/** @var ValidatorsClient */ |
64
|
|
|
protected $validatorClient; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* NStack constructor. |
68
|
|
|
* |
69
|
|
|
* @param \NStack\Config $config |
70
|
|
|
* @author Casper Rasmussen <[email protected]> |
71
|
|
|
*/ |
72
|
1 |
|
public function __construct(Config $config) |
73
|
|
|
{ |
74
|
1 |
|
$this->config = $config; |
75
|
1 |
|
$this->continentsClient = new ContinentsClient($config); |
76
|
1 |
|
$this->countriesClient = new CountriesClient($config); |
77
|
1 |
|
$this->collectionClient = new CollectionsClient($config); |
78
|
1 |
|
$this->filesClient = new FilesClient($config); |
79
|
1 |
|
$this->ipAddressClient = new IpAddressesClient($config); |
80
|
1 |
|
$this->languageClient = new LanguagesClient($config); |
81
|
1 |
|
$this->localizeClient = new LocalizeClient($config); |
82
|
1 |
|
$this->versionControlClient = new VersionControlClient($config); |
83
|
1 |
|
$this->proposalClient = new ProposalsClient($config); |
84
|
1 |
|
$this->timezoneClient = new TimezoneClient($config); |
85
|
1 |
|
$this->pushLogClient = new PushLogClient($config); |
86
|
1 |
|
$this->validatorClient = new ValidatorsClient($config); |
87
|
1 |
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return \NStack\Config |
91
|
|
|
* @author Casper Rasmussen <[email protected]> |
92
|
|
|
*/ |
93
|
|
|
public function getConfig(): Config |
94
|
|
|
{ |
95
|
|
|
return $this->config; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* getContinentsClient |
100
|
|
|
* |
101
|
|
|
* @return ContinentsClient |
102
|
|
|
* @author Casper Rasmussen <[email protected]> |
103
|
|
|
*/ |
104
|
|
|
public function getContinentsClient(): ContinentsClient |
105
|
|
|
{ |
106
|
|
|
return $this->continentsClient; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* getCountriesClient |
111
|
|
|
* |
112
|
|
|
* @return CountriesClient |
113
|
|
|
* @author Casper Rasmussen <[email protected]> |
114
|
|
|
*/ |
115
|
|
|
public function getCountriesClient(): CountriesClient |
116
|
|
|
{ |
117
|
|
|
return $this->countriesClient; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return CollectionsClient |
122
|
|
|
* @author Casper Rasmussen <[email protected]> |
123
|
|
|
*/ |
124
|
|
|
public function getCollectionClient(): CollectionsClient |
125
|
|
|
{ |
126
|
|
|
return $this->collectionClient; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return FilesClient |
131
|
|
|
* @author Casper Rasmussen <[email protected]> |
132
|
|
|
*/ |
133
|
|
|
public function getFilesClient(): FilesClient |
134
|
|
|
{ |
135
|
|
|
return $this->filesClient; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @return IpAddressesClient |
140
|
|
|
* @author Casper Rasmussen <[email protected]> |
141
|
|
|
*/ |
142
|
|
|
public function getIpAddressClient(): IpAddressesClient |
143
|
|
|
{ |
144
|
|
|
return $this->ipAddressClient; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return LanguagesClient |
149
|
|
|
* @author Casper Rasmussen <[email protected]> |
150
|
|
|
*/ |
151
|
|
|
public function getLanguageClient(): LanguagesClient |
152
|
|
|
{ |
153
|
|
|
return $this->languageClient; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return LocalizeClient |
158
|
|
|
* @author Casper Rasmussen <[email protected]> |
159
|
|
|
*/ |
160
|
|
|
public function getLocalizeClient(): LocalizeClient |
161
|
|
|
{ |
162
|
|
|
return $this->localizeClient; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @return VersionControlClient |
167
|
|
|
* @author Casper Rasmussen <[email protected]> |
168
|
|
|
*/ |
169
|
|
|
public function getVersionControlClient(): VersionControlClient |
170
|
|
|
{ |
171
|
|
|
return $this->versionControlClient; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @return ProposalsClient |
176
|
|
|
* @author Casper Rasmussen <[email protected]> |
177
|
|
|
*/ |
178
|
|
|
public function getProposalClient(): ProposalsClient |
179
|
|
|
{ |
180
|
|
|
return $this->proposalClient; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @return TimezoneClient |
185
|
|
|
* @author Casper Rasmussen <[email protected]> |
186
|
|
|
*/ |
187
|
|
|
public function getTimezoneClient(): TimezoneClient |
188
|
|
|
{ |
189
|
|
|
return $this->timezoneClient; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @return PushLogClient |
194
|
|
|
* @author Casper Rasmussen <[email protected]> |
195
|
|
|
*/ |
196
|
|
|
public function getPushLogClient(): PushLogClient |
197
|
|
|
{ |
198
|
|
|
return $this->pushLogClient; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return ValidatorsClient |
203
|
|
|
* @author Casper Rasmussen <[email protected]> |
204
|
|
|
*/ |
205
|
|
|
public function getValidatorClient(): ValidatorsClient |
206
|
|
|
{ |
207
|
|
|
return $this->validatorClient; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* getDeeplink |
212
|
|
|
* |
213
|
|
|
* @return string |
214
|
|
|
* @throws \NStack\Exceptions\MissingMasterKeyException |
215
|
|
|
* @author Casper Rasmussen <[email protected]> |
216
|
|
|
*/ |
217
|
|
|
public function getDeeplink(): string |
218
|
|
|
{ |
219
|
|
|
if (!$this->config->getMasterKey()) { |
220
|
|
|
throw new MissingMasterKeyException(); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
return $this->config->getBaseUrl() . '/deeplink/' . $this->config->getAppId() . '/' . |
224
|
|
|
$this->config->getMasterKey(); |
225
|
|
|
} |
226
|
|
|
} |