Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
14.93% |
10 / 67 |
|
23.08% |
6 / 26 |
CRAP | |
0.00% |
0 / 1 |
| Configuration | |
14.93% |
10 / 67 |
|
23.08% |
6 / 26 |
1076.07 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setApiKey | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getApiKey | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| setApiKeyPrefix | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getApiKeyPrefix | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| setAccessToken | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getAccessToken | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setUsername | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getUsername | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setPassword | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getPassword | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setHost | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getHost | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setRegion | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
110 | |||
| setUserAgent | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| getUserAgent | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setDebug | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getDebug | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setDebugFile | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getDebugFile | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setTempFolderPath | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getTempFolderPath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getDefaultConfiguration | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| setDefaultConfiguration | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| toDebugReport | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| getApiKeyWithPrefix | |
50.00% |
4 / 8 |
|
0.00% |
0 / 1 |
4.12 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Configuration |
| 4 | * PHP version 5. |
| 5 | * |
| 6 | * @category Class |
| 7 | * |
| 8 | * @author Swagger Codegen team |
| 9 | * |
| 10 | * @see https://github.com/swagger-api/swagger-codegen |
| 11 | */ |
| 12 | |
| 13 | /** |
| 14 | * Fingerprint Server API. |
| 15 | * |
| 16 | * Fingerprint Server API allows you to search, update, and delete identification events in a server environment. It can be used for data exports, decision-making, and data analysis scenarios. Server API is intended for server-side usage, it's not intended to be used from the client side, whether it's a browser or a mobile device. |
| 17 | * |
| 18 | * OpenAPI spec version: 3 |
| 19 | * Contact: support@fingerprint.com |
| 20 | * Generated by: https://github.com/swagger-api/swagger-codegen.git |
| 21 | * Swagger Codegen version: 3.0.34 |
| 22 | */ |
| 23 | /** |
| 24 | * NOTE: This class is auto generated by the swagger code generator program. |
| 25 | * https://github.com/swagger-api/swagger-codegen |
| 26 | * Do not edit the class manually. |
| 27 | */ |
| 28 | |
| 29 | namespace Fingerprint\ServerAPI; |
| 30 | |
| 31 | /** |
| 32 | * Configuration Class Doc Comment |
| 33 | * PHP version 5. |
| 34 | * |
| 35 | * @category Class |
| 36 | * |
| 37 | * @author Swagger Codegen team |
| 38 | * |
| 39 | * @see https://github.com/swagger-api/swagger-codegen |
| 40 | */ |
| 41 | class Configuration |
| 42 | { |
| 43 | public const REGION_GLOBAL = 'https://api.fpjs.io'; |
| 44 | public const REGION_EUROPE = 'https://eu.api.fpjs.io'; |
| 45 | public const REGION_ASIA = 'https://ap.api.fpjs.io'; |
| 46 | |
| 47 | /** |
| 48 | * Associate array to store API key(s). |
| 49 | * |
| 50 | * @var string[] |
| 51 | */ |
| 52 | protected array $apiKeys = []; |
| 53 | |
| 54 | /** |
| 55 | * Associate array to store API prefix (e.g. Bearer). |
| 56 | * |
| 57 | * @var string[] |
| 58 | */ |
| 59 | protected array $apiKeyPrefixes = []; |
| 60 | |
| 61 | /** |
| 62 | * Access token for OAuth. |
| 63 | */ |
| 64 | protected string $accessToken = ''; |
| 65 | |
| 66 | /** |
| 67 | * Username for HTTP basic authentication. |
| 68 | */ |
| 69 | protected string $username = ''; |
| 70 | |
| 71 | /** |
| 72 | * Password for HTTP basic authentication. |
| 73 | */ |
| 74 | protected string $password = ''; |
| 75 | |
| 76 | /** |
| 77 | * The host. |
| 78 | */ |
| 79 | protected string $host = 'https://api.fpjs.io'; |
| 80 | |
| 81 | /** |
| 82 | * User agent of the HTTP request, set to "PHP-Swagger" by default. |
| 83 | */ |
| 84 | protected string $userAgent = 'Swagger-Codegen/6.10.0/php'; |
| 85 | |
| 86 | /** |
| 87 | * Debug switch (default set to false). |
| 88 | */ |
| 89 | protected bool $debug = false; |
| 90 | |
| 91 | /** |
| 92 | * Debug file location (log to STDOUT by default). |
| 93 | */ |
| 94 | protected string $debugFile = 'php://output'; |
| 95 | |
| 96 | /** |
| 97 | * Debug file location (log to STDOUT by default). |
| 98 | */ |
| 99 | protected string $tempFolderPath; |
| 100 | private static $defaultConfiguration; |
| 101 | |
| 102 | public function __construct() |
| 103 | { |
| 104 | $this->tempFolderPath = sys_get_temp_dir(); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Sets API key. |
| 109 | * |
| 110 | * @param string $apiKeyIdentifier API key identifier (authentication scheme) |
| 111 | * @param string $key API key or token |
| 112 | * |
| 113 | * @return $this |
| 114 | */ |
| 115 | public function setApiKey(string $apiKeyIdentifier, string $key): self |
| 116 | { |
| 117 | $this->apiKeys[$apiKeyIdentifier] = $key; |
| 118 | |
| 119 | return $this; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Gets API key. |
| 124 | * |
| 125 | * @param string $apiKeyIdentifier API key identifier (authentication scheme) |
| 126 | * |
| 127 | * @return string|null API key or token |
| 128 | */ |
| 129 | public function getApiKey(string $apiKeyIdentifier): ?string |
| 130 | { |
| 131 | return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Sets the prefix for API key (e.g. Bearer). |
| 136 | * |
| 137 | * @param string $apiKeyIdentifier API key identifier (authentication scheme) |
| 138 | * @param string $prefix API key prefix, e.g. Bearer |
| 139 | * |
| 140 | * @return $this |
| 141 | */ |
| 142 | public function setApiKeyPrefix(string $apiKeyIdentifier, string $prefix): self |
| 143 | { |
| 144 | $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; |
| 145 | |
| 146 | return $this; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Gets API key prefix. |
| 151 | * |
| 152 | * @param string $apiKeyIdentifier API key identifier (authentication scheme) |
| 153 | * |
| 154 | */ |
| 155 | public function getApiKeyPrefix(string $apiKeyIdentifier): ?string |
| 156 | { |
| 157 | return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Sets the access token for OAuth. |
| 162 | * |
| 163 | * @param string $accessToken Token for OAuth |
| 164 | * |
| 165 | * @return $this |
| 166 | */ |
| 167 | public function setAccessToken(string $accessToken): self |
| 168 | { |
| 169 | $this->accessToken = $accessToken; |
| 170 | |
| 171 | return $this; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Gets the access token for OAuth. |
| 176 | * |
| 177 | * @return string Access token for OAuth |
| 178 | */ |
| 179 | public function getAccessToken(): string |
| 180 | { |
| 181 | return $this->accessToken; |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Sets the username for HTTP basic authentication. |
| 186 | * |
| 187 | * @param string $username Username for HTTP basic authentication |
| 188 | * |
| 189 | * @return $this |
| 190 | */ |
| 191 | public function setUsername(string $username): self |
| 192 | { |
| 193 | $this->username = $username; |
| 194 | |
| 195 | return $this; |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * Gets the username for HTTP basic authentication. |
| 200 | * |
| 201 | * @return string Username for HTTP basic authentication |
| 202 | */ |
| 203 | public function getUsername(): string |
| 204 | { |
| 205 | return $this->username; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Sets the password for HTTP basic authentication. |
| 210 | * |
| 211 | * @param string $password Password for HTTP basic authentication |
| 212 | * |
| 213 | * @return $this |
| 214 | */ |
| 215 | public function setPassword(string $password): self |
| 216 | { |
| 217 | $this->password = $password; |
| 218 | |
| 219 | return $this; |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Gets the password for HTTP basic authentication. |
| 224 | * |
| 225 | * @return string Password for HTTP basic authentication |
| 226 | */ |
| 227 | public function getPassword(): string |
| 228 | { |
| 229 | return $this->password; |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Sets the host. |
| 234 | * |
| 235 | * @param string $host Host |
| 236 | * |
| 237 | * @return $this |
| 238 | */ |
| 239 | public function setHost(string $host): self |
| 240 | { |
| 241 | $this->host = $host; |
| 242 | |
| 243 | return $this; |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Gets the host. |
| 248 | * |
| 249 | * @return string Host |
| 250 | */ |
| 251 | public function getHost(): string |
| 252 | { |
| 253 | return $this->host; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * @return $this |
| 258 | */ |
| 259 | public function setRegion(?string $region = self::REGION_GLOBAL): self |
| 260 | { |
| 261 | switch (trim(strtolower($region))) { |
| 262 | case self::REGION_ASIA: |
| 263 | case 'as': |
| 264 | case 'asia': |
| 265 | $this->setHost(self::REGION_ASIA); |
| 266 | |
| 267 | break; |
| 268 | |
| 269 | case self::REGION_EUROPE: |
| 270 | case 'eu': |
| 271 | case 'europe': |
| 272 | $this->setHost(self::REGION_EUROPE); |
| 273 | |
| 274 | break; |
| 275 | |
| 276 | default: |
| 277 | case self::REGION_GLOBAL: |
| 278 | case 'global': |
| 279 | $this->setHost(self::REGION_GLOBAL); |
| 280 | |
| 281 | break; |
| 282 | } |
| 283 | |
| 284 | return $this; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Sets the user agent of the api client. |
| 289 | * |
| 290 | * @param string $userAgent the user agent of the api client |
| 291 | * |
| 292 | * @return $this |
| 293 | * |
| 294 | * @throws \InvalidArgumentException |
| 295 | */ |
| 296 | public function setUserAgent(string $userAgent): self |
| 297 | { |
| 298 | if (!is_string($userAgent)) { |
| 299 | throw new \InvalidArgumentException('User-agent must be a string.'); |
| 300 | } |
| 301 | |
| 302 | $this->userAgent = $userAgent; |
| 303 | |
| 304 | return $this; |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Gets the user agent of the api client. |
| 309 | * |
| 310 | * @return string user agent |
| 311 | */ |
| 312 | public function getUserAgent(): string |
| 313 | { |
| 314 | return $this->userAgent; |
| 315 | } |
| 316 | |
| 317 | /** |
| 318 | * Sets debug flag. |
| 319 | * |
| 320 | * @param bool $debug Debug flag |
| 321 | * |
| 322 | * @return $this |
| 323 | */ |
| 324 | public function setDebug(bool $debug): self |
| 325 | { |
| 326 | $this->debug = $debug; |
| 327 | |
| 328 | return $this; |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * Gets the debug flag. |
| 333 | * |
| 334 | */ |
| 335 | public function getDebug(): bool |
| 336 | { |
| 337 | return $this->debug; |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * Sets the debug file. |
| 342 | * |
| 343 | * @param string $debugFile Debug file |
| 344 | * |
| 345 | * @return $this |
| 346 | */ |
| 347 | public function setDebugFile(string $debugFile): self |
| 348 | { |
| 349 | $this->debugFile = $debugFile; |
| 350 | |
| 351 | return $this; |
| 352 | } |
| 353 | |
| 354 | /** |
| 355 | * Gets the debug file. |
| 356 | * |
| 357 | */ |
| 358 | public function getDebugFile(): string |
| 359 | { |
| 360 | return $this->debugFile; |
| 361 | } |
| 362 | |
| 363 | /** |
| 364 | * Sets the temp folder path. |
| 365 | * |
| 366 | * @param string $tempFolderPath Temp folder path |
| 367 | * |
| 368 | * @return $this |
| 369 | */ |
| 370 | public function setTempFolderPath(string $tempFolderPath): self |
| 371 | { |
| 372 | $this->tempFolderPath = $tempFolderPath; |
| 373 | |
| 374 | return $this; |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * Gets the temp folder path. |
| 379 | * |
| 380 | * @return string Temp folder path |
| 381 | */ |
| 382 | public function getTempFolderPath(): string |
| 383 | { |
| 384 | return $this->tempFolderPath; |
| 385 | } |
| 386 | |
| 387 | /** |
| 388 | * Gets the default configuration instance, with apiKey and host params. |
| 389 | * |
| 390 | */ |
| 391 | public static function getDefaultConfiguration(?string $api_key = null, ?string $region = self::REGION_GLOBAL): self |
| 392 | { |
| 393 | if (null === self::$defaultConfiguration) { |
| 394 | self::$defaultConfiguration = new Configuration(); |
| 395 | } |
| 396 | |
| 397 | self::$defaultConfiguration->setApiKey('api_key', $api_key); |
| 398 | self::$defaultConfiguration->setRegion($region); |
| 399 | |
| 400 | return self::$defaultConfiguration; |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Sets the detault configuration instance. |
| 405 | * |
| 406 | * @param Configuration $config An instance of the Configuration Object |
| 407 | * |
| 408 | */ |
| 409 | public static function setDefaultConfiguration(Configuration $config): void |
| 410 | { |
| 411 | self::$defaultConfiguration = $config; |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * Gets the essential information for debugging. |
| 416 | * |
| 417 | * @return string The report for debugging |
| 418 | */ |
| 419 | public static function toDebugReport(): string |
| 420 | { |
| 421 | $report = 'PHP SDK (Fingerprint\ServerAPI) Debug Report:'.PHP_EOL; |
| 422 | $report .= ' OS: '.php_uname().PHP_EOL; |
| 423 | $report .= ' PHP Version: '.PHP_VERSION.PHP_EOL; |
| 424 | $report .= ' OpenAPI Spec Version: 3'.PHP_EOL; |
| 425 | $report .= ' SDK Package Version: 6.10.0'.PHP_EOL; |
| 426 | $report .= ' Temp Folder Path: '.self::getDefaultConfiguration()->getTempFolderPath().PHP_EOL; |
| 427 | |
| 428 | return $report; |
| 429 | } |
| 430 | |
| 431 | /** |
| 432 | * Get API key (with prefix if set). |
| 433 | * |
| 434 | * @param string $apiKeyIdentifier name of apikey |
| 435 | * |
| 436 | * @return string|null API key with the prefix |
| 437 | */ |
| 438 | public function getApiKeyWithPrefix(string $apiKeyIdentifier): ?string |
| 439 | { |
| 440 | $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); |
| 441 | $apiKey = $this->getApiKey($apiKeyIdentifier); |
| 442 | |
| 443 | if (null === $apiKey) { |
| 444 | return null; |
| 445 | } |
| 446 | |
| 447 | if (null === $prefix) { |
| 448 | $keyWithPrefix = $apiKey; |
| 449 | } else { |
| 450 | $keyWithPrefix = $prefix.' '.$apiKey; |
| 451 | } |
| 452 | |
| 453 | return $keyWithPrefix; |
| 454 | } |
| 455 | } |