Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
51.47% |
455 / 884 |
|
4.76% |
1 / 21 |
CRAP | |
0.00% |
0 / 1 |
FingerprintApi | |
51.47% |
455 / 884 |
|
4.76% |
1 / 21 |
4725.07 | |
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 | |
85.71% |
30 / 35 |
|
0.00% |
0 / 1 |
9.24 | |||
getVisitsRequest | |
83.67% |
41 / 49 |
|
0.00% |
0 / 1 |
14.85 | |||
searchEventsRequest | |
90.57% |
48 / 53 |
|
0.00% |
0 / 1 |
18.27 | |||
updateEventRequest | |
82.00% |
41 / 50 |
|
0.00% |
0 / 1 |
16.31 | |||
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 Pro Server API. |
15 | * |
16 | * Fingerprint Pro Server API allows you to get information about visitors and about individual 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.4.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(string $visitor_id): array |
90 | { |
91 | $returnType = ''; |
92 | $request = $this->deleteVisitorDataRequest($visitor_id); |
93 | |
94 | try { |
95 | $options = $this->createHttpClientOption(); |
96 | |
97 | try { |
98 | $response = $this->client->send($request, $options); |
99 | } catch (RequestException $e) { |
100 | $apiException = new ApiException( |
101 | "[{$e->getCode()}] {$e->getMessage()}", |
102 | $e->getCode() |
103 | ); |
104 | $apiException->setResponseObject($e->getResponse()); |
105 | |
106 | throw $apiException; |
107 | } |
108 | |
109 | $statusCode = $response->getStatusCode(); |
110 | |
111 | if ($statusCode < 200 || $statusCode > 299) { |
112 | $apiException = new ApiException( |
113 | sprintf( |
114 | '[%d] Error connecting to the API (%s)', |
115 | $statusCode, |
116 | $request->getUri() |
117 | ), |
118 | $statusCode |
119 | ); |
120 | $apiException->setResponseObject($response); |
121 | |
122 | throw $apiException; |
123 | } |
124 | |
125 | return [null, $response]; |
126 | } catch (ApiException $e) { |
127 | /** @var ResponseInterface $response */ |
128 | $response = $e->getResponseObject(); |
129 | |
130 | switch ($e->getCode()) { |
131 | case 400: |
132 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
133 | $e->setErrorDetails($errorDetail); |
134 | $e->setResponseObject($response); |
135 | |
136 | break; |
137 | |
138 | case 403: |
139 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
140 | $e->setErrorDetails($errorDetail); |
141 | $e->setResponseObject($response); |
142 | |
143 | break; |
144 | |
145 | case 404: |
146 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
147 | $e->setErrorDetails($errorDetail); |
148 | $e->setResponseObject($response); |
149 | |
150 | break; |
151 | |
152 | case 429: |
153 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
154 | $e->setErrorDetails($errorDetail); |
155 | $e->setResponseObject($response); |
156 | |
157 | break; |
158 | } |
159 | |
160 | if (429 === $e->getCode()) { |
161 | $e->setRetryAfter(1); |
162 | if ($response->hasHeader('retry-after')) { |
163 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
164 | } |
165 | } |
166 | |
167 | throw $e; |
168 | } |
169 | } |
170 | |
171 | /** |
172 | * Operation deleteVisitorDataAsync. |
173 | * |
174 | * Delete data by visitor ID |
175 | * |
176 | * @param string $visitor_id The [visitor ID](https://dev.fingerprint.com/reference/get-function#visitorid) you want to delete. (required) |
177 | * |
178 | * @throws \InvalidArgumentException |
179 | * @throws SerializationException |
180 | * @throws GuzzleException |
181 | * @throws ApiException |
182 | */ |
183 | public function deleteVisitorDataAsync(string $visitor_id): PromiseInterface |
184 | { |
185 | $returnType = ''; |
186 | $request = $this->deleteVisitorDataRequest($visitor_id); |
187 | |
188 | return $this->client |
189 | ->sendAsync($request, $this->createHttpClientOption()) |
190 | ->then( |
191 | function ($response) use ($request) { |
192 | $statusCode = $response->getStatusCode(); |
193 | |
194 | if ($statusCode < 200 || $statusCode > 299) { |
195 | $apiException = new ApiException( |
196 | sprintf( |
197 | '[%d] Error connecting to the API (%s)', |
198 | $statusCode, |
199 | $request->getUri() |
200 | ), |
201 | $statusCode |
202 | ); |
203 | $apiException->setResponseObject($response); |
204 | |
205 | throw $apiException; |
206 | } |
207 | |
208 | return [null, $response]; |
209 | }, |
210 | function ($e) { |
211 | /** @var ResponseInterface $response */ |
212 | $response = $e->getResponseObject(); |
213 | |
214 | switch ($e->getCode()) { |
215 | case 400: |
216 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
217 | $e->setErrorDetails($errorDetail); |
218 | $e->setResponseObject($response); |
219 | |
220 | break; |
221 | |
222 | case 403: |
223 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
224 | $e->setErrorDetails($errorDetail); |
225 | $e->setResponseObject($response); |
226 | |
227 | break; |
228 | |
229 | case 404: |
230 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
231 | $e->setErrorDetails($errorDetail); |
232 | $e->setResponseObject($response); |
233 | |
234 | break; |
235 | |
236 | case 429: |
237 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
238 | $e->setErrorDetails($errorDetail); |
239 | $e->setResponseObject($response); |
240 | |
241 | break; |
242 | } |
243 | |
244 | if (429 === $e->getCode()) { |
245 | $e->setRetryAfter(1); |
246 | if ($response->hasHeader('retry-after')) { |
247 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
248 | } |
249 | } |
250 | |
251 | throw $e; |
252 | } |
253 | ); |
254 | } |
255 | |
256 | /** |
257 | * Operation getEvent. |
258 | * |
259 | * Get event by request ID |
260 | * |
261 | * @param string $request_id The unique [identifier](https://dev.fingerprint.com/reference/get-function#requestid) of each identification request. (required) |
262 | * |
263 | * @return array{ \Fingerprint\ServerAPI\Model\EventsGetResponse|null, \Psr\Http\Message\ResponseInterface } |
264 | * |
265 | * @throws \InvalidArgumentException |
266 | * @throws SerializationException |
267 | * @throws GuzzleException |
268 | * @throws ApiException |
269 | */ |
270 | public function getEvent(string $request_id): array |
271 | { |
272 | $returnType = '\Fingerprint\ServerAPI\Model\EventsGetResponse'; |
273 | $request = $this->getEventRequest($request_id); |
274 | |
275 | try { |
276 | $options = $this->createHttpClientOption(); |
277 | |
278 | try { |
279 | $response = $this->client->send($request, $options); |
280 | } catch (RequestException $e) { |
281 | $apiException = new ApiException( |
282 | "[{$e->getCode()}] {$e->getMessage()}", |
283 | $e->getCode() |
284 | ); |
285 | $apiException->setResponseObject($e->getResponse()); |
286 | |
287 | throw $apiException; |
288 | } |
289 | |
290 | $statusCode = $response->getStatusCode(); |
291 | |
292 | if ($statusCode < 200 || $statusCode > 299) { |
293 | $apiException = new ApiException( |
294 | sprintf( |
295 | '[%d] Error connecting to the API (%s)', |
296 | $statusCode, |
297 | $request->getUri() |
298 | ), |
299 | $statusCode |
300 | ); |
301 | $apiException->setResponseObject($response); |
302 | |
303 | throw $apiException; |
304 | } |
305 | |
306 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
307 | |
308 | return [$serialized, $response]; |
309 | } catch (ApiException $e) { |
310 | /** @var ResponseInterface $response */ |
311 | $response = $e->getResponseObject(); |
312 | |
313 | switch ($e->getCode()) { |
314 | case 200: |
315 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\EventsGetResponse'); |
316 | $e->setErrorDetails($errorDetail); |
317 | $e->setResponseObject($response); |
318 | |
319 | break; |
320 | |
321 | case 403: |
322 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
323 | $e->setErrorDetails($errorDetail); |
324 | $e->setResponseObject($response); |
325 | |
326 | break; |
327 | |
328 | case 404: |
329 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
330 | $e->setErrorDetails($errorDetail); |
331 | $e->setResponseObject($response); |
332 | |
333 | break; |
334 | } |
335 | |
336 | if (429 === $e->getCode()) { |
337 | $e->setRetryAfter(1); |
338 | if ($response->hasHeader('retry-after')) { |
339 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
340 | } |
341 | } |
342 | |
343 | throw $e; |
344 | } |
345 | } |
346 | |
347 | /** |
348 | * Operation getEventAsync. |
349 | * |
350 | * Get event by request ID |
351 | * |
352 | * @param string $request_id The unique [identifier](https://dev.fingerprint.com/reference/get-function#requestid) of each identification request. (required) |
353 | * |
354 | * @throws \InvalidArgumentException |
355 | * @throws SerializationException |
356 | * @throws GuzzleException |
357 | * @throws ApiException |
358 | */ |
359 | public function getEventAsync(string $request_id): PromiseInterface |
360 | { |
361 | $returnType = '\Fingerprint\ServerAPI\Model\EventsGetResponse'; |
362 | $request = $this->getEventRequest($request_id); |
363 | |
364 | return $this->client |
365 | ->sendAsync($request, $this->createHttpClientOption()) |
366 | ->then( |
367 | function ($response) use ($returnType, $request) { |
368 | $statusCode = $response->getStatusCode(); |
369 | |
370 | if ($statusCode < 200 || $statusCode > 299) { |
371 | $apiException = new ApiException( |
372 | sprintf( |
373 | '[%d] Error connecting to the API (%s)', |
374 | $statusCode, |
375 | $request->getUri() |
376 | ), |
377 | $statusCode |
378 | ); |
379 | $apiException->setResponseObject($response); |
380 | |
381 | throw $apiException; |
382 | } |
383 | |
384 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
385 | |
386 | return [$serialized, $response]; |
387 | }, |
388 | function ($e) { |
389 | /** @var ResponseInterface $response */ |
390 | $response = $e->getResponseObject(); |
391 | |
392 | switch ($e->getCode()) { |
393 | case 200: |
394 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\EventsGetResponse'); |
395 | $e->setErrorDetails($errorDetail); |
396 | $e->setResponseObject($response); |
397 | |
398 | break; |
399 | |
400 | case 403: |
401 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
402 | $e->setErrorDetails($errorDetail); |
403 | $e->setResponseObject($response); |
404 | |
405 | break; |
406 | |
407 | case 404: |
408 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
409 | $e->setErrorDetails($errorDetail); |
410 | $e->setResponseObject($response); |
411 | |
412 | break; |
413 | } |
414 | |
415 | if (429 === $e->getCode()) { |
416 | $e->setRetryAfter(1); |
417 | if ($response->hasHeader('retry-after')) { |
418 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
419 | } |
420 | } |
421 | |
422 | throw $e; |
423 | } |
424 | ); |
425 | } |
426 | |
427 | /** |
428 | * Operation getRelatedVisitors. |
429 | * |
430 | * Get Related Visitors |
431 | * |
432 | * @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) |
433 | * |
434 | * @return array{ \Fingerprint\ServerAPI\Model\RelatedVisitorsResponse|null, \Psr\Http\Message\ResponseInterface } |
435 | * |
436 | * @throws \InvalidArgumentException |
437 | * @throws SerializationException |
438 | * @throws GuzzleException |
439 | * @throws ApiException |
440 | */ |
441 | public function getRelatedVisitors(string $visitor_id): array |
442 | { |
443 | $returnType = '\Fingerprint\ServerAPI\Model\RelatedVisitorsResponse'; |
444 | $request = $this->getRelatedVisitorsRequest($visitor_id); |
445 | |
446 | try { |
447 | $options = $this->createHttpClientOption(); |
448 | |
449 | try { |
450 | $response = $this->client->send($request, $options); |
451 | } catch (RequestException $e) { |
452 | $apiException = new ApiException( |
453 | "[{$e->getCode()}] {$e->getMessage()}", |
454 | $e->getCode() |
455 | ); |
456 | $apiException->setResponseObject($e->getResponse()); |
457 | |
458 | throw $apiException; |
459 | } |
460 | |
461 | $statusCode = $response->getStatusCode(); |
462 | |
463 | if ($statusCode < 200 || $statusCode > 299) { |
464 | $apiException = new ApiException( |
465 | sprintf( |
466 | '[%d] Error connecting to the API (%s)', |
467 | $statusCode, |
468 | $request->getUri() |
469 | ), |
470 | $statusCode |
471 | ); |
472 | $apiException->setResponseObject($response); |
473 | |
474 | throw $apiException; |
475 | } |
476 | |
477 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
478 | |
479 | return [$serialized, $response]; |
480 | } catch (ApiException $e) { |
481 | /** @var ResponseInterface $response */ |
482 | $response = $e->getResponseObject(); |
483 | |
484 | switch ($e->getCode()) { |
485 | case 200: |
486 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\RelatedVisitorsResponse'); |
487 | $e->setErrorDetails($errorDetail); |
488 | $e->setResponseObject($response); |
489 | |
490 | break; |
491 | |
492 | case 400: |
493 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
494 | $e->setErrorDetails($errorDetail); |
495 | $e->setResponseObject($response); |
496 | |
497 | break; |
498 | |
499 | case 403: |
500 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
501 | $e->setErrorDetails($errorDetail); |
502 | $e->setResponseObject($response); |
503 | |
504 | break; |
505 | |
506 | case 404: |
507 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
508 | $e->setErrorDetails($errorDetail); |
509 | $e->setResponseObject($response); |
510 | |
511 | break; |
512 | |
513 | case 429: |
514 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
515 | $e->setErrorDetails($errorDetail); |
516 | $e->setResponseObject($response); |
517 | |
518 | break; |
519 | } |
520 | |
521 | if (429 === $e->getCode()) { |
522 | $e->setRetryAfter(1); |
523 | if ($response->hasHeader('retry-after')) { |
524 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
525 | } |
526 | } |
527 | |
528 | throw $e; |
529 | } |
530 | } |
531 | |
532 | /** |
533 | * Operation getRelatedVisitorsAsync. |
534 | * |
535 | * Get Related Visitors |
536 | * |
537 | * @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) |
538 | * |
539 | * @throws \InvalidArgumentException |
540 | * @throws SerializationException |
541 | * @throws GuzzleException |
542 | * @throws ApiException |
543 | */ |
544 | public function getRelatedVisitorsAsync(string $visitor_id): PromiseInterface |
545 | { |
546 | $returnType = '\Fingerprint\ServerAPI\Model\RelatedVisitorsResponse'; |
547 | $request = $this->getRelatedVisitorsRequest($visitor_id); |
548 | |
549 | return $this->client |
550 | ->sendAsync($request, $this->createHttpClientOption()) |
551 | ->then( |
552 | function ($response) use ($returnType, $request) { |
553 | $statusCode = $response->getStatusCode(); |
554 | |
555 | if ($statusCode < 200 || $statusCode > 299) { |
556 | $apiException = new ApiException( |
557 | sprintf( |
558 | '[%d] Error connecting to the API (%s)', |
559 | $statusCode, |
560 | $request->getUri() |
561 | ), |
562 | $statusCode |
563 | ); |
564 | $apiException->setResponseObject($response); |
565 | |
566 | throw $apiException; |
567 | } |
568 | |
569 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
570 | |
571 | return [$serialized, $response]; |
572 | }, |
573 | function ($e) { |
574 | /** @var ResponseInterface $response */ |
575 | $response = $e->getResponseObject(); |
576 | |
577 | switch ($e->getCode()) { |
578 | case 200: |
579 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\RelatedVisitorsResponse'); |
580 | $e->setErrorDetails($errorDetail); |
581 | $e->setResponseObject($response); |
582 | |
583 | break; |
584 | |
585 | case 400: |
586 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
587 | $e->setErrorDetails($errorDetail); |
588 | $e->setResponseObject($response); |
589 | |
590 | break; |
591 | |
592 | case 403: |
593 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
594 | $e->setErrorDetails($errorDetail); |
595 | $e->setResponseObject($response); |
596 | |
597 | break; |
598 | |
599 | case 404: |
600 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
601 | $e->setErrorDetails($errorDetail); |
602 | $e->setResponseObject($response); |
603 | |
604 | break; |
605 | |
606 | case 429: |
607 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
608 | $e->setErrorDetails($errorDetail); |
609 | $e->setResponseObject($response); |
610 | |
611 | break; |
612 | } |
613 | |
614 | if (429 === $e->getCode()) { |
615 | $e->setRetryAfter(1); |
616 | if ($response->hasHeader('retry-after')) { |
617 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
618 | } |
619 | } |
620 | |
621 | throw $e; |
622 | } |
623 | ); |
624 | } |
625 | |
626 | /** |
627 | * Operation getVisits. |
628 | * |
629 | * Get visits by visitor ID |
630 | * |
631 | * @param string $visitor_id Unique [visitor identifier](https://dev.fingerprint.com/reference/get-function#visitorid) issued by Fingerprint Pro. (required) |
632 | * @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) |
633 | * @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) |
634 | * @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) |
635 | * @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) |
636 | * @param int $before ⚠️ Deprecated pagination method, please use `paginationKey` instead. Timestamp (in milliseconds since epoch) used to paginate results. (optional) |
637 | * |
638 | * @return array{ \Fingerprint\ServerAPI\Model\VisitorsGetResponse|null, \Psr\Http\Message\ResponseInterface } |
639 | * |
640 | * @throws \InvalidArgumentException |
641 | * @throws SerializationException |
642 | * @throws GuzzleException |
643 | * @throws ApiException |
644 | */ |
645 | public function getVisits(string $visitor_id, ?string $request_id = null, ?string $linked_id = null, ?int $limit = null, ?string $pagination_key = null, ?int $before = null): array |
646 | { |
647 | $returnType = '\Fingerprint\ServerAPI\Model\VisitorsGetResponse'; |
648 | $request = $this->getVisitsRequest($visitor_id, $request_id, $linked_id, $limit, $pagination_key, $before); |
649 | |
650 | try { |
651 | $options = $this->createHttpClientOption(); |
652 | |
653 | try { |
654 | $response = $this->client->send($request, $options); |
655 | } catch (RequestException $e) { |
656 | $apiException = new ApiException( |
657 | "[{$e->getCode()}] {$e->getMessage()}", |
658 | $e->getCode() |
659 | ); |
660 | $apiException->setResponseObject($e->getResponse()); |
661 | |
662 | throw $apiException; |
663 | } |
664 | |
665 | $statusCode = $response->getStatusCode(); |
666 | |
667 | if ($statusCode < 200 || $statusCode > 299) { |
668 | $apiException = new ApiException( |
669 | sprintf( |
670 | '[%d] Error connecting to the API (%s)', |
671 | $statusCode, |
672 | $request->getUri() |
673 | ), |
674 | $statusCode |
675 | ); |
676 | $apiException->setResponseObject($response); |
677 | |
678 | throw $apiException; |
679 | } |
680 | |
681 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
682 | |
683 | return [$serialized, $response]; |
684 | } catch (ApiException $e) { |
685 | /** @var ResponseInterface $response */ |
686 | $response = $e->getResponseObject(); |
687 | |
688 | switch ($e->getCode()) { |
689 | case 200: |
690 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\VisitorsGetResponse'); |
691 | $e->setErrorDetails($errorDetail); |
692 | $e->setResponseObject($response); |
693 | |
694 | break; |
695 | |
696 | case 400: |
697 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorPlainResponse'); |
698 | $e->setErrorDetails($errorDetail); |
699 | $e->setResponseObject($response); |
700 | |
701 | break; |
702 | |
703 | case 403: |
704 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorPlainResponse'); |
705 | $e->setErrorDetails($errorDetail); |
706 | $e->setResponseObject($response); |
707 | |
708 | break; |
709 | |
710 | case 429: |
711 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorPlainResponse'); |
712 | $e->setErrorDetails($errorDetail); |
713 | $e->setResponseObject($response); |
714 | |
715 | break; |
716 | } |
717 | |
718 | if (429 === $e->getCode()) { |
719 | $e->setRetryAfter(1); |
720 | if ($response->hasHeader('retry-after')) { |
721 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
722 | } |
723 | } |
724 | |
725 | throw $e; |
726 | } |
727 | } |
728 | |
729 | /** |
730 | * Operation getVisitsAsync. |
731 | * |
732 | * Get visits by visitor ID |
733 | * |
734 | * @param string $visitor_id Unique [visitor identifier](https://dev.fingerprint.com/reference/get-function#visitorid) issued by Fingerprint Pro. (required) |
735 | * @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) |
736 | * @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) |
737 | * @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) |
738 | * @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) |
739 | * @param int $before ⚠️ Deprecated pagination method, please use `paginationKey` instead. Timestamp (in milliseconds since epoch) used to paginate results. (optional) |
740 | * |
741 | * @throws \InvalidArgumentException |
742 | * @throws SerializationException |
743 | * @throws GuzzleException |
744 | * @throws ApiException |
745 | */ |
746 | public function getVisitsAsync(string $visitor_id, ?string $request_id = null, ?string $linked_id = null, ?int $limit = null, ?string $pagination_key = null, ?int $before = null): PromiseInterface |
747 | { |
748 | $returnType = '\Fingerprint\ServerAPI\Model\VisitorsGetResponse'; |
749 | $request = $this->getVisitsRequest($visitor_id, $request_id, $linked_id, $limit, $pagination_key, $before); |
750 | |
751 | return $this->client |
752 | ->sendAsync($request, $this->createHttpClientOption()) |
753 | ->then( |
754 | function ($response) use ($returnType, $request) { |
755 | $statusCode = $response->getStatusCode(); |
756 | |
757 | if ($statusCode < 200 || $statusCode > 299) { |
758 | $apiException = new ApiException( |
759 | sprintf( |
760 | '[%d] Error connecting to the API (%s)', |
761 | $statusCode, |
762 | $request->getUri() |
763 | ), |
764 | $statusCode |
765 | ); |
766 | $apiException->setResponseObject($response); |
767 | |
768 | throw $apiException; |
769 | } |
770 | |
771 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
772 | |
773 | return [$serialized, $response]; |
774 | }, |
775 | function ($e) { |
776 | /** @var ResponseInterface $response */ |
777 | $response = $e->getResponseObject(); |
778 | |
779 | switch ($e->getCode()) { |
780 | case 200: |
781 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\VisitorsGetResponse'); |
782 | $e->setErrorDetails($errorDetail); |
783 | $e->setResponseObject($response); |
784 | |
785 | break; |
786 | |
787 | case 400: |
788 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorPlainResponse'); |
789 | $e->setErrorDetails($errorDetail); |
790 | $e->setResponseObject($response); |
791 | |
792 | break; |
793 | |
794 | case 403: |
795 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorPlainResponse'); |
796 | $e->setErrorDetails($errorDetail); |
797 | $e->setResponseObject($response); |
798 | |
799 | break; |
800 | |
801 | case 429: |
802 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorPlainResponse'); |
803 | $e->setErrorDetails($errorDetail); |
804 | $e->setResponseObject($response); |
805 | |
806 | break; |
807 | } |
808 | |
809 | if (429 === $e->getCode()) { |
810 | $e->setRetryAfter(1); |
811 | if ($response->hasHeader('retry-after')) { |
812 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
813 | } |
814 | } |
815 | |
816 | throw $e; |
817 | } |
818 | ); |
819 | } |
820 | |
821 | /** |
822 | * Operation searchEvents. |
823 | * |
824 | * Get events via search |
825 | * |
826 | * @param int $limit Limit the number of events returned. (required) |
827 | * @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) |
828 | * @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) |
829 | * @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. (optional) |
830 | * @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) |
831 | * @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) |
832 | * @param int $start Filter events with a timestamp greater than the start time, in Unix time (milliseconds). (optional) |
833 | * @param int $end Filter events with a timestamp smaller than the end time, in Unix time (milliseconds). (optional) |
834 | * @param bool $reverse Sort events in reverse timestamp order. (optional) |
835 | * @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) |
836 | * |
837 | * @return array{ \Fingerprint\ServerAPI\Model\SearchEventsResponse|null, \Psr\Http\Message\ResponseInterface } |
838 | * |
839 | * @throws \InvalidArgumentException |
840 | * @throws SerializationException |
841 | * @throws GuzzleException |
842 | * @throws ApiException |
843 | */ |
844 | public function searchEvents(int $limit, ?string $pagination_key = null, ?string $visitor_id = null, ?string $bot = null, ?string $ip_address = null, ?string $linked_id = null, ?int $start = null, ?int $end = null, ?bool $reverse = null, ?bool $suspect = null): array |
845 | { |
846 | $returnType = '\Fingerprint\ServerAPI\Model\SearchEventsResponse'; |
847 | $request = $this->searchEventsRequest($limit, $pagination_key, $visitor_id, $bot, $ip_address, $linked_id, $start, $end, $reverse, $suspect); |
848 | |
849 | try { |
850 | $options = $this->createHttpClientOption(); |
851 | |
852 | try { |
853 | $response = $this->client->send($request, $options); |
854 | } catch (RequestException $e) { |
855 | $apiException = new ApiException( |
856 | "[{$e->getCode()}] {$e->getMessage()}", |
857 | $e->getCode() |
858 | ); |
859 | $apiException->setResponseObject($e->getResponse()); |
860 | |
861 | throw $apiException; |
862 | } |
863 | |
864 | $statusCode = $response->getStatusCode(); |
865 | |
866 | if ($statusCode < 200 || $statusCode > 299) { |
867 | $apiException = new ApiException( |
868 | sprintf( |
869 | '[%d] Error connecting to the API (%s)', |
870 | $statusCode, |
871 | $request->getUri() |
872 | ), |
873 | $statusCode |
874 | ); |
875 | $apiException->setResponseObject($response); |
876 | |
877 | throw $apiException; |
878 | } |
879 | |
880 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
881 | |
882 | return [$serialized, $response]; |
883 | } catch (ApiException $e) { |
884 | /** @var ResponseInterface $response */ |
885 | $response = $e->getResponseObject(); |
886 | |
887 | switch ($e->getCode()) { |
888 | case 200: |
889 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\SearchEventsResponse'); |
890 | $e->setErrorDetails($errorDetail); |
891 | $e->setResponseObject($response); |
892 | |
893 | break; |
894 | |
895 | case 400: |
896 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
897 | $e->setErrorDetails($errorDetail); |
898 | $e->setResponseObject($response); |
899 | |
900 | break; |
901 | |
902 | case 403: |
903 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
904 | $e->setErrorDetails($errorDetail); |
905 | $e->setResponseObject($response); |
906 | |
907 | break; |
908 | } |
909 | |
910 | if (429 === $e->getCode()) { |
911 | $e->setRetryAfter(1); |
912 | if ($response->hasHeader('retry-after')) { |
913 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
914 | } |
915 | } |
916 | |
917 | throw $e; |
918 | } |
919 | } |
920 | |
921 | /** |
922 | * Operation searchEventsAsync. |
923 | * |
924 | * Get events via search |
925 | * |
926 | * @param int $limit Limit the number of events returned. (required) |
927 | * @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) |
928 | * @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) |
929 | * @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. (optional) |
930 | * @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) |
931 | * @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) |
932 | * @param int $start Filter events with a timestamp greater than the start time, in Unix time (milliseconds). (optional) |
933 | * @param int $end Filter events with a timestamp smaller than the end time, in Unix time (milliseconds). (optional) |
934 | * @param bool $reverse Sort events in reverse timestamp order. (optional) |
935 | * @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) |
936 | * |
937 | * @throws \InvalidArgumentException |
938 | * @throws SerializationException |
939 | * @throws GuzzleException |
940 | * @throws ApiException |
941 | */ |
942 | public function searchEventsAsync(int $limit, ?string $pagination_key = null, ?string $visitor_id = null, ?string $bot = null, ?string $ip_address = null, ?string $linked_id = null, ?int $start = null, ?int $end = null, ?bool $reverse = null, ?bool $suspect = null): PromiseInterface |
943 | { |
944 | $returnType = '\Fingerprint\ServerAPI\Model\SearchEventsResponse'; |
945 | $request = $this->searchEventsRequest($limit, $pagination_key, $visitor_id, $bot, $ip_address, $linked_id, $start, $end, $reverse, $suspect); |
946 | |
947 | return $this->client |
948 | ->sendAsync($request, $this->createHttpClientOption()) |
949 | ->then( |
950 | function ($response) use ($returnType, $request) { |
951 | $statusCode = $response->getStatusCode(); |
952 | |
953 | if ($statusCode < 200 || $statusCode > 299) { |
954 | $apiException = new ApiException( |
955 | sprintf( |
956 | '[%d] Error connecting to the API (%s)', |
957 | $statusCode, |
958 | $request->getUri() |
959 | ), |
960 | $statusCode |
961 | ); |
962 | $apiException->setResponseObject($response); |
963 | |
964 | throw $apiException; |
965 | } |
966 | |
967 | $serialized = ObjectSerializer::deserialize($response, $returnType); |
968 | |
969 | return [$serialized, $response]; |
970 | }, |
971 | function ($e) { |
972 | /** @var ResponseInterface $response */ |
973 | $response = $e->getResponseObject(); |
974 | |
975 | switch ($e->getCode()) { |
976 | case 200: |
977 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\SearchEventsResponse'); |
978 | $e->setErrorDetails($errorDetail); |
979 | $e->setResponseObject($response); |
980 | |
981 | break; |
982 | |
983 | case 400: |
984 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
985 | $e->setErrorDetails($errorDetail); |
986 | $e->setResponseObject($response); |
987 | |
988 | break; |
989 | |
990 | case 403: |
991 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
992 | $e->setErrorDetails($errorDetail); |
993 | $e->setResponseObject($response); |
994 | |
995 | break; |
996 | } |
997 | |
998 | if (429 === $e->getCode()) { |
999 | $e->setRetryAfter(1); |
1000 | if ($response->hasHeader('retry-after')) { |
1001 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
1002 | } |
1003 | } |
1004 | |
1005 | throw $e; |
1006 | } |
1007 | ); |
1008 | } |
1009 | |
1010 | /** |
1011 | * Operation updateEvent. |
1012 | * |
1013 | * Update an event with a given request ID |
1014 | * |
1015 | * @param EventsUpdateRequest $body (required) |
1016 | * @param string $request_id The unique event [identifier](https://dev.fingerprint.com/reference/get-function#requestid). (required) |
1017 | * |
1018 | * @return array{ null, \Psr\Http\Message\ResponseInterface } |
1019 | * |
1020 | * @throws \InvalidArgumentException |
1021 | * @throws SerializationException |
1022 | * @throws GuzzleException |
1023 | * @throws ApiException |
1024 | */ |
1025 | public function updateEvent(EventsUpdateRequest $body, string $request_id): array |
1026 | { |
1027 | $returnType = ''; |
1028 | $request = $this->updateEventRequest($body, $request_id); |
1029 | |
1030 | try { |
1031 | $options = $this->createHttpClientOption(); |
1032 | |
1033 | try { |
1034 | $response = $this->client->send($request, $options); |
1035 | } catch (RequestException $e) { |
1036 | $apiException = new ApiException( |
1037 | "[{$e->getCode()}] {$e->getMessage()}", |
1038 | $e->getCode() |
1039 | ); |
1040 | $apiException->setResponseObject($e->getResponse()); |
1041 | |
1042 | throw $apiException; |
1043 | } |
1044 | |
1045 | $statusCode = $response->getStatusCode(); |
1046 | |
1047 | if ($statusCode < 200 || $statusCode > 299) { |
1048 | $apiException = new ApiException( |
1049 | sprintf( |
1050 | '[%d] Error connecting to the API (%s)', |
1051 | $statusCode, |
1052 | $request->getUri() |
1053 | ), |
1054 | $statusCode |
1055 | ); |
1056 | $apiException->setResponseObject($response); |
1057 | |
1058 | throw $apiException; |
1059 | } |
1060 | |
1061 | return [null, $response]; |
1062 | } catch (ApiException $e) { |
1063 | /** @var ResponseInterface $response */ |
1064 | $response = $e->getResponseObject(); |
1065 | |
1066 | switch ($e->getCode()) { |
1067 | case 400: |
1068 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
1069 | $e->setErrorDetails($errorDetail); |
1070 | $e->setResponseObject($response); |
1071 | |
1072 | break; |
1073 | |
1074 | case 403: |
1075 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
1076 | $e->setErrorDetails($errorDetail); |
1077 | $e->setResponseObject($response); |
1078 | |
1079 | break; |
1080 | |
1081 | case 404: |
1082 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
1083 | $e->setErrorDetails($errorDetail); |
1084 | $e->setResponseObject($response); |
1085 | |
1086 | break; |
1087 | |
1088 | case 409: |
1089 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
1090 | $e->setErrorDetails($errorDetail); |
1091 | $e->setResponseObject($response); |
1092 | |
1093 | break; |
1094 | } |
1095 | |
1096 | if (429 === $e->getCode()) { |
1097 | $e->setRetryAfter(1); |
1098 | if ($response->hasHeader('retry-after')) { |
1099 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
1100 | } |
1101 | } |
1102 | |
1103 | throw $e; |
1104 | } |
1105 | } |
1106 | |
1107 | /** |
1108 | * Operation updateEventAsync. |
1109 | * |
1110 | * Update an event with a given request ID |
1111 | * |
1112 | * @param EventsUpdateRequest $body (required) |
1113 | * @param string $request_id The unique event [identifier](https://dev.fingerprint.com/reference/get-function#requestid). (required) |
1114 | * |
1115 | * @throws \InvalidArgumentException |
1116 | * @throws SerializationException |
1117 | * @throws GuzzleException |
1118 | * @throws ApiException |
1119 | */ |
1120 | public function updateEventAsync(EventsUpdateRequest $body, string $request_id): PromiseInterface |
1121 | { |
1122 | $returnType = ''; |
1123 | $request = $this->updateEventRequest($body, $request_id); |
1124 | |
1125 | return $this->client |
1126 | ->sendAsync($request, $this->createHttpClientOption()) |
1127 | ->then( |
1128 | function ($response) use ($request) { |
1129 | $statusCode = $response->getStatusCode(); |
1130 | |
1131 | if ($statusCode < 200 || $statusCode > 299) { |
1132 | $apiException = new ApiException( |
1133 | sprintf( |
1134 | '[%d] Error connecting to the API (%s)', |
1135 | $statusCode, |
1136 | $request->getUri() |
1137 | ), |
1138 | $statusCode |
1139 | ); |
1140 | $apiException->setResponseObject($response); |
1141 | |
1142 | throw $apiException; |
1143 | } |
1144 | |
1145 | return [null, $response]; |
1146 | }, |
1147 | function ($e) { |
1148 | /** @var ResponseInterface $response */ |
1149 | $response = $e->getResponseObject(); |
1150 | |
1151 | switch ($e->getCode()) { |
1152 | case 400: |
1153 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
1154 | $e->setErrorDetails($errorDetail); |
1155 | $e->setResponseObject($response); |
1156 | |
1157 | break; |
1158 | |
1159 | case 403: |
1160 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
1161 | $e->setErrorDetails($errorDetail); |
1162 | $e->setResponseObject($response); |
1163 | |
1164 | break; |
1165 | |
1166 | case 404: |
1167 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
1168 | $e->setErrorDetails($errorDetail); |
1169 | $e->setResponseObject($response); |
1170 | |
1171 | break; |
1172 | |
1173 | case 409: |
1174 | $errorDetail = ObjectSerializer::deserialize($response, '\Fingerprint\ServerAPI\Model\ErrorResponse'); |
1175 | $e->setErrorDetails($errorDetail); |
1176 | $e->setResponseObject($response); |
1177 | |
1178 | break; |
1179 | } |
1180 | |
1181 | if (429 === $e->getCode()) { |
1182 | $e->setRetryAfter(1); |
1183 | if ($response->hasHeader('retry-after')) { |
1184 | $e->setRetryAfter((int) $response->getHeader('retry-after')[0]); |
1185 | } |
1186 | } |
1187 | |
1188 | throw $e; |
1189 | } |
1190 | ); |
1191 | } |
1192 | |
1193 | /** |
1194 | * Create request for operation 'deleteVisitorData'. |
1195 | * |
1196 | * @throws \InvalidArgumentException |
1197 | * @throws SerializationException |
1198 | * @throws GuzzleException |
1199 | * @throws ApiException |
1200 | */ |
1201 | protected function deleteVisitorDataRequest(string $visitor_id): Request |
1202 | { |
1203 | // verify the required parameter 'visitor_id' is set |
1204 | if (null === $visitor_id || (is_array($visitor_id) && 0 === count($visitor_id))) { |
1205 | throw new \InvalidArgumentException( |
1206 | 'Missing the required parameter $visitor_id when calling deleteVisitorData' |
1207 | ); |
1208 | } |
1209 | |
1210 | $resourcePath = '/visitors/{visitor_id}'; |
1211 | $headers = []; |
1212 | $queryParams = ['ii' => $this->integration_info]; |
1213 | $headerParams = []; |
1214 | $httpBody = ''; |
1215 | |
1216 | // path params |
1217 | if (null !== $visitor_id) { |
1218 | $resourcePath = str_replace( |
1219 | '{visitor_id}', |
1220 | ObjectSerializer::toPathValue($visitor_id), |
1221 | $resourcePath |
1222 | ); |
1223 | } |
1224 | |
1225 | // this endpoint requires API key authentication |
1226 | $apiKey = $this->config->getApiKeyWithPrefix('Auth-API-Key'); |
1227 | if (null !== $apiKey) { |
1228 | $headers['Auth-API-Key'] = $apiKey; |
1229 | } |
1230 | // this endpoint requires API key authentication |
1231 | $apiKey = $this->config->getApiKeyWithPrefix('api_key'); |
1232 | if (null !== $apiKey) { |
1233 | $queryParams['api_key'] = $apiKey; |
1234 | } |
1235 | |
1236 | $defaultHeaders = [ |
1237 | 'Content-Type' => 'application/json', |
1238 | 'Accept' => 'application/json', |
1239 | ]; |
1240 | if ($this->config->getUserAgent()) { |
1241 | $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
1242 | } |
1243 | |
1244 | $headers = array_merge( |
1245 | $defaultHeaders, |
1246 | $headerParams, |
1247 | $headers |
1248 | ); |
1249 | |
1250 | $query = http_build_query($queryParams); |
1251 | |
1252 | return new Request( |
1253 | 'DELETE', |
1254 | $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''), |
1255 | $headers, |
1256 | $httpBody |
1257 | ); |
1258 | } |
1259 | |
1260 | /** |
1261 | * Create request for operation 'getEvent'. |
1262 | * |
1263 | * @throws \InvalidArgumentException |
1264 | * @throws SerializationException |
1265 | * @throws GuzzleException |
1266 | * @throws ApiException |
1267 | */ |
1268 | protected function getEventRequest(string $request_id): Request |
1269 | { |
1270 | // verify the required parameter 'request_id' is set |
1271 | if (null === $request_id || (is_array($request_id) && 0 === count($request_id))) { |
1272 | throw new \InvalidArgumentException( |
1273 | 'Missing the required parameter $request_id when calling getEvent' |
1274 | ); |
1275 | } |
1276 | |
1277 | $resourcePath = '/events/{request_id}'; |
1278 | $headers = []; |
1279 | $queryParams = ['ii' => $this->integration_info]; |
1280 | $headerParams = []; |
1281 | $httpBody = ''; |
1282 | |
1283 | // path params |
1284 | if (null !== $request_id) { |
1285 | $resourcePath = str_replace( |
1286 | '{request_id}', |
1287 | ObjectSerializer::toPathValue($request_id), |
1288 | $resourcePath |
1289 | ); |
1290 | } |
1291 | |
1292 | // this endpoint requires API key authentication |
1293 | $apiKey = $this->config->getApiKeyWithPrefix('Auth-API-Key'); |
1294 | if (null !== $apiKey) { |
1295 | $headers['Auth-API-Key'] = $apiKey; |
1296 | } |
1297 | // this endpoint requires API key authentication |
1298 | $apiKey = $this->config->getApiKeyWithPrefix('api_key'); |
1299 | if (null !== $apiKey) { |
1300 | $queryParams['api_key'] = $apiKey; |
1301 | } |
1302 | |
1303 | $defaultHeaders = [ |
1304 | 'Content-Type' => 'application/json', |
1305 | 'Accept' => 'application/json', |
1306 | ]; |
1307 | if ($this->config->getUserAgent()) { |
1308 | $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
1309 | } |
1310 | |
1311 | $headers = array_merge( |
1312 | $defaultHeaders, |
1313 | $headerParams, |
1314 | $headers |
1315 | ); |
1316 | |
1317 | $query = http_build_query($queryParams); |
1318 | |
1319 | return new Request( |
1320 | 'GET', |
1321 | $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''), |
1322 | $headers, |
1323 | $httpBody |
1324 | ); |
1325 | } |
1326 | |
1327 | /** |
1328 | * Create request for operation 'getRelatedVisitors'. |
1329 | * |
1330 | * @throws \InvalidArgumentException |
1331 | * @throws SerializationException |
1332 | * @throws GuzzleException |
1333 | * @throws ApiException |
1334 | */ |
1335 | protected function getRelatedVisitorsRequest(string $visitor_id): Request |
1336 | { |
1337 | // verify the required parameter 'visitor_id' is set |
1338 | if (null === $visitor_id || (is_array($visitor_id) && 0 === count($visitor_id))) { |
1339 | throw new \InvalidArgumentException( |
1340 | 'Missing the required parameter $visitor_id when calling getRelatedVisitors' |
1341 | ); |
1342 | } |
1343 | |
1344 | $resourcePath = '/related-visitors'; |
1345 | $headers = []; |
1346 | $queryParams = ['ii' => $this->integration_info]; |
1347 | $headerParams = []; |
1348 | $httpBody = ''; |
1349 | |
1350 | // query params |
1351 | if (null !== $visitor_id) { |
1352 | $queryParams['visitor_id'] = ObjectSerializer::toQueryValue($visitor_id, null); |
1353 | } |
1354 | |
1355 | // this endpoint requires API key authentication |
1356 | $apiKey = $this->config->getApiKeyWithPrefix('Auth-API-Key'); |
1357 | if (null !== $apiKey) { |
1358 | $headers['Auth-API-Key'] = $apiKey; |
1359 | } |
1360 | // this endpoint requires API key authentication |
1361 | $apiKey = $this->config->getApiKeyWithPrefix('api_key'); |
1362 | if (null !== $apiKey) { |
1363 | $queryParams['api_key'] = $apiKey; |
1364 | } |
1365 | |
1366 | $defaultHeaders = [ |
1367 | 'Content-Type' => 'application/json', |
1368 | 'Accept' => 'application/json', |
1369 | ]; |
1370 | if ($this->config->getUserAgent()) { |
1371 | $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
1372 | } |
1373 | |
1374 | $headers = array_merge( |
1375 | $defaultHeaders, |
1376 | $headerParams, |
1377 | $headers |
1378 | ); |
1379 | |
1380 | $query = http_build_query($queryParams); |
1381 | |
1382 | return new Request( |
1383 | 'GET', |
1384 | $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''), |
1385 | $headers, |
1386 | $httpBody |
1387 | ); |
1388 | } |
1389 | |
1390 | /** |
1391 | * Create request for operation 'getVisits'. |
1392 | * |
1393 | * @throws \InvalidArgumentException |
1394 | * @throws SerializationException |
1395 | * @throws GuzzleException |
1396 | * @throws ApiException |
1397 | */ |
1398 | protected function getVisitsRequest(string $visitor_id, ?string $request_id = null, ?string $linked_id = null, ?int $limit = null, ?string $pagination_key = null, ?int $before = null): Request |
1399 | { |
1400 | // verify the required parameter 'visitor_id' is set |
1401 | if (null === $visitor_id || (is_array($visitor_id) && 0 === count($visitor_id))) { |
1402 | throw new \InvalidArgumentException( |
1403 | 'Missing the required parameter $visitor_id when calling getVisits' |
1404 | ); |
1405 | } |
1406 | |
1407 | $resourcePath = '/visitors/{visitor_id}'; |
1408 | $headers = []; |
1409 | $queryParams = ['ii' => $this->integration_info]; |
1410 | $headerParams = []; |
1411 | $httpBody = ''; |
1412 | |
1413 | // query params |
1414 | if (null !== $request_id) { |
1415 | $queryParams['request_id'] = ObjectSerializer::toQueryValue($request_id, null); |
1416 | } |
1417 | // query params |
1418 | if (null !== $linked_id) { |
1419 | $queryParams['linked_id'] = ObjectSerializer::toQueryValue($linked_id, null); |
1420 | } |
1421 | // query params |
1422 | if (null !== $limit) { |
1423 | $queryParams['limit'] = ObjectSerializer::toQueryValue($limit, 'int32'); |
1424 | } |
1425 | // query params |
1426 | if (null !== $pagination_key) { |
1427 | $queryParams['paginationKey'] = ObjectSerializer::toQueryValue($pagination_key, null); |
1428 | } |
1429 | // query params |
1430 | if (null !== $before) { |
1431 | $queryParams['before'] = ObjectSerializer::toQueryValue($before, 'int64'); |
1432 | } |
1433 | |
1434 | // path params |
1435 | if (null !== $visitor_id) { |
1436 | $resourcePath = str_replace( |
1437 | '{visitor_id}', |
1438 | ObjectSerializer::toPathValue($visitor_id), |
1439 | $resourcePath |
1440 | ); |
1441 | } |
1442 | |
1443 | // this endpoint requires API key authentication |
1444 | $apiKey = $this->config->getApiKeyWithPrefix('Auth-API-Key'); |
1445 | if (null !== $apiKey) { |
1446 | $headers['Auth-API-Key'] = $apiKey; |
1447 | } |
1448 | // this endpoint requires API key authentication |
1449 | $apiKey = $this->config->getApiKeyWithPrefix('api_key'); |
1450 | if (null !== $apiKey) { |
1451 | $queryParams['api_key'] = $apiKey; |
1452 | } |
1453 | |
1454 | $defaultHeaders = [ |
1455 | 'Content-Type' => 'application/json', |
1456 | 'Accept' => 'application/json', |
1457 | ]; |
1458 | if ($this->config->getUserAgent()) { |
1459 | $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
1460 | } |
1461 | |
1462 | $headers = array_merge( |
1463 | $defaultHeaders, |
1464 | $headerParams, |
1465 | $headers |
1466 | ); |
1467 | |
1468 | $query = http_build_query($queryParams); |
1469 | |
1470 | return new Request( |
1471 | 'GET', |
1472 | $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''), |
1473 | $headers, |
1474 | $httpBody |
1475 | ); |
1476 | } |
1477 | |
1478 | /** |
1479 | * Create request for operation 'searchEvents'. |
1480 | * |
1481 | * @throws \InvalidArgumentException |
1482 | * @throws SerializationException |
1483 | * @throws GuzzleException |
1484 | * @throws ApiException |
1485 | */ |
1486 | protected function searchEventsRequest(int $limit, ?string $pagination_key = null, ?string $visitor_id = null, ?string $bot = null, ?string $ip_address = null, ?string $linked_id = null, ?int $start = null, ?int $end = null, ?bool $reverse = null, ?bool $suspect = null): Request |
1487 | { |
1488 | // verify the required parameter 'limit' is set |
1489 | if (null === $limit || (is_array($limit) && 0 === count($limit))) { |
1490 | throw new \InvalidArgumentException( |
1491 | 'Missing the required parameter $limit when calling searchEvents' |
1492 | ); |
1493 | } |
1494 | |
1495 | $resourcePath = '/events/search'; |
1496 | $headers = []; |
1497 | $queryParams = ['ii' => $this->integration_info]; |
1498 | $headerParams = []; |
1499 | $httpBody = ''; |
1500 | |
1501 | // query params |
1502 | if (null !== $limit) { |
1503 | $queryParams['limit'] = ObjectSerializer::toQueryValue($limit, 'int32'); |
1504 | } |
1505 | // query params |
1506 | if (null !== $pagination_key) { |
1507 | $queryParams['pagination_key'] = ObjectSerializer::toQueryValue($pagination_key, null); |
1508 | } |
1509 | // query params |
1510 | if (null !== $visitor_id) { |
1511 | $queryParams['visitor_id'] = ObjectSerializer::toQueryValue($visitor_id, null); |
1512 | } |
1513 | // query params |
1514 | if (null !== $bot) { |
1515 | $queryParams['bot'] = ObjectSerializer::toQueryValue($bot, null); |
1516 | } |
1517 | // query params |
1518 | if (null !== $ip_address) { |
1519 | $queryParams['ip_address'] = ObjectSerializer::toQueryValue($ip_address, null); |
1520 | } |
1521 | // query params |
1522 | if (null !== $linked_id) { |
1523 | $queryParams['linked_id'] = ObjectSerializer::toQueryValue($linked_id, null); |
1524 | } |
1525 | // query params |
1526 | if (null !== $start) { |
1527 | $queryParams['start'] = ObjectSerializer::toQueryValue($start, 'int64'); |
1528 | } |
1529 | // query params |
1530 | if (null !== $end) { |
1531 | $queryParams['end'] = ObjectSerializer::toQueryValue($end, 'int64'); |
1532 | } |
1533 | // query params |
1534 | if (null !== $reverse) { |
1535 | $queryParams['reverse'] = ObjectSerializer::toQueryValue($reverse, null); |
1536 | } |
1537 | // query params |
1538 | if (null !== $suspect) { |
1539 | $queryParams['suspect'] = ObjectSerializer::toQueryValue($suspect, null); |
1540 | } |
1541 | |
1542 | // this endpoint requires API key authentication |
1543 | $apiKey = $this->config->getApiKeyWithPrefix('Auth-API-Key'); |
1544 | if (null !== $apiKey) { |
1545 | $headers['Auth-API-Key'] = $apiKey; |
1546 | } |
1547 | // this endpoint requires API key authentication |
1548 | $apiKey = $this->config->getApiKeyWithPrefix('api_key'); |
1549 | if (null !== $apiKey) { |
1550 | $queryParams['api_key'] = $apiKey; |
1551 | } |
1552 | |
1553 | $defaultHeaders = [ |
1554 | 'Content-Type' => 'application/json', |
1555 | 'Accept' => 'application/json', |
1556 | ]; |
1557 | if ($this->config->getUserAgent()) { |
1558 | $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
1559 | } |
1560 | |
1561 | $headers = array_merge( |
1562 | $defaultHeaders, |
1563 | $headerParams, |
1564 | $headers |
1565 | ); |
1566 | |
1567 | $query = http_build_query($queryParams); |
1568 | |
1569 | return new Request( |
1570 | 'GET', |
1571 | $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''), |
1572 | $headers, |
1573 | $httpBody |
1574 | ); |
1575 | } |
1576 | |
1577 | /** |
1578 | * Create request for operation 'updateEvent'. |
1579 | * |
1580 | * @throws \InvalidArgumentException |
1581 | * @throws SerializationException |
1582 | * @throws GuzzleException |
1583 | * @throws ApiException |
1584 | */ |
1585 | protected function updateEventRequest(EventsUpdateRequest $body, string $request_id): Request |
1586 | { |
1587 | // verify the required parameter 'body' is set |
1588 | if (null === $body || (is_array($body) && 0 === count($body))) { |
1589 | throw new \InvalidArgumentException( |
1590 | 'Missing the required parameter $body when calling updateEvent' |
1591 | ); |
1592 | } |
1593 | // verify the required parameter 'request_id' is set |
1594 | if (null === $request_id || (is_array($request_id) && 0 === count($request_id))) { |
1595 | throw new \InvalidArgumentException( |
1596 | 'Missing the required parameter $request_id when calling updateEvent' |
1597 | ); |
1598 | } |
1599 | |
1600 | $resourcePath = '/events/{request_id}'; |
1601 | $headers = []; |
1602 | $queryParams = ['ii' => $this->integration_info]; |
1603 | $headerParams = []; |
1604 | $httpBody = ''; |
1605 | |
1606 | // path params |
1607 | if (null !== $request_id) { |
1608 | $resourcePath = str_replace( |
1609 | '{request_id}', |
1610 | ObjectSerializer::toPathValue($request_id), |
1611 | $resourcePath |
1612 | ); |
1613 | } |
1614 | |
1615 | // body params |
1616 | $_tempBody = null; |
1617 | if (isset($body)) { |
1618 | $_tempBody = $body; |
1619 | } |
1620 | |
1621 | // for model (json/xml) |
1622 | if (isset($_tempBody)) { |
1623 | if ($_tempBody instanceof ModelInterface) { |
1624 | $httpBody = (string) $_tempBody; |
1625 | } else { |
1626 | // $_tempBody is the method argument, if present |
1627 | $httpBody = json_encode($_tempBody); |
1628 | } |
1629 | } |
1630 | |
1631 | // this endpoint requires API key authentication |
1632 | $apiKey = $this->config->getApiKeyWithPrefix('Auth-API-Key'); |
1633 | if (null !== $apiKey) { |
1634 | $headers['Auth-API-Key'] = $apiKey; |
1635 | } |
1636 | // this endpoint requires API key authentication |
1637 | $apiKey = $this->config->getApiKeyWithPrefix('api_key'); |
1638 | if (null !== $apiKey) { |
1639 | $queryParams['api_key'] = $apiKey; |
1640 | } |
1641 | |
1642 | $defaultHeaders = [ |
1643 | 'Content-Type' => 'application/json', |
1644 | 'Accept' => 'application/json', |
1645 | ]; |
1646 | if ($this->config->getUserAgent()) { |
1647 | $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
1648 | } |
1649 | |
1650 | $headers = array_merge( |
1651 | $defaultHeaders, |
1652 | $headerParams, |
1653 | $headers |
1654 | ); |
1655 | |
1656 | $query = http_build_query($queryParams); |
1657 | |
1658 | return new Request( |
1659 | 'PUT', |
1660 | $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''), |
1661 | $headers, |
1662 | $httpBody |
1663 | ); |
1664 | } |
1665 | |
1666 | /** |
1667 | * Create http client option. |
1668 | * |
1669 | * @throws \RuntimeException on file opening failure |
1670 | */ |
1671 | protected function createHttpClientOption(): array |
1672 | { |
1673 | $options = []; |
1674 | if ($this->config->getDebug()) { |
1675 | $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); |
1676 | if (!$options[RequestOptions::DEBUG]) { |
1677 | throw new \RuntimeException('Failed to open the debug file: '.$this->config->getDebugFile()); |
1678 | } |
1679 | } |
1680 | |
1681 | return $options; |
1682 | } |
1683 | } |