-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathConfiguration.php
More file actions
384 lines (341 loc) · 11.7 KB
/
Configuration.php
File metadata and controls
384 lines (341 loc) · 11.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<?php
/*
* BandwidthLib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
namespace BandwidthLib;
/**
* All configuration including auth info and base URI for the API access
* are configured in this class.
*/
class Configuration
{
/**
* Timeout to use for endpoint calls
* @var int
*/
private $timeout = 0;
/**
* The username to use with basic authentication
* @var string
*/
private $messagingBasicAuthUserName = 'TODO: Replace';
/**
* The password to use with basic authentication
* @var string
*/
private $messagingBasicAuthPassword = 'TODO: Replace';
/**
* The username to use with basic authentication
* @var string
*/
private $multiFactorAuthBasicAuthUserName = 'TODO: Replace';
/**
* The password to use with basic authentication
* @var string
*/
private $multiFactorAuthBasicAuthPassword = 'TODO: Replace';
/**
* The username to use with basic authentication
* @var string
*/
private $phoneNumberLookupBasicAuthUserName = 'TODO: Replace';
/**
* The password to use with basic authentication
* @var string
*/
private $phoneNumberLookupBasicAuthPassword = 'TODO: Replace';
/**
* The username to use with basic authentication
* @var string
*/
private $voiceBasicAuthUserName = 'TODO: Replace';
/**
* The password to use with basic authentication
* @var string
*/
private $voiceBasicAuthPassword = 'TODO: Replace';
/**
* The username to use with basic authentication
* @var string
*/
private $webRtcBasicAuthUserName = 'TODO: Replace';
/**
* The password to use with basic authentication
* @var string
*/
private $webRtcBasicAuthPassword = 'TODO: Replace';
/**
* The clientId to use for OAuth2
* @var string
*/
private $clientId;
/**
* The clientSecret to use for OAuth2
* @var string
*/
private $clientSecret;
/**
* The OAuth2 access token to use for API calls
* @var string
*/
private $accessToken;
/**
* The expiration time of the access token
* @var int
*/
private $accessTokenExpiration;
/**
* Current API environment
* @var Environments
*/
private $environment = Environments::PRODUCTION;
/**
* @todo Add description for parameter
* @var string
*/
private $baseUrl = 'https://www.example.com';
public function __construct($configOptions = null)
{
if (isset($configOptions['timeout'])) {
$this->timeout = $configOptions['timeout'];
}
if (isset($configOptions['messagingBasicAuthUserName'])) {
$this->messagingBasicAuthUserName = $configOptions['messagingBasicAuthUserName'];
}
if (isset($configOptions['messagingBasicAuthPassword'])) {
$this->messagingBasicAuthPassword = $configOptions['messagingBasicAuthPassword'];
}
if (isset($configOptions['multiFactorAuthBasicAuthUserName'])) {
$this->multiFactorAuthBasicAuthUserName = $configOptions['multiFactorAuthBasicAuthUserName'];
}
if (isset($configOptions['multiFactorAuthBasicAuthPassword'])) {
$this->multiFactorAuthBasicAuthPassword = $configOptions['multiFactorAuthBasicAuthPassword'];
}
if (isset($configOptions['phoneNumberLookupBasicAuthUserName'])) {
$this->phoneNumberLookupBasicAuthUserName = $configOptions['phoneNumberLookupBasicAuthUserName'];
}
if (isset($configOptions['phoneNumberLookupBasicAuthPassword'])) {
$this->phoneNumberLookupBasicAuthPassword = $configOptions['phoneNumberLookupBasicAuthPassword'];
}
if (isset($configOptions['voiceBasicAuthUserName'])) {
$this->voiceBasicAuthUserName = $configOptions['voiceBasicAuthUserName'];
}
if (isset($configOptions['voiceBasicAuthPassword'])) {
$this->voiceBasicAuthPassword = $configOptions['voiceBasicAuthPassword'];
}
if (isset($configOptions['webRtcBasicAuthUserName'])) {
$this->webRtcBasicAuthUserName = $configOptions['webRtcBasicAuthUserName'];
}
if (isset($configOptions['webRtcBasicAuthPassword'])) {
$this->webRtcBasicAuthPassword = $configOptions['webRtcBasicAuthPassword'];
}
if (isset($configOptions['clientId'])) {
$this->clientId = $configOptions['clientId'];
}
if (isset($configOptions['clientSecret'])) {
$this->clientSecret = $configOptions['clientSecret'];
}
if (isset($configOptions['accessToken'])) {
$this->accessToken = $configOptions['accessToken'];
}
if (isset($configOptions['accessTokenExpiration'])) {
$this->accessTokenExpiration = $configOptions['accessTokenExpiration'];
}
if (isset($configOptions['environment'])) {
$this->environment = $configOptions['environment'];
}
if (isset($configOptions['baseUrl'])) {
$this->baseUrl = $configOptions['baseUrl'];
}
}
public function getConfigurationMap()
{
$configMap = array();
if (isset($this->timeout)) {
$configMap['timeout'] = $this->timeout;
}
if (isset($this->messagingBasicAuthUserName)) {
$configMap['messagingBasicAuthUserName'] = $this->messagingBasicAuthUserName;
}
if (isset($this->messagingBasicAuthPassword)) {
$configMap['messagingBasicAuthPassword'] = $this->messagingBasicAuthPassword;
}
if (isset($this->multiFactorAuthBasicAuthUserName)) {
$configMap['multiFactorAuthBasicAuthUserName'] = $this->multiFactorAuthBasicAuthUserName;
}
if (isset($this->multiFactorAuthBasicAuthPassword)) {
$configMap['multiFactorAuthBasicAuthPassword'] = $this->multiFactorAuthBasicAuthPassword;
}
if (isset($this->phoneNumberLookupBasicAuthUserName)) {
$configMap['phoneNumberLookupBasicAuthUserName'] = $this->phoneNumberLookupBasicAuthUserName;
}
if (isset($this->phoneNumberLookupBasicAuthPassword)) {
$configMap['phoneNumberLookupBasicAuthPassword'] = $this->phoneNumberLookupBasicAuthPassword;
}
if (isset($this->voiceBasicAuthUserName)) {
$configMap['voiceBasicAuthUserName'] = $this->voiceBasicAuthUserName;
}
if (isset($this->voiceBasicAuthPassword)) {
$configMap['voiceBasicAuthPassword'] = $this->voiceBasicAuthPassword;
}
if (isset($this->webRtcBasicAuthUserName)) {
$configMap['webRtcBasicAuthUserName'] = $this->webRtcBasicAuthUserName;
}
if (isset($this->webRtcBasicAuthPassword)) {
$configMap['webRtcBasicAuthPassword'] = $this->webRtcBasicAuthPassword;
}
if (isset($this->clientId)) {
$configMap['clientId'] = $this->clientId;
}
if (isset($this->clientSecret)) {
$configMap['clientSecret'] = $this->clientSecret;
}
if (isset($this->accessToken)) {
$configMap['accessToken'] = $this->accessToken;
}
if (isset($this->accessTokenExpiration)) {
$configMap['accessTokenExpiration'] = $this->accessTokenExpiration;
}
if (isset($this->environment)) {
$configMap['environment'] = $this->environment;
}
if (isset($this->baseUrl)) {
$configMap['baseUrl'] = $this->baseUrl;
}
return $configMap;
}
// Getter for timeout
public function getTimeout()
{
return $this->timeout;
}
// Getter for messagingBasicAuthUserName
public function getMessagingBasicAuthUserName()
{
return $this->messagingBasicAuthUserName;
}
// Getter for messagingBasicAuthPassword
public function getMessagingBasicAuthPassword()
{
return $this->messagingBasicAuthPassword;
}
// Getter for multiFactorAuthBasicAuthUserName
public function getMultiFactorAuthBasicAuthUserName()
{
return $this->multiFactorAuthBasicAuthUserName;
}
// Getter for multiFactorAuthBasicAuthPassword
public function getMultiFactorAuthBasicAuthPassword()
{
return $this->multiFactorAuthBasicAuthPassword;
}
// Getter for phoneNumberLookupBasicAuthUserName
public function getPhoneNumberLookupBasicAuthUserName()
{
return $this->phoneNumberLookupBasicAuthUserName;
}
// Getter for phoneNumberLookupBasicAuthPassword
public function getPhoneNumberLookupBasicAuthPassword()
{
return $this->phoneNumberLookupBasicAuthPassword;
}
// Getter for voiceBasicAuthUserName
public function getVoiceBasicAuthUserName()
{
return $this->voiceBasicAuthUserName;
}
// Getter for voiceBasicAuthPassword
public function getVoiceBasicAuthPassword()
{
return $this->voiceBasicAuthPassword;
}
// Getter for webRtcBasicAuthUserName
public function getWebRtcBasicAuthUserName()
{
return $this->webRtcBasicAuthUserName;
}
// Getter for webRtcBasicAuthPassword
public function getWebRtcBasicAuthPassword()
{
return $this->webRtcBasicAuthPassword;
}
// Getter for clientId
public function getClientId()
{
return $this->clientId;
}
// Getter for clientSecret
public function getClientSecret()
{
return $this->clientSecret;
}
// Getter for accessToken
public function getAccessToken()
{
return $this->accessToken;
}
// Setter for accessToken
public function setAccessToken($value)
{
$this->accessToken = $value;
}
// Getter for getAccessTokenExpiration
public function getAccessTokenExpiration()
{
return $this->accessTokenExpiration;
}
// Setter for accessTokenExpiration
public function setAccessTokenExpiration($value)
{
$this->accessTokenExpiration = $value;
}
// Getter for environment
public function getEnvironment()
{
return $this->environment;
}
// Getter for baseUrl
public function getBaseUrl()
{
return $this->baseUrl;
}
/**
* Get the base uri for a given server in the current environment
* @param string $server Server name
* @return string Base URI
*/
public function getBaseUri(string $server = Servers::DEFAULT_)
{
return APIHelper::appendUrlWithTemplateParameters(
static::$environmentsMap[$this->environment][$server],
array(
'base_url' => $this->baseUrl,
),
false
);
}
/**
* A map of all baseurls used in different environments and servers
* @var array
*/
private static $environmentsMap = array(
Environments::PRODUCTION => array(
Servers::DEFAULT_ => 'api.bandwidth.com',
Servers::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
Servers::MULTIFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1',
Servers::PHONENUMBERLOOKUPDEFAULT => 'https://api.bandwidth.com/v2',
Servers::VOICEDEFAULT => 'https://voice.bandwidth.com',
Servers::WEBRTCDEFAULT => 'https://api.webrtc.bandwidth.com/v1',
),
Environments::CUSTOM => array(
Servers::DEFAULT_ => '{base_url}',
Servers::MESSAGINGDEFAULT => '{base_url}',
Servers::MULTIFACTORAUTHDEFAULT => '{base_url}',
Servers::PHONENUMBERLOOKUPDEFAULT => '{base_url}',
Servers::VOICEDEFAULT => '{base_url}',
Servers::WEBRTCDEFAULT => '{base_url}',
),
);
}