From 103b7f69f11d46bdc41b8fbdffb2d9325310fa06 Mon Sep 17 00:00:00 2001 From: Orkun Date: Tue, 27 Aug 2024 02:13:15 +0300 Subject: [PATCH] docs(readme): add usage for new endpoints --- README.md | 40 +++++++++++++++++++++++++++++++++------- template/README.mustache | 40 +++++++++++++++++++++++++++++++++------- 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 5627d25a..812daa4b 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ const PAGINATION_KEY = "1683900801733.Ogvu1j"; // Import Fingerprint Pro Classes and Guzzle Http Client use Fingerprint\ServerAPI\Api\FingerprintApi; use Fingerprint\ServerAPI\Configuration; +use Fingerprint\ServerAPI\Model\EventUpdateRequest; use GuzzleHttp\Client; // Create a new Configuration instance with your Fingerprint Pro Server API Key and your Fingerprint Pro Server API Region. @@ -104,7 +105,7 @@ $client = new FingerprintApi( // Get an event with a given requestId try { // Fetch the event with a given requestId - $response = $client->getEvent(FPJS_REQUEST_ID); + list($model, $response) = $client->getEvent(FPJS_REQUEST_ID); echo "
" . $response->__toString() . "
"; } catch (Exception $e) { echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL; @@ -113,31 +114,56 @@ try { // Get a specific visitor's all visits try { // Fetch all visits with a given visitorId, with a page limit - $response = $client->getVisits(FPJS_VISITOR_ID, null, null, LIMIT); + list($model, $response) = $client->getVisits(FPJS_VISITOR_ID, null, null, LIMIT); echo "
" . $response->__toString() . "
"; } catch (Exception $e) { - echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL; + echo 'Exception when calling FingerprintApi->getVisits: ', $e->getMessage(), PHP_EOL; } // Get a specific visitor's all visits with a linkedId try { // Fetch all visits with a given visitorId, with a page limit, skipping the first visit - $response = $client->getVisits(FPJS_VISITOR_ID, null, FPJS_LINKED_ID, LIMIT, PAGINATION_KEY); + list($model, $response) = $client->getVisits(FPJS_VISITOR_ID, null, FPJS_LINKED_ID, LIMIT, PAGINATION_KEY); echo "
" . $response->__toString() . "
"; } catch (Exception $e) { - echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL; + echo 'Exception when calling FingerprintApi->getVisits: ', $e->getMessage(), PHP_EOL; } // Use all the parameters on getVisits try { // Fetch the visitor's all visits with a given requestId and linkedId with a page limit while skipping the first visit - $response = $client->getVisits(FPJS_VISITOR_ID, FPJS_REQUEST_ID, FPJS_LINKED_ID, LIMIT, PAGINATION_KEY); + list($model, $response) = $client->getVisits(FPJS_VISITOR_ID, FPJS_REQUEST_ID, FPJS_LINKED_ID, LIMIT, PAGINATION_KEY); echo "
" . $response->__toString() . "
"; } catch (Exception $e) { - echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL; + echo 'Exception when calling FingerprintApi->getVisits: ', $e->getMessage(), PHP_EOL; +} + +// Update Event +try { + $body = new EventUpdateRequest([ + 'linked_id' => 'new linked id', + 'tag' => json_encode(['new_property' => 'new value']), + 'suspect' => true, + ]); + list($model, $response) = $client->updateEvent($body, FPJS_REQUEST_ID); + echo "
" . $response->__toString() . "
"; +} catch (Exception $e) { + echo 'Exception when calling FingerprintApi->updateEvent: ', $e->getMessage(), PHP_EOL; +} + +// Delete by visitor ID +try { + list($model, $response) = $client->deleteVisitorData(FPJS_VISITOR_ID); + echo "
" . $response->__toString() . "
"; +} catch (Exception $e) { + echo 'Exception when calling FingerprintApi->deleteVisitorData: ', $e->getMessage(), PHP_EOL; } ``` +> ⚠️ Warning It's not possible to update events older than 10 days. + +> ⚠️ If you are interested in using `deleteVisitorData` API, please [contact our support team](https://fingerprint.com/support/) to enable it for you. Otherwise, you will receive a 403. + ## Sealed results This SDK provides utility methods for decoding [sealed results](https://dev.fingerprint.com/docs/sealed-client-results). diff --git a/template/README.mustache b/template/README.mustache index 3154a0e0..f4aeade8 100644 --- a/template/README.mustache +++ b/template/README.mustache @@ -94,6 +94,7 @@ const PAGINATION_KEY = "1683900801733.Ogvu1j"; // Import Fingerprint Pro Classes and Guzzle Http Client use Fingerprint\ServerAPI\Api\FingerprintApi; use Fingerprint\ServerAPI\Configuration; +use Fingerprint\ServerAPI\Model\EventUpdateRequest; use GuzzleHttp\Client; // Create a new Configuration instance with your Fingerprint Pro Server API Key and your Fingerprint Pro Server API Region. @@ -114,7 +115,7 @@ $client = new FingerprintApi( // Get an event with a given requestId try { // Fetch the event with a given requestId - $response = $client->getEvent(FPJS_REQUEST_ID); + list($model, $response) = $client->getEvent(FPJS_REQUEST_ID); echo "
" . $response->__toString() . "
"; } catch (Exception $e) { echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL; @@ -123,31 +124,56 @@ try { // Get a specific visitor's all visits try { // Fetch all visits with a given visitorId, with a page limit - $response = $client->getVisits(FPJS_VISITOR_ID, null, null, LIMIT); + list($model, $response) = $client->getVisits(FPJS_VISITOR_ID, null, null, LIMIT); echo "
" . $response->__toString() . "
"; } catch (Exception $e) { - echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL; + echo 'Exception when calling FingerprintApi->getVisits: ', $e->getMessage(), PHP_EOL; } // Get a specific visitor's all visits with a linkedId try { // Fetch all visits with a given visitorId, with a page limit, skipping the first visit - $response = $client->getVisits(FPJS_VISITOR_ID, null, FPJS_LINKED_ID, LIMIT, PAGINATION_KEY); + list($model, $response) = $client->getVisits(FPJS_VISITOR_ID, null, FPJS_LINKED_ID, LIMIT, PAGINATION_KEY); echo "
" . $response->__toString() . "
"; } catch (Exception $e) { - echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL; + echo 'Exception when calling FingerprintApi->getVisits: ', $e->getMessage(), PHP_EOL; } // Use all the parameters on getVisits try { // Fetch the visitor's all visits with a given requestId and linkedId with a page limit while skipping the first visit - $response = $client->getVisits(FPJS_VISITOR_ID, FPJS_REQUEST_ID, FPJS_LINKED_ID, LIMIT, PAGINATION_KEY); + list($model, $response) = $client->getVisits(FPJS_VISITOR_ID, FPJS_REQUEST_ID, FPJS_LINKED_ID, LIMIT, PAGINATION_KEY); echo "
" . $response->__toString() . "
"; } catch (Exception $e) { - echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL; + echo 'Exception when calling FingerprintApi->getVisits: ', $e->getMessage(), PHP_EOL; +} + +// Update Event +try { + $body = new EventUpdateRequest([ + 'linked_id' => 'new linked id', + 'tag' => json_encode(['new_property' => 'new value']), + 'suspect' => true, + ]); + list($model, $response) = $client->updateEvent($body, FPJS_REQUEST_ID); + echo "
" . $response->__toString() . "
"; +} catch (Exception $e) { + echo 'Exception when calling FingerprintApi->updateEvent: ', $e->getMessage(), PHP_EOL; +} + +// Delete by visitor ID +try { + list($model, $response) = $client->deleteVisitorData(FPJS_VISITOR_ID); + echo "
" . $response->__toString() . "
"; +} catch (Exception $e) { + echo 'Exception when calling FingerprintApi->deleteVisitorData: ', $e->getMessage(), PHP_EOL; } ``` +> ⚠️ Warning It's not possible to update events older than 10 days. + +> ⚠️ If you are interested in using `deleteVisitorData` API, please [contact our support team](https://fingerprint.com/support/) to enable it for you. Otherwise, you will receive a 403. + ## Sealed results This SDK provides utility methods for decoding [sealed results](https://dev.fingerprint.com/docs/sealed-client-results).