Skip to content

Commit

Permalink
docs(readme): add usage for new endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Orkuncakilkaya committed Aug 26, 2024
1 parent e85cd69 commit 103b7f6
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 14 deletions.
40 changes: 33 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 "<pre>" . $response->__toString() . "</pre>";
} catch (Exception $e) {
echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL;
Expand All @@ -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 "<pre>" . $response->__toString() . "</pre>";
} 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 "<pre>" . $response->__toString() . "</pre>";
} 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 "<pre>" . $response->__toString() . "</pre>";
} 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 "<pre>" . $response->__toString() . "</pre>";
} 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 "<pre>" . $response->__toString() . "</pre>";
} 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).
Expand Down
40 changes: 33 additions & 7 deletions template/README.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 "<pre>" . $response->__toString() . "</pre>";
} catch (Exception $e) {
echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL;
Expand All @@ -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 "<pre>" . $response->__toString() . "</pre>";
} 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 "<pre>" . $response->__toString() . "</pre>";
} 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 "<pre>" . $response->__toString() . "</pre>";
} 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 "<pre>" . $response->__toString() . "</pre>";
} 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 "<pre>" . $response->__toString() . "</pre>";
} 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).
Expand Down

0 comments on commit 103b7f6

Please sign in to comment.