Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
59.14% |
634 / 1072 |
|
9.09% |
2 / 22 |
CRAP | |
0.00% |
0 / 1 |
| FingerprintApi | |
59.14% |
634 / 1072 |
|
9.09% |
2 / 22 |
3870.67 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
3 | |||
| getConfig | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| deleteVisitorData | |
80.77% |
42 / 52 |
|
0.00% |
0 / 1 |
11.86 | |||
| deleteVisitorDataAsync | |
0.00% |
0 / 50 |
|
0.00% |
0 / 1 |
90 | |||
| getEvent | |
64.58% |
31 / 48 |
|
0.00% |
0 / 1 |
14.44 | |||
| getEventAsync | |
0.00% |
0 / 46 |
|
0.00% |
0 / 1 |
72 | |||
| getRelatedVisitors | |
75.86% |
44 / 58 |
|
0.00% |
0 / 1 |
14.03 | |||
| getRelatedVisitorsAsync | |
0.00% |
0 / 56 |
|
0.00% |
0 / 1 |
110 | |||
| getVisits | |
66.04% |
35 / 53 |
|
0.00% |
0 / 1 |
15.74 | |||
| getVisitsAsync | |
0.00% |
0 / 51 |
|
0.00% |
0 / 1 |
90 | |||
| searchEvents | |
64.58% |
31 / 48 |
|
0.00% |
0 / 1 |
14.44 | |||
| searchEventsAsync | |
0.00% |
0 / 46 |
|
0.00% |
0 / 1 |
72 | |||
| updateEvent | |
75.00% |
39 / 52 |
|
0.00% |
0 / 1 |
12.89 | |||
| updateEventAsync | |
0.00% |
0 / 50 |
|
0.00% |
0 / 1 |
90 | |||
| deleteVisitorDataRequest | |
87.18% |
34 / 39 |
|
0.00% |
0 / 1 |
9.17 | |||
| getEventRequest | |
87.18% |
34 / 39 |
|
0.00% |
0 / 1 |
9.17 | |||
| getRelatedVisitorsRequest | |
86.84% |
33 / 38 |
|
0.00% |
0 / 1 |
9.18 | |||
| getVisitsRequest | |
73.44% |
47 / 64 |
|
0.00% |
0 / 1 |
17.67 | |||
| searchEventsRequest | |
97.60% |
203 / 208 |
|
0.00% |
0 / 1 |
43 | |||
| updateEventRequest | |
82.00% |
41 / 50 |
|
0.00% |
0 / 1 |
16.31 | |||
| buildQuery | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
7 | |||
| createHttpClientOption | |
50.00% |
3 / 6 |
|
0.00% |
0 / 1 |
4.12 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * FingerprintApi |
| 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\Api; |
| 30 | |
| 31 | use Fingerprint\ServerAPI\ApiException; |
| 32 | use Fingerprint\ServerAPI\Configuration; |
| 33 | use Fingerprint\ServerAPI\Model\EventsUpdateRequest; |
| 34 | use Fingerprint\ServerAPI\Model\ModelInterface; |
| 35 | use Fingerprint\ServerAPI\ObjectSerializer; |
| 36 | use Fingerprint\ServerAPI\SerializationException; |
| 37 | use GuzzleHttp\Client; |
| 38 | use GuzzleHttp\ClientInterface; |
| 39 | use GuzzleHttp\Exception\GuzzleException; |
| 40 | use GuzzleHttp\Exception\RequestException; |
| 41 | use GuzzleHttp\Promise\PromiseInterface; |
| 42 | use GuzzleHttp\Psr7\Request; |
| 43 | use GuzzleHttp\RequestOptions; |
| 44 | use Psr\Http\Message\ResponseInterface; |
| 45 | |
| 46 | /** |
| 47 | * FingerprintApi Class Doc Comment. |
| 48 | * |
| 49 | * @category Class |
| 50 | * |
| 51 | * @author Swagger Codegen team |
| 52 | * |
| 53 | * @see https://github.com/swagger-api/swagger-codegen |
| 54 | */ |
| 55 | class FingerprintApi |
| 56 | { |
| 57 | protected ClientInterface $client; |
| 58 | protected Configuration $config; |
| 59 | |
| 60 | protected string $integration_info = 'fingerprint-pro-server-php-sdk/6.10.0'; |
| 61 | |
| 62 | public function __construct( |
| 63 | ?ClientInterface $client = null, |
| 64 | ?Configuration $config = null |
| 65 | ) { |
| 66 | $this->client = $client ?: new Client(); |
| 67 | $this->config = $config ?: new Configuration(); |
| 68 | } |
| 69 | |
| 70 | public function getConfig(): Configuration |
| 71 | { |
| 72 | return $this->config; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Operation deleteVisitorData. |
| 77 | * |
| 78 | * Delete data by visitor ID |
| 79 | * |
| 80 | * @param string $visitor_id The [visitor ID](https://dev.fingerprint.com/reference/get-function#visitorid) you want to delete. (required) |
| 81 | * |
| 82 | * @return array{ null, \Psr\Http\Message\ResponseInterface } |
| 83 | * |
| 84 | * @throws \InvalidArgumentException |
| 85 | * @throws SerializationException |
| 86 | * @throws GuzzleException |
| 87 | * @throws ApiException |
| 88 | */ |
| 89 | public function deleteVisitorData( |
| 90 | string $visitor_id |
| 91 | ): array { |
| 92 | $returnType = ''; |
| 93 | $request = $this->deleteVisitorDataRequest($visitor_id); |
| 94 | |
| 95 | try { |
| 96 | $options = $this->createHttpClientOption(); |
| 97 | |
| 98 | try { |
| 99 | $response = $this->client->send($request, $options); |
| 100 | } catch (RequestException $e) { |
| 101 | $apiException = new ApiException( |
| 102 | "[{$e->getCode()}] {$e->getMessage()}", |
| 103 | $e->getCode() |
| 104 | ); |
| 105 | $apiException->setResponseObject($e->getResponse()); |
| 106 | |
| 107 | throw $apiException; |
| 108 | } |
| 109 | |
| 110 | $statusCode = $response->getStatusCode(); |
| 111 | |
| 112 | if ($statusCode < 200 || $statusCode > 299) { |
| 113 | $apiException = new ApiException( |
| 114 | sprintf( |
| 115 | '[%d] Error connecting to the API (%s)', |
| 116 | $statusCode, |
| 117 | $request->getUri() |
| 118 | ), |
| 119 | $statusCode |
| 120 | ); |
| 121 | $apiException->setResponseObject($response); |
| 122 | |
| 123 | throw $apiException; |
| 124 | } |
| 125 | |
| 126 | return [null, $response]; |
| 127 | } catch (ApiException $e) { |
| 128 | /** @var ResponseInterface $response */ |
| 129 | $response = $e->getResponseObject(); |
| 130 | |
| 131 | switch ($e->getCode()) { |
| 132 | case 400: |
| 133 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 134 | $e->setErrorDetails($errorDetail); |
| 135 | $e->setResponseObject($response); |
| 136 | |
| 137 | break; |
| 138 | |
| 139 | case 403: |
| 140 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 141 | $e->setErrorDetails($errorDetail); |
| 142 | $e->setResponseObject($response); |
| 143 | |
| 144 | break; |
| 145 | |
| 146 | case 404: |
| 147 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 148 | $e->setErrorDetails($errorDetail); |
| 149 | $e->setResponseObject($response); |
| 150 | |
| 151 | break; |
| 152 | |
| 153 | case 429: |
| 154 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 155 | $e->setErrorDetails($errorDetail); |
| 156 | $e->setResponseObject($response); |
| 157 | |
| 158 | break; |
| 159 | } |
| 160 | |
| 161 | if (429 === $e->getCode()) { |
| 162 | $e->setRetryAfter(1); |
| 163 | if ($response->hasHeader('retry-after')) { |
| 164 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | throw $e; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Operation deleteVisitorDataAsync. |
| 174 | * |
| 175 | * Delete data by visitor ID |
| 176 | * |
| 177 | * @param string $visitor_id The [visitor ID](https://dev.fingerprint.com/reference/get-function#visitorid) you want to delete. (required) |
| 178 | * |
| 179 | * @throws \InvalidArgumentException |
| 180 | * @throws SerializationException |
| 181 | * @throws GuzzleException |
| 182 | * @throws ApiException |
| 183 | */ |
| 184 | public function deleteVisitorDataAsync( |
| 185 | string $visitor_id |
| 186 | ): PromiseInterface { |
| 187 | $returnType = ''; |
| 188 | $request = $this->deleteVisitorDataRequest($visitor_id); |
| 189 | |
| 190 | return $this->client |
| 191 | ->sendAsync($request, $this->createHttpClientOption()) |
| 192 | ->then( |
| 193 | function ($response) use ($request) { |
| 194 | $statusCode = $response->getStatusCode(); |
| 195 | |
| 196 | if ($statusCode < 200 || $statusCode > 299) { |
| 197 | $apiException = new ApiException( |
| 198 | sprintf( |
| 199 | '[%d] Error connecting to the API (%s)', |
| 200 | $statusCode, |
| 201 | $request->getUri() |
| 202 | ), |
| 203 | $statusCode |
| 204 | ); |
| 205 | $apiException->setResponseObject($response); |
| 206 | |
| 207 | throw $apiException; |
| 208 | } |
| 209 | |
| 210 | return [null, $response]; |
| 211 | }, |
| 212 | function ($e) { |
| 213 | /** @var ResponseInterface $response */ |
| 214 | $response = $e->getResponseObject(); |
| 215 | |
| 216 | switch ($e->getCode()) { |
| 217 | case 400: |
| 218 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 219 | $e->setErrorDetails($errorDetail); |
| 220 | $e->setResponseObject($response); |
| 221 | |
| 222 | break; |
| 223 | |
| 224 | case 403: |
| 225 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 226 | $e->setErrorDetails($errorDetail); |
| 227 | $e->setResponseObject($response); |
| 228 | |
| 229 | break; |
| 230 | |
| 231 | case 404: |
| 232 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 233 | $e->setErrorDetails($errorDetail); |
| 234 | $e->setResponseObject($response); |
| 235 | |
| 236 | break; |
| 237 | |
| 238 | case 429: |
| 239 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 240 | $e->setErrorDetails($errorDetail); |
| 241 | $e->setResponseObject($response); |
| 242 | |
| 243 | break; |
| 244 | } |
| 245 | |
| 246 | if (429 === $e->getCode()) { |
| 247 | $e->setRetryAfter(1); |
| 248 | if ($response->hasHeader('retry-after')) { |
| 249 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | throw $e; |
| 254 | } |
| 255 | ); |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * Operation getEvent. |
| 260 | * |
| 261 | * Get event by request ID |
| 262 | * |
| 263 | * @param string $request_id The unique [identifier](https://dev.fingerprint.com/reference/get-function#requestid) of each identification request. (required) |
| 264 | * |
| 265 | * @return array{ \Fingerprint\ServerAPI\Model\EventsGetResponse|null, \Psr\Http\Message\ResponseInterface } |
| 266 | * |
| 267 | * @throws \InvalidArgumentException |
| 268 | * @throws SerializationException |
| 269 | * @throws GuzzleException |
| 270 | * @throws ApiException |
| 271 | */ |
| 272 | public function getEvent( |
| 273 | string $request_id |
| 274 | ): array { |
| 275 | $returnType = '\Fingerprint\ServerAPI\Model\EventsGetResponse'; |
| 276 | $request = $this->getEventRequest($request_id); |
| 277 | |
| 278 | try { |
| 279 | $options = $this->createHttpClientOption(); |
| 280 | |
| 281 | try { |
| 282 | $response = $this->client->send($request, $options); |
| 283 | } catch (RequestException $e) { |
| 284 | $apiException = new ApiException( |
| 285 | "[{$e->getCode()}] {$e->getMessage()}", |
| 286 | $e->getCode() |
| 287 | ); |
| 288 | $apiException->setResponseObject($e->getResponse()); |
| 289 | |
| 290 | throw $apiException; |
| 291 | } |
| 292 | |
| 293 | $statusCode = $response->getStatusCode(); |
| 294 | |
| 295 | if ($statusCode < 200 || $statusCode > 299) { |
| 296 | $apiException = new ApiException( |
| 297 | sprintf( |
| 298 | '[%d] Error connecting to the API (%s)', |
| 299 | $statusCode, |
| 300 | $request->getUri() |
| 301 | ), |
| 302 | $statusCode |
| 303 | ); |
| 304 | $apiException->setResponseObject($response); |
| 305 | |
| 306 | throw $apiException; |
| 307 | } |
| 308 | |
| 309 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
| 310 | |
| 311 | return [$serialized, $response]; |
| 312 | } catch (ApiException $e) { |
| 313 | /** @var ResponseInterface $response */ |
| 314 | $response = $e->getResponseObject(); |
| 315 | |
| 316 | switch ($e->getCode()) { |
| 317 | case 200: |
| 318 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\EventsGetResponse'); |
| 319 | $e->setErrorDetails($errorDetail); |
| 320 | $e->setResponseObject($response); |
| 321 | |
| 322 | break; |
| 323 | |
| 324 | case 403: |
| 325 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 326 | $e->setErrorDetails($errorDetail); |
| 327 | $e->setResponseObject($response); |
| 328 | |
| 329 | break; |
| 330 | |
| 331 | case 404: |
| 332 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 333 | $e->setErrorDetails($errorDetail); |
| 334 | $e->setResponseObject($response); |
| 335 | |
| 336 | break; |
| 337 | } |
| 338 | |
| 339 | if (429 === $e->getCode()) { |
| 340 | $e->setRetryAfter(1); |
| 341 | if ($response->hasHeader('retry-after')) { |
| 342 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | throw $e; |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | /** |
| 351 | * Operation getEventAsync. |
| 352 | * |
| 353 | * Get event by request ID |
| 354 | * |
| 355 | * @param string $request_id The unique [identifier](https://dev.fingerprint.com/reference/get-function#requestid) of each identification request. (required) |
| 356 | * |
| 357 | * @throws \InvalidArgumentException |
| 358 | * @throws SerializationException |
| 359 | * @throws GuzzleException |
| 360 | * @throws ApiException |
| 361 | */ |
| 362 | public function getEventAsync( |
| 363 | string $request_id |
| 364 | ): PromiseInterface { |
| 365 | $returnType = '\Fingerprint\ServerAPI\Model\EventsGetResponse'; |
| 366 | $request = $this->getEventRequest($request_id); |
| 367 | |
| 368 | return $this->client |
| 369 | ->sendAsync($request, $this->createHttpClientOption()) |
| 370 | ->then( |
| 371 | function ($response) use ($returnType, $request) { |
| 372 | $statusCode = $response->getStatusCode(); |
| 373 | |
| 374 | if ($statusCode < 200 || $statusCode > 299) { |
| 375 | $apiException = new ApiException( |
| 376 | sprintf( |
| 377 | '[%d] Error connecting to the API (%s)', |
| 378 | $statusCode, |
| 379 | $request->getUri() |
| 380 | ), |
| 381 | $statusCode |
| 382 | ); |
| 383 | $apiException->setResponseObject($response); |
| 384 | |
| 385 | throw $apiException; |
| 386 | } |
| 387 | |
| 388 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
| 389 | |
| 390 | return [$serialized, $response]; |
| 391 | }, |
| 392 | function ($e) { |
| 393 | /** @var ResponseInterface $response */ |
| 394 | $response = $e->getResponseObject(); |
| 395 | |
| 396 | switch ($e->getCode()) { |
| 397 | case 200: |
| 398 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\EventsGetResponse'); |
| 399 | $e->setErrorDetails($errorDetail); |
| 400 | $e->setResponseObject($response); |
| 401 | |
| 402 | break; |
| 403 | |
| 404 | case 403: |
| 405 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 406 | $e->setErrorDetails($errorDetail); |
| 407 | $e->setResponseObject($response); |
| 408 | |
| 409 | break; |
| 410 | |
| 411 | case 404: |
| 412 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 413 | $e->setErrorDetails($errorDetail); |
| 414 | $e->setResponseObject($response); |
| 415 | |
| 416 | break; |
| 417 | } |
| 418 | |
| 419 | if (429 === $e->getCode()) { |
| 420 | $e->setRetryAfter(1); |
| 421 | if ($response->hasHeader('retry-after')) { |
| 422 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | throw $e; |
| 427 | } |
| 428 | ); |
| 429 | } |
| 430 | |
| 431 | /** |
| 432 | * Operation getRelatedVisitors. |
| 433 | * |
| 434 | * Get Related Visitors |
| 435 | * |
| 436 | * @param string $visitor_id The [visitor ID](https://dev.fingerprint.com/reference/get-function#visitorid) for which you want to find the other visitor IDs that originated from the same mobile device. (required) |
| 437 | * |
| 438 | * @return array{ \Fingerprint\ServerAPI\Model\RelatedVisitorsResponse|null, \Psr\Http\Message\ResponseInterface } |
| 439 | * |
| 440 | * @throws \InvalidArgumentException |
| 441 | * @throws SerializationException |
| 442 | * @throws GuzzleException |
| 443 | * @throws ApiException |
| 444 | */ |
| 445 | public function getRelatedVisitors( |
| 446 | string $visitor_id |
| 447 | ): array { |
| 448 | $returnType = '\Fingerprint\ServerAPI\Model\RelatedVisitorsResponse'; |
| 449 | $request = $this->getRelatedVisitorsRequest($visitor_id); |
| 450 | |
| 451 | try { |
| 452 | $options = $this->createHttpClientOption(); |
| 453 | |
| 454 | try { |
| 455 | $response = $this->client->send($request, $options); |
| 456 | } catch (RequestException $e) { |
| 457 | $apiException = new ApiException( |
| 458 | "[{$e->getCode()}] {$e->getMessage()}", |
| 459 | $e->getCode() |
| 460 | ); |
| 461 | $apiException->setResponseObject($e->getResponse()); |
| 462 | |
| 463 | throw $apiException; |
| 464 | } |
| 465 | |
| 466 | $statusCode = $response->getStatusCode(); |
| 467 | |
| 468 | if ($statusCode < 200 || $statusCode > 299) { |
| 469 | $apiException = new ApiException( |
| 470 | sprintf( |
| 471 | '[%d] Error connecting to the API (%s)', |
| 472 | $statusCode, |
| 473 | $request->getUri() |
| 474 | ), |
| 475 | $statusCode |
| 476 | ); |
| 477 | $apiException->setResponseObject($response); |
| 478 | |
| 479 | throw $apiException; |
| 480 | } |
| 481 | |
| 482 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
| 483 | |
| 484 | return [$serialized, $response]; |
| 485 | } catch (ApiException $e) { |
| 486 | /** @var ResponseInterface $response */ |
| 487 | $response = $e->getResponseObject(); |
| 488 | |
| 489 | switch ($e->getCode()) { |
| 490 | case 200: |
| 491 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\RelatedVisitorsResponse'); |
| 492 | $e->setErrorDetails($errorDetail); |
| 493 | $e->setResponseObject($response); |
| 494 | |
| 495 | break; |
| 496 | |
| 497 | case 400: |
| 498 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 499 | $e->setErrorDetails($errorDetail); |
| 500 | $e->setResponseObject($response); |
| 501 | |
| 502 | break; |
| 503 | |
| 504 | case 403: |
| 505 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 506 | $e->setErrorDetails($errorDetail); |
| 507 | $e->setResponseObject($response); |
| 508 | |
| 509 | break; |
| 510 | |
| 511 | case 404: |
| 512 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 513 | $e->setErrorDetails($errorDetail); |
| 514 | $e->setResponseObject($response); |
| 515 | |
| 516 | break; |
| 517 | |
| 518 | case 429: |
| 519 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 520 | $e->setErrorDetails($errorDetail); |
| 521 | $e->setResponseObject($response); |
| 522 | |
| 523 | break; |
| 524 | } |
| 525 | |
| 526 | if (429 === $e->getCode()) { |
| 527 | $e->setRetryAfter(1); |
| 528 | if ($response->hasHeader('retry-after')) { |
| 529 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | throw $e; |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | /** |
| 538 | * Operation getRelatedVisitorsAsync. |
| 539 | * |
| 540 | * Get Related Visitors |
| 541 | * |
| 542 | * @param string $visitor_id The [visitor ID](https://dev.fingerprint.com/reference/get-function#visitorid) for which you want to find the other visitor IDs that originated from the same mobile device. (required) |
| 543 | * |
| 544 | * @throws \InvalidArgumentException |
| 545 | * @throws SerializationException |
| 546 | * @throws GuzzleException |
| 547 | * @throws ApiException |
| 548 | */ |
| 549 | public function getRelatedVisitorsAsync( |
| 550 | string $visitor_id |
| 551 | ): PromiseInterface { |
| 552 | $returnType = '\Fingerprint\ServerAPI\Model\RelatedVisitorsResponse'; |
| 553 | $request = $this->getRelatedVisitorsRequest($visitor_id); |
| 554 | |
| 555 | return $this->client |
| 556 | ->sendAsync($request, $this->createHttpClientOption()) |
| 557 | ->then( |
| 558 | function ($response) use ($returnType, $request) { |
| 559 | $statusCode = $response->getStatusCode(); |
| 560 | |
| 561 | if ($statusCode < 200 || $statusCode > 299) { |
| 562 | $apiException = new ApiException( |
| 563 | sprintf( |
| 564 | '[%d] Error connecting to the API (%s)', |
| 565 | $statusCode, |
| 566 | $request->getUri() |
| 567 | ), |
| 568 | $statusCode |
| 569 | ); |
| 570 | $apiException->setResponseObject($response); |
| 571 | |
| 572 | throw $apiException; |
| 573 | } |
| 574 | |
| 575 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
| 576 | |
| 577 | return [$serialized, $response]; |
| 578 | }, |
| 579 | function ($e) { |
| 580 | /** @var ResponseInterface $response */ |
| 581 | $response = $e->getResponseObject(); |
| 582 | |
| 583 | switch ($e->getCode()) { |
| 584 | case 200: |
| 585 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\RelatedVisitorsResponse'); |
| 586 | $e->setErrorDetails($errorDetail); |
| 587 | $e->setResponseObject($response); |
| 588 | |
| 589 | break; |
| 590 | |
| 591 | case 400: |
| 592 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 593 | $e->setErrorDetails($errorDetail); |
| 594 | $e->setResponseObject($response); |
| 595 | |
| 596 | break; |
| 597 | |
| 598 | case 403: |
| 599 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 600 | $e->setErrorDetails($errorDetail); |
| 601 | $e->setResponseObject($response); |
| 602 | |
| 603 | break; |
| 604 | |
| 605 | case 404: |
| 606 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 607 | $e->setErrorDetails($errorDetail); |
| 608 | $e->setResponseObject($response); |
| 609 | |
| 610 | break; |
| 611 | |
| 612 | case 429: |
| 613 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 614 | $e->setErrorDetails($errorDetail); |
| 615 | $e->setResponseObject($response); |
| 616 | |
| 617 | break; |
| 618 | } |
| 619 | |
| 620 | if (429 === $e->getCode()) { |
| 621 | $e->setRetryAfter(1); |
| 622 | if ($response->hasHeader('retry-after')) { |
| 623 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | throw $e; |
| 628 | } |
| 629 | ); |
| 630 | } |
| 631 | |
| 632 | /** |
| 633 | * Operation getVisits. |
| 634 | * |
| 635 | * Get visits by visitor ID |
| 636 | * |
| 637 | * @param string $visitor_id Unique [visitor identifier](https://dev.fingerprint.com/reference/get-function#visitorid) issued by Fingerprint Pro. (required) |
| 638 | * @param string $request_id Filter visits by `requestId`. Every identification request has a unique identifier associated with it called `requestId`. This identifier is returned to the client in the identification [result](https://dev.fingerprint.com/reference/get-function#requestid). When you filter visits by `requestId`, only one visit will be returned. (optional) |
| 639 | * @param string $linked_id Filter visits by your custom identifier. You can use [`linkedId`](https://dev.fingerprint.com/reference/get-function#linkedid) to associate identification requests with your own identifier, for example: session ID, purchase ID, or transaction ID. You can then use this `linked_id` parameter to retrieve all events associated with your custom identifier. (optional) |
| 640 | * @param int $limit Limit scanned results. For performance reasons, the API first scans some number of events before filtering them. Use `limit` to specify how many events are scanned before they are filtered by `requestId` or `linkedId`. Results are always returned sorted by the timestamp (most recent first). By default, the most recent 100 visits are scanned, the maximum is 500. (optional) |
| 641 | * @param string $pagination_key Use `paginationKey` to get the next page of results. When more results are available (e.g., you requested 200 results using `limit` parameter, but a total of 600 results are available), the `paginationKey` top-level attribute is added to the response. The key corresponds to the `requestId` of the last returned event. In the following request, use that value in the `paginationKey` parameter to get the next page of results: 1. First request, returning most recent 200 events: `GET api-base-url/visitors/:visitorId?limit=200` 2. Use `response.paginationKey` to get the next page of results: `GET api-base-url/visitors/:visitorId?limit=200&paginationKey=1683900801733.Ogvu1j` Pagination happens during scanning and before filtering, so you can get less visits than the `limit` you specified with more available on the next page. When there are no more results available for scanning, the `paginationKey` attribute is not returned. (optional) |
| 642 | * @param int $before ⚠️ Deprecated pagination method, please use `paginationKey` instead. Timestamp (in milliseconds since epoch) used to paginate results. (optional) |
| 643 | * |
| 644 | * @return array{ \Fingerprint\ServerAPI\Model\VisitorsGetResponse|null, \Psr\Http\Message\ResponseInterface } |
| 645 | * |
| 646 | * @throws \InvalidArgumentException |
| 647 | * @throws SerializationException |
| 648 | * @throws GuzzleException |
| 649 | * @throws ApiException |
| 650 | */ |
| 651 | public function getVisits( |
| 652 | string $visitor_id, |
| 653 | ?string $request_id = null, |
| 654 | ?string $linked_id = null, |
| 655 | ?int $limit = null, |
| 656 | ?string $pagination_key = null, |
| 657 | ?int $before = null |
| 658 | ): array { |
| 659 | $returnType = '\Fingerprint\ServerAPI\Model\VisitorsGetResponse'; |
| 660 | $request = $this->getVisitsRequest($visitor_id, $request_id, $linked_id, $limit, $pagination_key, $before); |
| 661 | |
| 662 | try { |
| 663 | $options = $this->createHttpClientOption(); |
| 664 | |
| 665 | try { |
| 666 | $response = $this->client->send($request, $options); |
| 667 | } catch (RequestException $e) { |
| 668 | $apiException = new ApiException( |
| 669 | "[{$e->getCode()}] {$e->getMessage()}", |
| 670 | $e->getCode() |
| 671 | ); |
| 672 | $apiException->setResponseObject($e->getResponse()); |
| 673 | |
| 674 | throw $apiException; |
| 675 | } |
| 676 | |
| 677 | $statusCode = $response->getStatusCode(); |
| 678 | |
| 679 | if ($statusCode < 200 || $statusCode > 299) { |
| 680 | $apiException = new ApiException( |
| 681 | sprintf( |
| 682 | '[%d] Error connecting to the API (%s)', |
| 683 | $statusCode, |
| 684 | $request->getUri() |
| 685 | ), |
| 686 | $statusCode |
| 687 | ); |
| 688 | $apiException->setResponseObject($response); |
| 689 | |
| 690 | throw $apiException; |
| 691 | } |
| 692 | |
| 693 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
| 694 | |
| 695 | return [$serialized, $response]; |
| 696 | } catch (ApiException $e) { |
| 697 | /** @var ResponseInterface $response */ |
| 698 | $response = $e->getResponseObject(); |
| 699 | |
| 700 | switch ($e->getCode()) { |
| 701 | case 200: |
| 702 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\VisitorsGetResponse'); |
| 703 | $e->setErrorDetails($errorDetail); |
| 704 | $e->setResponseObject($response); |
| 705 | |
| 706 | break; |
| 707 | |
| 708 | case 400: |
| 709 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorPlainResponse'); |
| 710 | $e->setErrorDetails($errorDetail); |
| 711 | $e->setResponseObject($response); |
| 712 | |
| 713 | break; |
| 714 | |
| 715 | case 403: |
| 716 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorPlainResponse'); |
| 717 | $e->setErrorDetails($errorDetail); |
| 718 | $e->setResponseObject($response); |
| 719 | |
| 720 | break; |
| 721 | |
| 722 | case 429: |
| 723 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorPlainResponse'); |
| 724 | $e->setErrorDetails($errorDetail); |
| 725 | $e->setResponseObject($response); |
| 726 | |
| 727 | break; |
| 728 | } |
| 729 | |
| 730 | if (429 === $e->getCode()) { |
| 731 | $e->setRetryAfter(1); |
| 732 | if ($response->hasHeader('retry-after')) { |
| 733 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | throw $e; |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | /** |
| 742 | * Operation getVisitsAsync. |
| 743 | * |
| 744 | * Get visits by visitor ID |
| 745 | * |
| 746 | * @param string $visitor_id Unique [visitor identifier](https://dev.fingerprint.com/reference/get-function#visitorid) issued by Fingerprint Pro. (required) |
| 747 | * @param string $request_id Filter visits by `requestId`. Every identification request has a unique identifier associated with it called `requestId`. This identifier is returned to the client in the identification [result](https://dev.fingerprint.com/reference/get-function#requestid). When you filter visits by `requestId`, only one visit will be returned. (optional) |
| 748 | * @param string $linked_id Filter visits by your custom identifier. You can use [`linkedId`](https://dev.fingerprint.com/reference/get-function#linkedid) to associate identification requests with your own identifier, for example: session ID, purchase ID, or transaction ID. You can then use this `linked_id` parameter to retrieve all events associated with your custom identifier. (optional) |
| 749 | * @param int $limit Limit scanned results. For performance reasons, the API first scans some number of events before filtering them. Use `limit` to specify how many events are scanned before they are filtered by `requestId` or `linkedId`. Results are always returned sorted by the timestamp (most recent first). By default, the most recent 100 visits are scanned, the maximum is 500. (optional) |
| 750 | * @param string $pagination_key Use `paginationKey` to get the next page of results. When more results are available (e.g., you requested 200 results using `limit` parameter, but a total of 600 results are available), the `paginationKey` top-level attribute is added to the response. The key corresponds to the `requestId` of the last returned event. In the following request, use that value in the `paginationKey` parameter to get the next page of results: 1. First request, returning most recent 200 events: `GET api-base-url/visitors/:visitorId?limit=200` 2. Use `response.paginationKey` to get the next page of results: `GET api-base-url/visitors/:visitorId?limit=200&paginationKey=1683900801733.Ogvu1j` Pagination happens during scanning and before filtering, so you can get less visits than the `limit` you specified with more available on the next page. When there are no more results available for scanning, the `paginationKey` attribute is not returned. (optional) |
| 751 | * @param int $before ⚠️ Deprecated pagination method, please use `paginationKey` instead. Timestamp (in milliseconds since epoch) used to paginate results. (optional) |
| 752 | * |
| 753 | * @throws \InvalidArgumentException |
| 754 | * @throws SerializationException |
| 755 | * @throws GuzzleException |
| 756 | * @throws ApiException |
| 757 | */ |
| 758 | public function getVisitsAsync( |
| 759 | string $visitor_id, |
| 760 | ?string $request_id = null, |
| 761 | ?string $linked_id = null, |
| 762 | ?int $limit = null, |
| 763 | ?string $pagination_key = null, |
| 764 | ?int $before = null |
| 765 | ): PromiseInterface { |
| 766 | $returnType = '\Fingerprint\ServerAPI\Model\VisitorsGetResponse'; |
| 767 | $request = $this->getVisitsRequest($visitor_id, $request_id, $linked_id, $limit, $pagination_key, $before); |
| 768 | |
| 769 | return $this->client |
| 770 | ->sendAsync($request, $this->createHttpClientOption()) |
| 771 | ->then( |
| 772 | function ($response) use ($returnType, $request) { |
| 773 | $statusCode = $response->getStatusCode(); |
| 774 | |
| 775 | if ($statusCode < 200 || $statusCode > 299) { |
| 776 | $apiException = new ApiException( |
| 777 | sprintf( |
| 778 | '[%d] Error connecting to the API (%s)', |
| 779 | $statusCode, |
| 780 | $request->getUri() |
| 781 | ), |
| 782 | $statusCode |
| 783 | ); |
| 784 | $apiException->setResponseObject($response); |
| 785 | |
| 786 | throw $apiException; |
| 787 | } |
| 788 | |
| 789 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
| 790 | |
| 791 | return [$serialized, $response]; |
| 792 | }, |
| 793 | function ($e) { |
| 794 | /** @var ResponseInterface $response */ |
| 795 | $response = $e->getResponseObject(); |
| 796 | |
| 797 | switch ($e->getCode()) { |
| 798 | case 200: |
| 799 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\VisitorsGetResponse'); |
| 800 | $e->setErrorDetails($errorDetail); |
| 801 | $e->setResponseObject($response); |
| 802 | |
| 803 | break; |
| 804 | |
| 805 | case 400: |
| 806 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorPlainResponse'); |
| 807 | $e->setErrorDetails($errorDetail); |
| 808 | $e->setResponseObject($response); |
| 809 | |
| 810 | break; |
| 811 | |
| 812 | case 403: |
| 813 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorPlainResponse'); |
| 814 | $e->setErrorDetails($errorDetail); |
| 815 | $e->setResponseObject($response); |
| 816 | |
| 817 | break; |
| 818 | |
| 819 | case 429: |
| 820 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorPlainResponse'); |
| 821 | $e->setErrorDetails($errorDetail); |
| 822 | $e->setResponseObject($response); |
| 823 | |
| 824 | break; |
| 825 | } |
| 826 | |
| 827 | if (429 === $e->getCode()) { |
| 828 | $e->setRetryAfter(1); |
| 829 | if ($response->hasHeader('retry-after')) { |
| 830 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | throw $e; |
| 835 | } |
| 836 | ); |
| 837 | } |
| 838 | |
| 839 | /** |
| 840 | * Operation searchEvents. |
| 841 | * |
| 842 | * Get events via search |
| 843 | * |
| 844 | * @param int $limit Limit the number of events returned. (required) |
| 845 | * @param string $pagination_key Use `pagination_key` to get the next page of results. When more results are available (e.g., you requested up to 200 results for your search using `limit`, but there are more than 200 events total matching your request), the `paginationKey` top-level attribute is added to the response. The key corresponds to the `timestamp` of the last returned event. In the following request, use that value in the `pagination_key` parameter to get the next page of results: 1. First request, returning most recent 200 events: `GET api-base-url/events/search?limit=200` 2. Use `response.paginationKey` to get the next page of results: `GET api-base-url/events/search?limit=200&pagination_key=1740815825085` (optional) |
| 846 | * @param string $visitor_id Unique [visitor identifier](https://dev.fingerprint.com/reference/get-function#visitorid) issued by Fingerprint Pro. Filter for events matching this `visitor_id`. (optional) |
| 847 | * @param string $bot Filter events by the Bot Detection result, specifically: `all` - events where any kind of bot was detected. `good` - events where a good bot was detected. `bad` - events where a bad bot was detected. `none` - events where no bot was detected. > Note: When using this parameter, only events with the `products.botd.data.bot.result` property set to a valid value are returned. Events without a `products.botd` Smart Signal result are left out of the response. (optional) |
| 848 | * @param string $ip_address Filter events by IP address range. The range can be as specific as a single IP (/32 for IPv4 or /128 for IPv6) All ip_address filters must use CIDR notation, for example, 10.0.0.0/24, 192.168.0.1/32 (optional) |
| 849 | * @param string $linked_id Filter events by your custom identifier. You can use [linked IDs](https://dev.fingerprint.com/reference/get-function#linkedid) to associate identification requests with your own identifier, for example, session ID, purchase ID, or transaction ID. You can then use this `linked_id` parameter to retrieve all events associated with your custom identifier. (optional) |
| 850 | * @param int $start Filter events with a timestamp greater than the start time, in Unix time (milliseconds). (optional) |
| 851 | * @param int $end Filter events with a timestamp smaller than the end time, in Unix time (milliseconds). (optional) |
| 852 | * @param bool $reverse Sort events in reverse timestamp order. (optional) |
| 853 | * @param bool $suspect Filter events previously tagged as suspicious via the [Update API](https://dev.fingerprint.com/reference/updateevent). > Note: When using this parameter, only events with the `suspect` property explicitly set to `true` or `false` are returned. Events with undefined `suspect` property are left out of the response. (optional) |
| 854 | * @param bool $vpn Filter events by VPN Detection result. > Note: When using this parameter, only events with the `products.vpn.data.result` property set to `true` or `false` are returned. Events without a `products.vpn` Smart Signal result are left out of the response. (optional) |
| 855 | * @param bool $virtual_machine Filter events by Virtual Machine Detection result. > Note: When using this parameter, only events with the `products.virtualMachine.data.result` property set to `true` or `false` are returned. Events without a `products.virtualMachine` Smart Signal result are left out of the response. (optional) |
| 856 | * @param bool $tampering Filter events by Tampering Detection result. > Note: When using this parameter, only events with the `products.tampering.data.result` property set to `true` or `false` are returned. Events without a `products.tampering` Smart Signal result are left out of the response. (optional) |
| 857 | * @param bool $anti_detect_browser Filter events by Anti-detect Browser Detection result. > Note: When using this parameter, only events with the `products.tampering.data.antiDetectBrowser` property set to `true` or `false` are returned. Events without a `products.tampering` Smart Signal result are left out of the response. (optional) |
| 858 | * @param bool $incognito Filter events by Browser Incognito Detection result. > Note: When using this parameter, only events with the `products.incognito.data.result` property set to `true` or `false` are returned. Events without a `products.incognito` Smart Signal result are left out of the response. (optional) |
| 859 | * @param bool $privacy_settings Filter events by Privacy Settings Detection result. > Note: When using this parameter, only events with the `products.privacySettings.data.result` property set to `true` or `false` are returned. Events without a `products.privacySettings` Smart Signal result are left out of the response. (optional) |
| 860 | * @param bool $jailbroken Filter events by Jailbroken Device Detection result. > Note: When using this parameter, only events with the `products.jailbroken.data.result` property set to `true` or `false` are returned. Events without a `products.jailbroken` Smart Signal result are left out of the response. (optional) |
| 861 | * @param bool $frida Filter events by Frida Detection result. > Note: When using this parameter, only events with the `products.frida.data.result` property set to `true` or `false` are returned. Events without a `products.frida` Smart Signal result are left out of the response. (optional) |
| 862 | * @param bool $factory_reset Filter events by Factory Reset Detection result. > Note: When using this parameter, only events with the `products.factoryReset.data.result` property set to `true` or `false` are returned. Events without a `products.factoryReset` Smart Signal result are left out of the response. (optional) |
| 863 | * @param bool $cloned_app Filter events by Cloned App Detection result. > Note: When using this parameter, only events with the `products.clonedApp.data.result` property set to `true` or `false` are returned. Events without a `products.clonedApp` Smart Signal result are left out of the response. (optional) |
| 864 | * @param bool $emulator Filter events by Android Emulator Detection result. > Note: When using this parameter, only events with the `products.emulator.data.result` property set to `true` or `false` are returned. Events without a `products.emulator` Smart Signal result are left out of the response. (optional) |
| 865 | * @param bool $root_apps Filter events by Rooted Device Detection result. > Note: When using this parameter, only events with the `products.rootApps.data.result` property set to `true` or `false` are returned. Events without a `products.rootApps` Smart Signal result are left out of the response. (optional) |
| 866 | * @param string $vpn_confidence Filter events by VPN Detection result confidence level. `high` - events with high VPN Detection confidence. `medium` - events with medium VPN Detection confidence. `low` - events with low VPN Detection confidence. > Note: When using this parameter, only events with the `products.vpn.data.confidence` property set to a valid value are returned. Events without a `products.vpn` Smart Signal result are left out of the response. (optional) |
| 867 | * @param float $min_suspect_score Filter events with Suspect Score result above a provided minimum threshold. > Note: When using this parameter, only events where the `products.suspectScore.data.result` property set to a value exceeding your threshold are returned. Events without a `products.suspectScore` Smart Signal result are left out of the response. (optional) |
| 868 | * @param bool $ip_blocklist Filter events by IP Blocklist Detection result. > Note: When using this parameter, only events with the `products.ipBlocklist.data.result` property set to `true` or `false` are returned. Events without a `products.ipBlocklist` Smart Signal result are left out of the response. (optional) |
| 869 | * @param bool $datacenter Filter events by Datacenter Detection result. > Note: When using this parameter, only events with the `products.ipInfo.data.v4.datacenter.result` or `products.ipInfo.data.v6.datacenter.result` property set to `true` or `false` are returned. Events without a `products.ipInfo` Smart Signal result are left out of the response. (optional) |
| 870 | * @param bool $developer_tools Filter events by Developer Tools detection result. > Note: When using this parameter, only events with the `products.developerTools.data.result` property set to `true` or `false` are returned. Events without a `products.developerTools` Smart Signal result are left out of the response. (optional) |
| 871 | * @param bool $location_spoofing Filter events by Location Spoofing detection result. > Note: When using this parameter, only events with the `products.locationSpoofing.data.result` property set to `true` or `false` are returned. Events without a `products.locationSpoofing` Smart Signal result are left out of the response. (optional) |
| 872 | * @param bool $mitm_attack Filter events by MITM (Man-in-the-Middle) Attack detection result. > Note: When using this parameter, only events with the `products.mitmAttack.data.result` property set to `true` or `false` are returned. Events without a `products.mitmAttack` Smart Signal result are left out of the response. (optional) |
| 873 | * @param bool $proxy Filter events by Proxy detection result. > Note: When using this parameter, only events with the `products.proxy.data.result` property set to `true` or `false` are returned. Events without a `products.proxy` Smart Signal result are left out of the response. (optional) |
| 874 | * @param string $sdk_version Filter events by a specific SDK version associated with the identification event. Example: `3.11.14` (optional) |
| 875 | * @param string $sdk_platform Filter events by the SDK Platform associated with the identification event. `js` - JavaScript agent (Web). `ios` - Apple iOS based devices. `android` - Android based devices. (optional) |
| 876 | * @param string[] $environment Filter for events by providing one or more environment IDs. (optional) |
| 877 | * @param string $proximity_id Filter events by the most precise Proximity ID provided by default. > Note: When using this parameter, only events with the `products.proximity.id` property matching the provided ID are returned. Events without a `products.proximity` result are left out of the response. (optional) |
| 878 | * @param int $proximity_precision_radius Filter events by Proximity Radius. > Note: When using this parameter, only events with the `products.proximity.precisionRadius` property set to a valid value are returned. Events without a `products.proximity` result are left out of the response. (optional) |
| 879 | * |
| 880 | * @return array{ \Fingerprint\ServerAPI\Model\SearchEventsResponse|null, \Psr\Http\Message\ResponseInterface } |
| 881 | * |
| 882 | * @throws \InvalidArgumentException |
| 883 | * @throws SerializationException |
| 884 | * @throws GuzzleException |
| 885 | * @throws ApiException |
| 886 | */ |
| 887 | public function searchEvents( |
| 888 | int $limit, |
| 889 | ?string $pagination_key = null, |
| 890 | ?string $visitor_id = null, |
| 891 | ?string $bot = null, |
| 892 | ?string $ip_address = null, |
| 893 | ?string $linked_id = null, |
| 894 | ?int $start = null, |
| 895 | ?int $end = null, |
| 896 | ?bool $reverse = null, |
| 897 | ?bool $suspect = null, |
| 898 | ?bool $vpn = null, |
| 899 | ?bool $virtual_machine = null, |
| 900 | ?bool $tampering = null, |
| 901 | ?bool $anti_detect_browser = null, |
| 902 | ?bool $incognito = null, |
| 903 | ?bool $privacy_settings = null, |
| 904 | ?bool $jailbroken = null, |
| 905 | ?bool $frida = null, |
| 906 | ?bool $factory_reset = null, |
| 907 | ?bool $cloned_app = null, |
| 908 | ?bool $emulator = null, |
| 909 | ?bool $root_apps = null, |
| 910 | ?string $vpn_confidence = null, |
| 911 | ?float $min_suspect_score = null, |
| 912 | ?bool $ip_blocklist = null, |
| 913 | ?bool $datacenter = null, |
| 914 | ?bool $developer_tools = null, |
| 915 | ?bool $location_spoofing = null, |
| 916 | ?bool $mitm_attack = null, |
| 917 | ?bool $proxy = null, |
| 918 | ?string $sdk_version = null, |
| 919 | ?string $sdk_platform = null, |
| 920 | ?array $environment = null, |
| 921 | ?string $proximity_id = null, |
| 922 | ?int $proximity_precision_radius = null |
| 923 | ): array { |
| 924 | $returnType = '\Fingerprint\ServerAPI\Model\SearchEventsResponse'; |
| 925 | $request = $this->searchEventsRequest($limit, $pagination_key, $visitor_id, $bot, $ip_address, $linked_id, $start, $end, $reverse, $suspect, $vpn, $virtual_machine, $tampering, $anti_detect_browser, $incognito, $privacy_settings, $jailbroken, $frida, $factory_reset, $cloned_app, $emulator, $root_apps, $vpn_confidence, $min_suspect_score, $ip_blocklist, $datacenter, $developer_tools, $location_spoofing, $mitm_attack, $proxy, $sdk_version, $sdk_platform, $environment, $proximity_id, $proximity_precision_radius); |
| 926 | |
| 927 | try { |
| 928 | $options = $this->createHttpClientOption(); |
| 929 | |
| 930 | try { |
| 931 | $response = $this->client->send($request, $options); |
| 932 | } catch (RequestException $e) { |
| 933 | $apiException = new ApiException( |
| 934 | "[{$e->getCode()}] {$e->getMessage()}", |
| 935 | $e->getCode() |
| 936 | ); |
| 937 | $apiException->setResponseObject($e->getResponse()); |
| 938 | |
| 939 | throw $apiException; |
| 940 | } |
| 941 | |
| 942 | $statusCode = $response->getStatusCode(); |
| 943 | |
| 944 | if ($statusCode < 200 || $statusCode > 299) { |
| 945 | $apiException = new ApiException( |
| 946 | sprintf( |
| 947 | '[%d] Error connecting to the API (%s)', |
| 948 | $statusCode, |
| 949 | $request->getUri() |
| 950 | ), |
| 951 | $statusCode |
| 952 | ); |
| 953 | $apiException->setResponseObject($response); |
| 954 | |
| 955 | throw $apiException; |
| 956 | } |
| 957 | |
| 958 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
| 959 | |
| 960 | return [$serialized, $response]; |
| 961 | } catch (ApiException $e) { |
| 962 | /** @var ResponseInterface $response */ |
| 963 | $response = $e->getResponseObject(); |
| 964 | |
| 965 | switch ($e->getCode()) { |
| 966 | case 200: |
| 967 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\SearchEventsResponse'); |
| 968 | $e->setErrorDetails($errorDetail); |
| 969 | $e->setResponseObject($response); |
| 970 | |
| 971 | break; |
| 972 | |
| 973 | case 400: |
| 974 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 975 | $e->setErrorDetails($errorDetail); |
| 976 | $e->setResponseObject($response); |
| 977 | |
| 978 | break; |
| 979 | |
| 980 | case 403: |
| 981 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 982 | $e->setErrorDetails($errorDetail); |
| 983 | $e->setResponseObject($response); |
| 984 | |
| 985 | break; |
| 986 | } |
| 987 | |
| 988 | if (429 === $e->getCode()) { |
| 989 | $e->setRetryAfter(1); |
| 990 | if ($response->hasHeader('retry-after')) { |
| 991 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
| 992 | } |
| 993 | } |
| 994 | |
| 995 | throw $e; |
| 996 | } |
| 997 | } |
| 998 | |
| 999 | /** |
| 1000 | * Operation searchEventsAsync. |
| 1001 | * |
| 1002 | * Get events via search |
| 1003 | * |
| 1004 | * @param int $limit Limit the number of events returned. (required) |
| 1005 | * @param string $pagination_key Use `pagination_key` to get the next page of results. When more results are available (e.g., you requested up to 200 results for your search using `limit`, but there are more than 200 events total matching your request), the `paginationKey` top-level attribute is added to the response. The key corresponds to the `timestamp` of the last returned event. In the following request, use that value in the `pagination_key` parameter to get the next page of results: 1. First request, returning most recent 200 events: `GET api-base-url/events/search?limit=200` 2. Use `response.paginationKey` to get the next page of results: `GET api-base-url/events/search?limit=200&pagination_key=1740815825085` (optional) |
| 1006 | * @param string $visitor_id Unique [visitor identifier](https://dev.fingerprint.com/reference/get-function#visitorid) issued by Fingerprint Pro. Filter for events matching this `visitor_id`. (optional) |
| 1007 | * @param string $bot Filter events by the Bot Detection result, specifically: `all` - events where any kind of bot was detected. `good` - events where a good bot was detected. `bad` - events where a bad bot was detected. `none` - events where no bot was detected. > Note: When using this parameter, only events with the `products.botd.data.bot.result` property set to a valid value are returned. Events without a `products.botd` Smart Signal result are left out of the response. (optional) |
| 1008 | * @param string $ip_address Filter events by IP address range. The range can be as specific as a single IP (/32 for IPv4 or /128 for IPv6) All ip_address filters must use CIDR notation, for example, 10.0.0.0/24, 192.168.0.1/32 (optional) |
| 1009 | * @param string $linked_id Filter events by your custom identifier. You can use [linked IDs](https://dev.fingerprint.com/reference/get-function#linkedid) to associate identification requests with your own identifier, for example, session ID, purchase ID, or transaction ID. You can then use this `linked_id` parameter to retrieve all events associated with your custom identifier. (optional) |
| 1010 | * @param int $start Filter events with a timestamp greater than the start time, in Unix time (milliseconds). (optional) |
| 1011 | * @param int $end Filter events with a timestamp smaller than the end time, in Unix time (milliseconds). (optional) |
| 1012 | * @param bool $reverse Sort events in reverse timestamp order. (optional) |
| 1013 | * @param bool $suspect Filter events previously tagged as suspicious via the [Update API](https://dev.fingerprint.com/reference/updateevent). > Note: When using this parameter, only events with the `suspect` property explicitly set to `true` or `false` are returned. Events with undefined `suspect` property are left out of the response. (optional) |
| 1014 | * @param bool $vpn Filter events by VPN Detection result. > Note: When using this parameter, only events with the `products.vpn.data.result` property set to `true` or `false` are returned. Events without a `products.vpn` Smart Signal result are left out of the response. (optional) |
| 1015 | * @param bool $virtual_machine Filter events by Virtual Machine Detection result. > Note: When using this parameter, only events with the `products.virtualMachine.data.result` property set to `true` or `false` are returned. Events without a `products.virtualMachine` Smart Signal result are left out of the response. (optional) |
| 1016 | * @param bool $tampering Filter events by Tampering Detection result. > Note: When using this parameter, only events with the `products.tampering.data.result` property set to `true` or `false` are returned. Events without a `products.tampering` Smart Signal result are left out of the response. (optional) |
| 1017 | * @param bool $anti_detect_browser Filter events by Anti-detect Browser Detection result. > Note: When using this parameter, only events with the `products.tampering.data.antiDetectBrowser` property set to `true` or `false` are returned. Events without a `products.tampering` Smart Signal result are left out of the response. (optional) |
| 1018 | * @param bool $incognito Filter events by Browser Incognito Detection result. > Note: When using this parameter, only events with the `products.incognito.data.result` property set to `true` or `false` are returned. Events without a `products.incognito` Smart Signal result are left out of the response. (optional) |
| 1019 | * @param bool $privacy_settings Filter events by Privacy Settings Detection result. > Note: When using this parameter, only events with the `products.privacySettings.data.result` property set to `true` or `false` are returned. Events without a `products.privacySettings` Smart Signal result are left out of the response. (optional) |
| 1020 | * @param bool $jailbroken Filter events by Jailbroken Device Detection result. > Note: When using this parameter, only events with the `products.jailbroken.data.result` property set to `true` or `false` are returned. Events without a `products.jailbroken` Smart Signal result are left out of the response. (optional) |
| 1021 | * @param bool $frida Filter events by Frida Detection result. > Note: When using this parameter, only events with the `products.frida.data.result` property set to `true` or `false` are returned. Events without a `products.frida` Smart Signal result are left out of the response. (optional) |
| 1022 | * @param bool $factory_reset Filter events by Factory Reset Detection result. > Note: When using this parameter, only events with the `products.factoryReset.data.result` property set to `true` or `false` are returned. Events without a `products.factoryReset` Smart Signal result are left out of the response. (optional) |
| 1023 | * @param bool $cloned_app Filter events by Cloned App Detection result. > Note: When using this parameter, only events with the `products.clonedApp.data.result` property set to `true` or `false` are returned. Events without a `products.clonedApp` Smart Signal result are left out of the response. (optional) |
| 1024 | * @param bool $emulator Filter events by Android Emulator Detection result. > Note: When using this parameter, only events with the `products.emulator.data.result` property set to `true` or `false` are returned. Events without a `products.emulator` Smart Signal result are left out of the response. (optional) |
| 1025 | * @param bool $root_apps Filter events by Rooted Device Detection result. > Note: When using this parameter, only events with the `products.rootApps.data.result` property set to `true` or `false` are returned. Events without a `products.rootApps` Smart Signal result are left out of the response. (optional) |
| 1026 | * @param string $vpn_confidence Filter events by VPN Detection result confidence level. `high` - events with high VPN Detection confidence. `medium` - events with medium VPN Detection confidence. `low` - events with low VPN Detection confidence. > Note: When using this parameter, only events with the `products.vpn.data.confidence` property set to a valid value are returned. Events without a `products.vpn` Smart Signal result are left out of the response. (optional) |
| 1027 | * @param float $min_suspect_score Filter events with Suspect Score result above a provided minimum threshold. > Note: When using this parameter, only events where the `products.suspectScore.data.result` property set to a value exceeding your threshold are returned. Events without a `products.suspectScore` Smart Signal result are left out of the response. (optional) |
| 1028 | * @param bool $ip_blocklist Filter events by IP Blocklist Detection result. > Note: When using this parameter, only events with the `products.ipBlocklist.data.result` property set to `true` or `false` are returned. Events without a `products.ipBlocklist` Smart Signal result are left out of the response. (optional) |
| 1029 | * @param bool $datacenter Filter events by Datacenter Detection result. > Note: When using this parameter, only events with the `products.ipInfo.data.v4.datacenter.result` or `products.ipInfo.data.v6.datacenter.result` property set to `true` or `false` are returned. Events without a `products.ipInfo` Smart Signal result are left out of the response. (optional) |
| 1030 | * @param bool $developer_tools Filter events by Developer Tools detection result. > Note: When using this parameter, only events with the `products.developerTools.data.result` property set to `true` or `false` are returned. Events without a `products.developerTools` Smart Signal result are left out of the response. (optional) |
| 1031 | * @param bool $location_spoofing Filter events by Location Spoofing detection result. > Note: When using this parameter, only events with the `products.locationSpoofing.data.result` property set to `true` or `false` are returned. Events without a `products.locationSpoofing` Smart Signal result are left out of the response. (optional) |
| 1032 | * @param bool $mitm_attack Filter events by MITM (Man-in-the-Middle) Attack detection result. > Note: When using this parameter, only events with the `products.mitmAttack.data.result` property set to `true` or `false` are returned. Events without a `products.mitmAttack` Smart Signal result are left out of the response. (optional) |
| 1033 | * @param bool $proxy Filter events by Proxy detection result. > Note: When using this parameter, only events with the `products.proxy.data.result` property set to `true` or `false` are returned. Events without a `products.proxy` Smart Signal result are left out of the response. (optional) |
| 1034 | * @param string $sdk_version Filter events by a specific SDK version associated with the identification event. Example: `3.11.14` (optional) |
| 1035 | * @param string $sdk_platform Filter events by the SDK Platform associated with the identification event. `js` - JavaScript agent (Web). `ios` - Apple iOS based devices. `android` - Android based devices. (optional) |
| 1036 | * @param string[] $environment Filter for events by providing one or more environment IDs. (optional) |
| 1037 | * @param string $proximity_id Filter events by the most precise Proximity ID provided by default. > Note: When using this parameter, only events with the `products.proximity.id` property matching the provided ID are returned. Events without a `products.proximity` result are left out of the response. (optional) |
| 1038 | * @param int $proximity_precision_radius Filter events by Proximity Radius. > Note: When using this parameter, only events with the `products.proximity.precisionRadius` property set to a valid value are returned. Events without a `products.proximity` result are left out of the response. (optional) |
| 1039 | * |
| 1040 | * @throws \InvalidArgumentException |
| 1041 | * @throws SerializationException |
| 1042 | * @throws GuzzleException |
| 1043 | * @throws ApiException |
| 1044 | */ |
| 1045 | public function searchEventsAsync( |
| 1046 | int $limit, |
| 1047 | ?string $pagination_key = null, |
| 1048 | ?string $visitor_id = null, |
| 1049 | ?string $bot = null, |
| 1050 | ?string $ip_address = null, |
| 1051 | ?string $linked_id = null, |
| 1052 | ?int $start = null, |
| 1053 | ?int $end = null, |
| 1054 | ?bool $reverse = null, |
| 1055 | ?bool $suspect = null, |
| 1056 | ?bool $vpn = null, |
| 1057 | ?bool $virtual_machine = null, |
| 1058 | ?bool $tampering = null, |
| 1059 | ?bool $anti_detect_browser = null, |
| 1060 | ?bool $incognito = null, |
| 1061 | ?bool $privacy_settings = null, |
| 1062 | ?bool $jailbroken = null, |
| 1063 | ?bool $frida = null, |
| 1064 | ?bool $factory_reset = null, |
| 1065 | ?bool $cloned_app = null, |
| 1066 | ?bool $emulator = null, |
| 1067 | ?bool $root_apps = null, |
| 1068 | ?string $vpn_confidence = null, |
| 1069 | ?float $min_suspect_score = null, |
| 1070 | ?bool $ip_blocklist = null, |
| 1071 | ?bool $datacenter = null, |
| 1072 | ?bool $developer_tools = null, |
| 1073 | ?bool $location_spoofing = null, |
| 1074 | ?bool $mitm_attack = null, |
| 1075 | ?bool $proxy = null, |
| 1076 | ?string $sdk_version = null, |
| 1077 | ?string $sdk_platform = null, |
| 1078 | ?array $environment = null, |
| 1079 | ?string $proximity_id = null, |
| 1080 | ?int $proximity_precision_radius = null |
| 1081 | ): PromiseInterface { |
| 1082 | $returnType = '\Fingerprint\ServerAPI\Model\SearchEventsResponse'; |
| 1083 | $request = $this->searchEventsRequest($limit, $pagination_key, $visitor_id, $bot, $ip_address, $linked_id, $start, $end, $reverse, $suspect, $vpn, $virtual_machine, $tampering, $anti_detect_browser, $incognito, $privacy_settings, $jailbroken, $frida, $factory_reset, $cloned_app, $emulator, $root_apps, $vpn_confidence, $min_suspect_score, $ip_blocklist, $datacenter, $developer_tools, $location_spoofing, $mitm_attack, $proxy, $sdk_version, $sdk_platform, $environment, $proximity_id, $proximity_precision_radius); |
| 1084 | |
| 1085 | return $this->client |
| 1086 | ->sendAsync($request, $this->createHttpClientOption()) |
| 1087 | ->then( |
| 1088 | function ($response) use ($returnType, $request) { |
| 1089 | $statusCode = $response->getStatusCode(); |
| 1090 | |
| 1091 | if ($statusCode < 200 || $statusCode > 299) { |
| 1092 | $apiException = new ApiException( |
| 1093 | sprintf( |
| 1094 | '[%d] Error connecting to the API (%s)', |
| 1095 | $statusCode, |
| 1096 | $request->getUri() |
| 1097 | ), |
| 1098 | $statusCode |
| 1099 | ); |
| 1100 | $apiException->setResponseObject($response); |
| 1101 | |
| 1102 | throw $apiException; |
| 1103 | } |
| 1104 | |
| 1105 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
| 1106 | |
| 1107 | return [$serialized, $response]; |
| 1108 | }, |
| 1109 | function ($e) { |
| 1110 | /** @var ResponseInterface $response */ |
| 1111 | $response = $e->getResponseObject(); |
| 1112 | |
| 1113 | switch ($e->getCode()) { |
| 1114 | case 200: |
| 1115 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\SearchEventsResponse'); |
| 1116 | $e->setErrorDetails($errorDetail); |
| 1117 | $e->setResponseObject($response); |
| 1118 | |
| 1119 | break; |
| 1120 | |
| 1121 | case 400: |
| 1122 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 1123 | $e->setErrorDetails($errorDetail); |
| 1124 | $e->setResponseObject($response); |
| 1125 | |
| 1126 | break; |
| 1127 | |
| 1128 | case 403: |
| 1129 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 1130 | $e->setErrorDetails($errorDetail); |
| 1131 | $e->setResponseObject($response); |
| 1132 | |
| 1133 | break; |
| 1134 | } |
| 1135 | |
| 1136 | if (429 === $e->getCode()) { |
| 1137 | $e->setRetryAfter(1); |
| 1138 | if ($response->hasHeader('retry-after')) { |
| 1139 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
| 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | throw $e; |
| 1144 | } |
| 1145 | ); |
| 1146 | } |
| 1147 | |
| 1148 | /** |
| 1149 | * Operation updateEvent. |
| 1150 | * |
| 1151 | * Update an event with a given request ID |
| 1152 | * |
| 1153 | * @param EventsUpdateRequest $body (required) |
| 1154 | * @param string $request_id The unique event [identifier](https://dev.fingerprint.com/reference/get-function#requestid). (required) |
| 1155 | * |
| 1156 | * @return array{ null, \Psr\Http\Message\ResponseInterface } |
| 1157 | * |
| 1158 | * @throws \InvalidArgumentException |
| 1159 | * @throws SerializationException |
| 1160 | * @throws GuzzleException |
| 1161 | * @throws ApiException |
| 1162 | */ |
| 1163 | public function updateEvent( |
| 1164 | EventsUpdateRequest $body, |
| 1165 | string $request_id |
| 1166 | ): array { |
| 1167 | $returnType = ''; |
| 1168 | $request = $this->updateEventRequest($body, $request_id); |
| 1169 | |
| 1170 | try { |
| 1171 | $options = $this->createHttpClientOption(); |
| 1172 | |
| 1173 | try { |
| 1174 | $response = $this->client->send($request, $options); |
| 1175 | } catch (RequestException $e) { |
| 1176 | $apiException = new ApiException( |
| 1177 | "[{$e->getCode()}] {$e->getMessage()}", |
| 1178 | $e->getCode() |
| 1179 | ); |
| 1180 | $apiException->setResponseObject($e->getResponse()); |
| 1181 | |
| 1182 | throw $apiException; |
| 1183 | } |
| 1184 | |
| 1185 | $statusCode = $response->getStatusCode(); |
| 1186 | |
| 1187 | if ($statusCode < 200 || $statusCode > 299) { |
| 1188 | $apiException = new ApiException( |
| 1189 | sprintf( |
| 1190 | '[%d] Error connecting to the API (%s)', |
| 1191 | $statusCode, |
| 1192 | $request->getUri() |
| 1193 | ), |
| 1194 | $statusCode |
| 1195 | ); |
| 1196 | $apiException->setResponseObject($response); |
| 1197 | |
| 1198 | throw $apiException; |
| 1199 | } |
| 1200 | |
| 1201 | return [null, $response]; |
| 1202 | } catch (ApiException $e) { |
| 1203 | /** @var ResponseInterface $response */ |
| 1204 | $response = $e->getResponseObject(); |
| 1205 | |
| 1206 | switch ($e->getCode()) { |
| 1207 | case 400: |
| 1208 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 1209 | $e->setErrorDetails($errorDetail); |
| 1210 | $e->setResponseObject($response); |
| 1211 | |
| 1212 | break; |
| 1213 | |
| 1214 | case 403: |
| 1215 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 1216 | $e->setErrorDetails($errorDetail); |
| 1217 | $e->setResponseObject($response); |
| 1218 | |
| 1219 | break; |
| 1220 | |
| 1221 | case 404: |
| 1222 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 1223 | $e->setErrorDetails($errorDetail); |
| 1224 | $e->setResponseObject($response); |
| 1225 | |
| 1226 | break; |
| 1227 | |
| 1228 | case 409: |
| 1229 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 1230 | $e->setErrorDetails($errorDetail); |
| 1231 | $e->setResponseObject($response); |
| 1232 | |
| 1233 | break; |
| 1234 | } |
| 1235 | |
| 1236 | if (429 === $e->getCode()) { |
| 1237 | $e->setRetryAfter(1); |
| 1238 | if ($response->hasHeader('retry-after')) { |
| 1239 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
| 1240 | } |
| 1241 | } |
| 1242 | |
| 1243 | throw $e; |
| 1244 | } |
| 1245 | } |
| 1246 | |
| 1247 | /** |
| 1248 | * Operation updateEventAsync. |
| 1249 | * |
| 1250 | * Update an event with a given request ID |
| 1251 | * |
| 1252 | * @param EventsUpdateRequest $body (required) |
| 1253 | * @param string $request_id The unique event [identifier](https://dev.fingerprint.com/reference/get-function#requestid). (required) |
| 1254 | * |
| 1255 | * @throws \InvalidArgumentException |
| 1256 | * @throws SerializationException |
| 1257 | * @throws GuzzleException |
| 1258 | * @throws ApiException |
| 1259 | */ |
| 1260 | public function updateEventAsync( |
| 1261 | EventsUpdateRequest $body, |
| 1262 | string $request_id |
| 1263 | ): PromiseInterface { |
| 1264 | $returnType = ''; |
| 1265 | $request = $this->updateEventRequest($body, $request_id); |
| 1266 | |
| 1267 | return $this->client |
| 1268 | ->sendAsync($request, $this->createHttpClientOption()) |
| 1269 | ->then( |
| 1270 | function ($response) use ($request) { |
| 1271 | $statusCode = $response->getStatusCode(); |
| 1272 | |
| 1273 | if ($statusCode < 200 || $statusCode > 299) { |
| 1274 | $apiException = new ApiException( |
| 1275 | sprintf( |
| 1276 | '[%d] Error connecting to the API (%s)', |
| 1277 | $statusCode, |
| 1278 | $request->getUri() |
| 1279 | ), |
| 1280 | $statusCode |
| 1281 | ); |
| 1282 | $apiException->setResponseObject($response); |
| 1283 | |
| 1284 | throw $apiException; |
| 1285 | } |
| 1286 | |
| 1287 | return [null, $response]; |
| 1288 | }, |
| 1289 | function ($e) { |
| 1290 | /** @var ResponseInterface $response */ |
| 1291 | $response = $e->getResponseObject(); |
| 1292 | |
| 1293 | switch ($e->getCode()) { |
| 1294 | case 400: |
| 1295 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 1296 | $e->setErrorDetails($errorDetail); |
| 1297 | $e->setResponseObject($response); |
| 1298 | |
| 1299 | break; |
| 1300 | |
| 1301 | case 403: |
| 1302 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 1303 | $e->setErrorDetails($errorDetail); |
| 1304 | $e->setResponseObject($response); |
| 1305 | |
| 1306 | break; |
| 1307 | |
| 1308 | case 404: |
| 1309 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 1310 | $e->setErrorDetails($errorDetail); |
| 1311 | $e->setResponseObject($response); |
| 1312 | |
| 1313 | break; |
| 1314 | |
| 1315 | case 409: |
| 1316 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
| 1317 | $e->setErrorDetails($errorDetail); |
| 1318 | $e->setResponseObject($response); |
| 1319 | |
| 1320 | break; |
| 1321 | } |
| 1322 | |
| 1323 | if (429 === $e->getCode()) { |
| 1324 | $e->setRetryAfter(1); |
| 1325 | if ($response->hasHeader('retry-after')) { |
| 1326 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
| 1327 | } |
| 1328 | } |
| 1329 | |
| 1330 | throw $e; |
| 1331 | } |
| 1332 | ); |
| 1333 | } |
| 1334 | |
| 1335 | /** |
| 1336 | * Create request for operation 'deleteVisitorData'. |
| 1337 | * |
| 1338 | * @throws \InvalidArgumentException |
| 1339 | * @throws SerializationException |
| 1340 | * @throws GuzzleException |
| 1341 | * @throws ApiException |
| 1342 | */ |
| 1343 | protected function deleteVisitorDataRequest( |
| 1344 | string $visitor_id |
| 1345 | ): Request { |
| 1346 | // verify the required parameter 'visitor_id' is set |
| 1347 | if (null === $visitor_id || (is_array($visitor_id) && 0 === count($visitor_id))) { |
| 1348 | throw new \InvalidArgumentException( |
| 1349 | 'Missing the required parameter $visitor_id when calling deleteVisitorData' |
| 1350 | ); |
| 1351 | } |
| 1352 | |
| 1353 | $resourcePath = '/visitors/{visitor_id}'; |
| 1354 | $headers = []; |
| 1355 | $queryParams = ['ii' => $this->integration_info]; |
| 1356 | $headerParams = []; |
| 1357 | $httpBody = ''; |
| 1358 | |
| 1359 | // path params |
| 1360 | if (null !== $visitor_id) { |
| 1361 | $resourcePath = str_replace( |
| 1362 | '{visitor_id}', |
| 1363 | ObjectSerializer::toPathValue($visitor_id), |
| 1364 | $resourcePath |
| 1365 | ); |
| 1366 | } |
| 1367 | |
| 1368 | // this endpoint requires API key authentication |
| 1369 | $apiKey = $this->config->getApiKeyWithPrefix('Auth-API-Key'); |
| 1370 | if (null !== $apiKey) { |
| 1371 | $headers['Auth-API-Key'] = $apiKey; |
| 1372 | } |
| 1373 | // this endpoint requires API key authentication |
| 1374 | $apiKey = $this->config->getApiKeyWithPrefix('api_key'); |
| 1375 | if (null !== $apiKey) { |
| 1376 | $queryParams['api_key'] = $apiKey; |
| 1377 | } |
| 1378 | |
| 1379 | $defaultHeaders = [ |
| 1380 | 'Content-Type' => 'application/json', |
| 1381 | 'Accept' => 'application/json', |
| 1382 | ]; |
| 1383 | if ($this->config->getUserAgent()) { |
| 1384 | $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
| 1385 | } |
| 1386 | |
| 1387 | $headers = array_merge( |
| 1388 | $defaultHeaders, |
| 1389 | $headerParams, |
| 1390 | $headers |
| 1391 | ); |
| 1392 | |
| 1393 | $query = $this->buildQuery($queryParams); |
| 1394 | |
| 1395 | return new Request( |
| 1396 | 'DELETE', |
| 1397 | $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''), |
| 1398 | $headers, |
| 1399 | $httpBody |
| 1400 | ); |
| 1401 | } |
| 1402 | |
| 1403 | /** |
| 1404 | * Create request for operation 'getEvent'. |
| 1405 | * |
| 1406 | * @throws \InvalidArgumentException |
| 1407 | * @throws SerializationException |
| 1408 | * @throws GuzzleException |
| 1409 | * @throws ApiException |
| 1410 | */ |
| 1411 | protected function getEventRequest( |
| 1412 | string $request_id |
| 1413 | ): Request { |
| 1414 | // verify the required parameter 'request_id' is set |
| 1415 | if (null === $request_id || (is_array($request_id) && 0 === count($request_id))) { |
| 1416 | throw new \InvalidArgumentException( |
| 1417 | 'Missing the required parameter $request_id when calling getEvent' |
| 1418 | ); |
| 1419 | } |
| 1420 | |
| 1421 | $resourcePath = '/events/{request_id}'; |
| 1422 | $headers = []; |
| 1423 | $queryParams = ['ii' => $this->integration_info]; |
| 1424 | $headerParams = []; |
| 1425 | $httpBody = ''; |
| 1426 | |
| 1427 | // path params |
| 1428 | if (null !== $request_id) { |
| 1429 | $resourcePath = str_replace( |
| 1430 | '{request_id}', |
| 1431 | ObjectSerializer::toPathValue($request_id), |
| 1432 | $resourcePath |
| 1433 | ); |
| 1434 | } |
| 1435 | |
| 1436 | // this endpoint requires API key authentication |
| 1437 | $apiKey = $this->config->getApiKeyWithPrefix('Auth-API-Key'); |
| 1438 | if (null !== $apiKey) { |
| 1439 | $headers['Auth-API-Key'] = $apiKey; |
| 1440 | } |
| 1441 | // this endpoint requires API key authentication |
| 1442 | $apiKey = $this->config->getApiKeyWithPrefix('api_key'); |
| 1443 | if (null !== $apiKey) { |
| 1444 | $queryParams['api_key'] = $apiKey; |
| 1445 | } |
| 1446 | |
| 1447 | $defaultHeaders = [ |
| 1448 | 'Content-Type' => 'application/json', |
| 1449 | 'Accept' => 'application/json', |
| 1450 | ]; |
| 1451 | if ($this->config->getUserAgent()) { |
| 1452 | $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
| 1453 | } |
| 1454 | |
| 1455 | $headers = array_merge( |
| 1456 | $defaultHeaders, |
| 1457 | $headerParams, |
| 1458 | $headers |
| 1459 | ); |
| 1460 | |
| 1461 | $query = $this->buildQuery($queryParams); |
| 1462 | |
| 1463 | return new Request( |
| 1464 | 'GET', |
| 1465 | $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''), |
| 1466 | $headers, |
| 1467 | $httpBody |
| 1468 | ); |
| 1469 | } |
| 1470 | |
| 1471 | /** |
| 1472 | * Create request for operation 'getRelatedVisitors'. |
| 1473 | * |
| 1474 | * @throws \InvalidArgumentException |
| 1475 | * @throws SerializationException |
| 1476 | * @throws GuzzleException |
| 1477 | * @throws ApiException |
| 1478 | */ |
| 1479 | protected function getRelatedVisitorsRequest( |
| 1480 | string $visitor_id |
| 1481 | ): Request { |
| 1482 | // verify the required parameter 'visitor_id' is set |
| 1483 | if (null === $visitor_id || (is_array($visitor_id) && 0 === count($visitor_id))) { |
| 1484 | throw new \InvalidArgumentException( |
| 1485 | 'Missing the required parameter $visitor_id when calling getRelatedVisitors' |
| 1486 | ); |
| 1487 | } |
| 1488 | |
| 1489 | $resourcePath = '/related-visitors'; |
| 1490 | $headers = []; |
| 1491 | $queryParams = ['ii' => $this->integration_info]; |
| 1492 | $headerParams = []; |
| 1493 | $httpBody = ''; |
| 1494 | |
| 1495 | // query params |
| 1496 | if (null !== $visitor_id) { |
| 1497 | $queryParams['visitor_id'] = ObjectSerializer::toQueryValue( |
| 1498 | $visitor_id, |
| 1499 | null |
| 1500 | ); |
| 1501 | } |
| 1502 | |
| 1503 | // this endpoint requires API key authentication |
| 1504 | $apiKey = $this->config->getApiKeyWithPrefix('Auth-API-Key'); |
| 1505 | if (null !== $apiKey) { |
| 1506 | $headers['Auth-API-Key'] = $apiKey; |
| 1507 | } |
| 1508 | // this endpoint requires API key authentication |
| 1509 | $apiKey = $this->config->getApiKeyWithPrefix('api_key'); |
| 1510 | if (null !== $apiKey) { |
| 1511 | $queryParams['api_key'] = $apiKey; |
| 1512 | } |
| 1513 | |
| 1514 | $defaultHeaders = [ |
| 1515 | 'Content-Type' => 'application/json', |
| 1516 | 'Accept' => 'application/json', |
| 1517 | ]; |
| 1518 | if ($this->config->getUserAgent()) { |
| 1519 | $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
| 1520 | } |
| 1521 | |
| 1522 | $headers = array_merge( |
| 1523 | $defaultHeaders, |
| 1524 | $headerParams, |
| 1525 | $headers |
| 1526 | ); |
| 1527 | |
| 1528 | $query = $this->buildQuery($queryParams); |
| 1529 | |
| 1530 | return new Request( |
| 1531 | 'GET', |
| 1532 | $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''), |
| 1533 | $headers, |
| 1534 | $httpBody |
| 1535 | ); |
| 1536 | } |
| 1537 | |
| 1538 | /** |
| 1539 | * Create request for operation 'getVisits'. |
| 1540 | * |
| 1541 | * @throws \InvalidArgumentException |
| 1542 | * @throws SerializationException |
| 1543 | * @throws GuzzleException |
| 1544 | * @throws ApiException |
| 1545 | */ |
| 1546 | protected function getVisitsRequest( |
| 1547 | string $visitor_id, |
| 1548 | ?string $request_id = null, |
| 1549 | ?string $linked_id = null, |
| 1550 | ?int $limit = null, |
| 1551 | ?string $pagination_key = null, |
| 1552 | ?int $before = null |
| 1553 | ): Request { |
| 1554 | // verify the required parameter 'visitor_id' is set |
| 1555 | if (null === $visitor_id || (is_array($visitor_id) && 0 === count($visitor_id))) { |
| 1556 | throw new \InvalidArgumentException( |
| 1557 | 'Missing the required parameter $visitor_id when calling getVisits' |
| 1558 | ); |
| 1559 | } |
| 1560 | |
| 1561 | $resourcePath = '/visitors/{visitor_id}'; |
| 1562 | $headers = []; |
| 1563 | $queryParams = ['ii' => $this->integration_info]; |
| 1564 | $headerParams = []; |
| 1565 | $httpBody = ''; |
| 1566 | |
| 1567 | // query params |
| 1568 | if (null !== $request_id) { |
| 1569 | $queryParams['request_id'] = ObjectSerializer::toQueryValue( |
| 1570 | $request_id, |
| 1571 | null |
| 1572 | ); |
| 1573 | } |
| 1574 | // query params |
| 1575 | if (null !== $linked_id) { |
| 1576 | $queryParams['linked_id'] = ObjectSerializer::toQueryValue( |
| 1577 | $linked_id, |
| 1578 | null |
| 1579 | ); |
| 1580 | } |
| 1581 | // query params |
| 1582 | if (null !== $limit) { |
| 1583 | $queryParams['limit'] = ObjectSerializer::toQueryValue( |
| 1584 | $limit, |
| 1585 | null |
| 1586 | ); |
| 1587 | } |
| 1588 | // query params |
| 1589 | if (null !== $pagination_key) { |
| 1590 | $queryParams['paginationKey'] = ObjectSerializer::toQueryValue( |
| 1591 | $pagination_key, |
| 1592 | null |
| 1593 | ); |
| 1594 | } |
| 1595 | // query params |
| 1596 | if (null !== $before) { |
| 1597 | $queryParams['before'] = ObjectSerializer::toQueryValue( |
| 1598 | $before, |
| 1599 | null |
| 1600 | ); |
| 1601 | } |
| 1602 | |
| 1603 | // path params |
| 1604 | if (null !== $visitor_id) { |
| 1605 | $resourcePath = str_replace( |
| 1606 | '{visitor_id}', |
| 1607 | ObjectSerializer::toPathValue($visitor_id), |
| 1608 | $resourcePath |
| 1609 | ); |
| 1610 | } |
| 1611 | |
| 1612 | // this endpoint requires API key authentication |
| 1613 | $apiKey = $this->config->getApiKeyWithPrefix('Auth-API-Key'); |
| 1614 | if (null !== $apiKey) { |
| 1615 | $headers['Auth-API-Key'] = $apiKey; |
| 1616 | } |
| 1617 | // this endpoint requires API key authentication |
| 1618 | $apiKey = $this->config->getApiKeyWithPrefix('api_key'); |
| 1619 | if (null !== $apiKey) { |
| 1620 | $queryParams['api_key'] = $apiKey; |
| 1621 | } |
| 1622 | |
| 1623 | $defaultHeaders = [ |
| 1624 | 'Content-Type' => 'application/json', |
| 1625 | 'Accept' => 'application/json', |
| 1626 | ]; |
| 1627 | if ($this->config->getUserAgent()) { |
| 1628 | $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
| 1629 | } |
| 1630 | |
| 1631 | $headers = array_merge( |
| 1632 | $defaultHeaders, |
| 1633 | $headerParams, |
| 1634 | $headers |
| 1635 | ); |
| 1636 | |
| 1637 | $query = $this->buildQuery($queryParams); |
| 1638 | |
| 1639 | return new Request( |
| 1640 | 'GET', |
| 1641 | $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''), |
| 1642 | $headers, |
| 1643 | $httpBody |
| 1644 | ); |
| 1645 | } |
| 1646 | |
| 1647 | /** |
| 1648 | * Create request for operation 'searchEvents'. |
| 1649 | * |
| 1650 | * @throws \InvalidArgumentException |
| 1651 | * @throws SerializationException |
| 1652 | * @throws GuzzleException |
| 1653 | * @throws ApiException |
| 1654 | */ |
| 1655 | protected function searchEventsRequest( |
| 1656 | int $limit, |
| 1657 | ?string $pagination_key = null, |
| 1658 | ?string $visitor_id = null, |
| 1659 | ?string $bot = null, |
| 1660 | ?string $ip_address = null, |
| 1661 | ?string $linked_id = null, |
| 1662 | ?int $start = null, |
| 1663 | ?int $end = null, |
| 1664 | ?bool $reverse = null, |
| 1665 | ?bool $suspect = null, |
| 1666 | ?bool $vpn = null, |
| 1667 | ?bool $virtual_machine = null, |
| 1668 | ?bool $tampering = null, |
| 1669 | ?bool $anti_detect_browser = null, |
| 1670 | ?bool $incognito = null, |
| 1671 | ?bool $privacy_settings = null, |
| 1672 | ?bool $jailbroken = null, |
| 1673 | ?bool $frida = null, |
| 1674 | ?bool $factory_reset = null, |
| 1675 | ?bool $cloned_app = null, |
| 1676 | ?bool $emulator = null, |
| 1677 | ?bool $root_apps = null, |
| 1678 | ?string $vpn_confidence = null, |
| 1679 | ?float $min_suspect_score = null, |
| 1680 | ?bool $ip_blocklist = null, |
| 1681 | ?bool $datacenter = null, |
| 1682 | ?bool $developer_tools = null, |
| 1683 | ?bool $location_spoofing = null, |
| 1684 | ?bool $mitm_attack = null, |
| 1685 | ?bool $proxy = null, |
| 1686 | ?string $sdk_version = null, |
| 1687 | ?string $sdk_platform = null, |
| 1688 | ?array $environment = null, |
| 1689 | ?string $proximity_id = null, |
| 1690 | ?int $proximity_precision_radius = null |
| 1691 | ): Request { |
| 1692 | // verify the required parameter 'limit' is set |
| 1693 | if (null === $limit || (is_array($limit) && 0 === count($limit))) { |
| 1694 | throw new \InvalidArgumentException( |
| 1695 | 'Missing the required parameter $limit when calling searchEvents' |
| 1696 | ); |
| 1697 | } |
| 1698 | |
| 1699 | $resourcePath = '/events/search'; |
| 1700 | $headers = []; |
| 1701 | $queryParams = ['ii' => $this->integration_info]; |
| 1702 | $headerParams = []; |
| 1703 | $httpBody = ''; |
| 1704 | |
| 1705 | // query params |
| 1706 | if (null !== $limit) { |
| 1707 | $queryParams['limit'] = ObjectSerializer::toQueryValue( |
| 1708 | $limit, |
| 1709 | null |
| 1710 | ); |
| 1711 | } |
| 1712 | // query params |
| 1713 | if (null !== $pagination_key) { |
| 1714 | $queryParams['pagination_key'] = ObjectSerializer::toQueryValue( |
| 1715 | $pagination_key, |
| 1716 | null |
| 1717 | ); |
| 1718 | } |
| 1719 | // query params |
| 1720 | if (null !== $visitor_id) { |
| 1721 | $queryParams['visitor_id'] = ObjectSerializer::toQueryValue( |
| 1722 | $visitor_id, |
| 1723 | null |
| 1724 | ); |
| 1725 | } |
| 1726 | // query params |
| 1727 | if (null !== $bot) { |
| 1728 | $queryParams['bot'] = ObjectSerializer::toQueryValue( |
| 1729 | $bot, |
| 1730 | null |
| 1731 | ); |
| 1732 | } |
| 1733 | // query params |
| 1734 | if (null !== $ip_address) { |
| 1735 | $queryParams['ip_address'] = ObjectSerializer::toQueryValue( |
| 1736 | $ip_address, |
| 1737 | null |
| 1738 | ); |
| 1739 | } |
| 1740 | // query params |
| 1741 | if (null !== $linked_id) { |
| 1742 | $queryParams['linked_id'] = ObjectSerializer::toQueryValue( |
| 1743 | $linked_id, |
| 1744 | null |
| 1745 | ); |
| 1746 | } |
| 1747 | // query params |
| 1748 | if (null !== $start) { |
| 1749 | $queryParams['start'] = ObjectSerializer::toQueryValue( |
| 1750 | $start, |
| 1751 | null |
| 1752 | ); |
| 1753 | } |
| 1754 | // query params |
| 1755 | if (null !== $end) { |
| 1756 | $queryParams['end'] = ObjectSerializer::toQueryValue( |
| 1757 | $end, |
| 1758 | null |
| 1759 | ); |
| 1760 | } |
| 1761 | // query params |
| 1762 | if (null !== $reverse) { |
| 1763 | $queryParams['reverse'] = ObjectSerializer::toQueryValue( |
| 1764 | $reverse, |
| 1765 | null |
| 1766 | ); |
| 1767 | } |
| 1768 | // query params |
| 1769 | if (null !== $suspect) { |
| 1770 | $queryParams['suspect'] = ObjectSerializer::toQueryValue( |
| 1771 | $suspect, |
| 1772 | null |
| 1773 | ); |
| 1774 | } |
| 1775 | // query params |
| 1776 | if (null !== $vpn) { |
| 1777 | $queryParams['vpn'] = ObjectSerializer::toQueryValue( |
| 1778 | $vpn, |
| 1779 | null |
| 1780 | ); |
| 1781 | } |
| 1782 | // query params |
| 1783 | if (null !== $virtual_machine) { |
| 1784 | $queryParams['virtual_machine'] = ObjectSerializer::toQueryValue( |
| 1785 | $virtual_machine, |
| 1786 | null |
| 1787 | ); |
| 1788 | } |
| 1789 | // query params |
| 1790 | if (null !== $tampering) { |
| 1791 | $queryParams['tampering'] = ObjectSerializer::toQueryValue( |
| 1792 | $tampering, |
| 1793 | null |
| 1794 | ); |
| 1795 | } |
| 1796 | // query params |
| 1797 | if (null !== $anti_detect_browser) { |
| 1798 | $queryParams['anti_detect_browser'] = ObjectSerializer::toQueryValue( |
| 1799 | $anti_detect_browser, |
| 1800 | null |
| 1801 | ); |
| 1802 | } |
| 1803 | // query params |
| 1804 | if (null !== $incognito) { |
| 1805 | $queryParams['incognito'] = ObjectSerializer::toQueryValue( |
| 1806 | $incognito, |
| 1807 | null |
| 1808 | ); |
| 1809 | } |
| 1810 | // query params |
| 1811 | if (null !== $privacy_settings) { |
| 1812 | $queryParams['privacy_settings'] = ObjectSerializer::toQueryValue( |
| 1813 | $privacy_settings, |
| 1814 | null |
| 1815 | ); |
| 1816 | } |
| 1817 | // query params |
| 1818 | if (null !== $jailbroken) { |
| 1819 | $queryParams['jailbroken'] = ObjectSerializer::toQueryValue( |
| 1820 | $jailbroken, |
| 1821 | null |
| 1822 | ); |
| 1823 | } |
| 1824 | // query params |
| 1825 | if (null !== $frida) { |
| 1826 | $queryParams['frida'] = ObjectSerializer::toQueryValue( |
| 1827 | $frida, |
| 1828 | null |
| 1829 | ); |
| 1830 | } |
| 1831 | // query params |
| 1832 | if (null !== $factory_reset) { |
| 1833 | $queryParams['factory_reset'] = ObjectSerializer::toQueryValue( |
| 1834 | $factory_reset, |
| 1835 | null |
| 1836 | ); |
| 1837 | } |
| 1838 | // query params |
| 1839 | if (null !== $cloned_app) { |
| 1840 | $queryParams['cloned_app'] = ObjectSerializer::toQueryValue( |
| 1841 | $cloned_app, |
| 1842 | null |
| 1843 | ); |
| 1844 | } |
| 1845 | // query params |
| 1846 | if (null !== $emulator) { |
| 1847 | $queryParams['emulator'] = ObjectSerializer::toQueryValue( |
| 1848 | $emulator, |
| 1849 | null |
| 1850 | ); |
| 1851 | } |
| 1852 | // query params |
| 1853 | if (null !== $root_apps) { |
| 1854 | $queryParams['root_apps'] = ObjectSerializer::toQueryValue( |
| 1855 | $root_apps, |
| 1856 | null |
| 1857 | ); |
| 1858 | } |
| 1859 | // query params |
| 1860 | if (null !== $vpn_confidence) { |
| 1861 | $queryParams['vpn_confidence'] = ObjectSerializer::toQueryValue( |
| 1862 | $vpn_confidence, |
| 1863 | null |
| 1864 | ); |
| 1865 | } |
| 1866 | // query params |
| 1867 | if (null !== $min_suspect_score) { |
| 1868 | $queryParams['min_suspect_score'] = ObjectSerializer::toQueryValue( |
| 1869 | $min_suspect_score, |
| 1870 | null |
| 1871 | ); |
| 1872 | } |
| 1873 | // query params |
| 1874 | if (null !== $ip_blocklist) { |
| 1875 | $queryParams['ip_blocklist'] = ObjectSerializer::toQueryValue( |
| 1876 | $ip_blocklist, |
| 1877 | null |
| 1878 | ); |
| 1879 | } |
| 1880 | // query params |
| 1881 | if (null !== $datacenter) { |
| 1882 | $queryParams['datacenter'] = ObjectSerializer::toQueryValue( |
| 1883 | $datacenter, |
| 1884 | null |
| 1885 | ); |
| 1886 | } |
| 1887 | // query params |
| 1888 | if (null !== $developer_tools) { |
| 1889 | $queryParams['developer_tools'] = ObjectSerializer::toQueryValue( |
| 1890 | $developer_tools, |
| 1891 | null |
| 1892 | ); |
| 1893 | } |
| 1894 | // query params |
| 1895 | if (null !== $location_spoofing) { |
| 1896 | $queryParams['location_spoofing'] = ObjectSerializer::toQueryValue( |
| 1897 | $location_spoofing, |
| 1898 | null |
| 1899 | ); |
| 1900 | } |
| 1901 | // query params |
| 1902 | if (null !== $mitm_attack) { |
| 1903 | $queryParams['mitm_attack'] = ObjectSerializer::toQueryValue( |
| 1904 | $mitm_attack, |
| 1905 | null |
| 1906 | ); |
| 1907 | } |
| 1908 | // query params |
| 1909 | if (null !== $proxy) { |
| 1910 | $queryParams['proxy'] = ObjectSerializer::toQueryValue( |
| 1911 | $proxy, |
| 1912 | null |
| 1913 | ); |
| 1914 | } |
| 1915 | // query params |
| 1916 | if (null !== $sdk_version) { |
| 1917 | $queryParams['sdk_version'] = ObjectSerializer::toQueryValue( |
| 1918 | $sdk_version, |
| 1919 | null |
| 1920 | ); |
| 1921 | } |
| 1922 | // query params |
| 1923 | if (null !== $sdk_platform) { |
| 1924 | $queryParams['sdk_platform'] = ObjectSerializer::toQueryValue( |
| 1925 | $sdk_platform, |
| 1926 | null |
| 1927 | ); |
| 1928 | } |
| 1929 | // query params |
| 1930 | if (null !== $environment) { |
| 1931 | $queryParams['environment'] = ObjectSerializer::toQueryValue( |
| 1932 | $environment, |
| 1933 | 'multi' |
| 1934 | ); |
| 1935 | } |
| 1936 | // query params |
| 1937 | if (null !== $proximity_id) { |
| 1938 | $queryParams['proximity_id'] = ObjectSerializer::toQueryValue( |
| 1939 | $proximity_id, |
| 1940 | null |
| 1941 | ); |
| 1942 | } |
| 1943 | // query params |
| 1944 | if (null !== $proximity_precision_radius) { |
| 1945 | $queryParams['proximity_precision_radius'] = ObjectSerializer::toQueryValue( |
| 1946 | $proximity_precision_radius, |
| 1947 | null |
| 1948 | ); |
| 1949 | } |
| 1950 | |
| 1951 | // this endpoint requires API key authentication |
| 1952 | $apiKey = $this->config->getApiKeyWithPrefix('Auth-API-Key'); |
| 1953 | if (null !== $apiKey) { |
| 1954 | $headers['Auth-API-Key'] = $apiKey; |
| 1955 | } |
| 1956 | // this endpoint requires API key authentication |
| 1957 | $apiKey = $this->config->getApiKeyWithPrefix('api_key'); |
| 1958 | if (null !== $apiKey) { |
| 1959 | $queryParams['api_key'] = $apiKey; |
| 1960 | } |
| 1961 | |
| 1962 | $defaultHeaders = [ |
| 1963 | 'Content-Type' => 'application/json', |
| 1964 | 'Accept' => 'application/json', |
| 1965 | ]; |
| 1966 | if ($this->config->getUserAgent()) { |
| 1967 | $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
| 1968 | } |
| 1969 | |
| 1970 | $headers = array_merge( |
| 1971 | $defaultHeaders, |
| 1972 | $headerParams, |
| 1973 | $headers |
| 1974 | ); |
| 1975 | |
| 1976 | $query = $this->buildQuery($queryParams); |
| 1977 | |
| 1978 | return new Request( |
| 1979 | 'GET', |
| 1980 | $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''), |
| 1981 | $headers, |
| 1982 | $httpBody |
| 1983 | ); |
| 1984 | } |
| 1985 | |
| 1986 | /** |
| 1987 | * Create request for operation 'updateEvent'. |
| 1988 | * |
| 1989 | * @throws \InvalidArgumentException |
| 1990 | * @throws SerializationException |
| 1991 | * @throws GuzzleException |
| 1992 | * @throws ApiException |
| 1993 | */ |
| 1994 | protected function updateEventRequest( |
| 1995 | EventsUpdateRequest $body, |
| 1996 | string $request_id |
| 1997 | ): Request { |
| 1998 | // verify the required parameter 'body' is set |
| 1999 | if (null === $body || (is_array($body) && 0 === count($body))) { |
| 2000 | throw new \InvalidArgumentException( |
| 2001 | 'Missing the required parameter $body when calling updateEvent' |
| 2002 | ); |
| 2003 | } |
| 2004 | // verify the required parameter 'request_id' is set |
| 2005 | if (null === $request_id || (is_array($request_id) && 0 === count($request_id))) { |
| 2006 | throw new \InvalidArgumentException( |
| 2007 | 'Missing the required parameter $request_id when calling updateEvent' |
| 2008 | ); |
| 2009 | } |
| 2010 | |
| 2011 | $resourcePath = '/events/{request_id}'; |
| 2012 | $headers = []; |
| 2013 | $queryParams = ['ii' => $this->integration_info]; |
| 2014 | $headerParams = []; |
| 2015 | $httpBody = ''; |
| 2016 | |
| 2017 | // path params |
| 2018 | if (null !== $request_id) { |
| 2019 | $resourcePath = str_replace( |
| 2020 | '{request_id}', |
| 2021 | ObjectSerializer::toPathValue($request_id), |
| 2022 | $resourcePath |
| 2023 | ); |
| 2024 | } |
| 2025 | |
| 2026 | // body params |
| 2027 | $_tempBody = null; |
| 2028 | if (isset($body)) { |
| 2029 | $_tempBody = $body; |
| 2030 | } |
| 2031 | |
| 2032 | // for model (json/xml) |
| 2033 | if (isset($_tempBody)) { |
| 2034 | if ($_tempBody instanceof ModelInterface) { |
| 2035 | $httpBody = (string) $_tempBody; |
| 2036 | } else { |
| 2037 | // $_tempBody is the method argument, if present |
| 2038 | $httpBody = json_encode($_tempBody); |
| 2039 | } |
| 2040 | } |
| 2041 | |
| 2042 | // this endpoint requires API key authentication |
| 2043 | $apiKey = $this->config->getApiKeyWithPrefix('Auth-API-Key'); |
| 2044 | if (null !== $apiKey) { |
| 2045 | $headers['Auth-API-Key'] = $apiKey; |
| 2046 | } |
| 2047 | // this endpoint requires API key authentication |
| 2048 | $apiKey = $this->config->getApiKeyWithPrefix('api_key'); |
| 2049 | if (null !== $apiKey) { |
| 2050 | $queryParams['api_key'] = $apiKey; |
| 2051 | } |
| 2052 | |
| 2053 | $defaultHeaders = [ |
| 2054 | 'Content-Type' => 'application/json', |
| 2055 | 'Accept' => 'application/json', |
| 2056 | ]; |
| 2057 | if ($this->config->getUserAgent()) { |
| 2058 | $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
| 2059 | } |
| 2060 | |
| 2061 | $headers = array_merge( |
| 2062 | $defaultHeaders, |
| 2063 | $headerParams, |
| 2064 | $headers |
| 2065 | ); |
| 2066 | |
| 2067 | $query = $this->buildQuery($queryParams); |
| 2068 | |
| 2069 | return new Request( |
| 2070 | 'PUT', |
| 2071 | $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''), |
| 2072 | $headers, |
| 2073 | $httpBody |
| 2074 | ); |
| 2075 | } |
| 2076 | |
| 2077 | /** |
| 2078 | * Build query string while normalizing indexed arrays to bracket notation: key[]=a&key[]=b. |
| 2079 | */ |
| 2080 | protected function buildQuery(array $params): string |
| 2081 | { |
| 2082 | $sanitizedParams = $params; |
| 2083 | |
| 2084 | foreach ($sanitizedParams as &$value) { |
| 2085 | if (is_array($value)) { |
| 2086 | array_walk_recursive($value, function (&$item) { |
| 2087 | if (null === $item) { |
| 2088 | $item = ''; |
| 2089 | } |
| 2090 | }); |
| 2091 | } |
| 2092 | } |
| 2093 | unset($value); |
| 2094 | |
| 2095 | $qs = http_build_query($sanitizedParams, '', '&', PHP_QUERY_RFC3986); |
| 2096 | |
| 2097 | if ('' === $qs || false === strpos($qs, '%5B')) { |
| 2098 | return $qs; |
| 2099 | } |
| 2100 | |
| 2101 | $parts = explode('&', $qs); |
| 2102 | |
| 2103 | foreach ($parts as $index => $part) { |
| 2104 | $parts[$index] = preg_replace('/([^%5B]+)%5B\d+%5D/', '$1%5B%5D', $part, 1); |
| 2105 | } |
| 2106 | |
| 2107 | return implode('&', $parts); |
| 2108 | } |
| 2109 | |
| 2110 | /** |
| 2111 | * Create http client option. |
| 2112 | * |
| 2113 | * @throws \RuntimeException on file opening failure |
| 2114 | */ |
| 2115 | protected function createHttpClientOption(): array |
| 2116 | { |
| 2117 | $options = []; |
| 2118 | if ($this->config->getDebug()) { |
| 2119 | $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); |
| 2120 | if (!$options[RequestOptions::DEBUG]) { |
| 2121 | throw new \RuntimeException('Failed to open the debug file: '.$this->config->getDebugFile()); |
| 2122 | } |
| 2123 | } |
| 2124 | |
| 2125 | return $options; |
| 2126 | } |
| 2127 | } |