Skip to content

Commit a2093b3

Browse files
author
Orkun
authored
Merge pull request #41 from fingerprintjs/develop
feat: simplified configuration api
2 parents dd8c3eb + 16362fc commit a2093b3

File tree

10 files changed

+753
-116
lines changed

10 files changed

+753
-116
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
## [0.3.0-develop.7](https://github.com/fingerprintjs/fingerprint-pro-server-api-php-sdk/compare/v0.3.0-develop.6...v0.3.0-develop.7) (2022-11-01)
2+
3+
4+
### Bug Fixes
5+
6+
* api doc fixed for simpler use ([#43](https://github.com/fingerprintjs/fingerprint-pro-server-api-php-sdk/issues/43)) ([dca0952](https://github.com/fingerprintjs/fingerprint-pro-server-api-php-sdk/commit/dca0952e5bce0f7138e8de0da17584d6caa329d7))
7+
8+
## [0.3.0-develop.6](https://github.com/fingerprintjs/fingerprint-pro-server-api-php-sdk/compare/v0.3.0-develop.5...v0.3.0-develop.6) (2022-11-01)
9+
10+
11+
### Features
12+
13+
* update php version for public consts & simplify docs ([#42](https://github.com/fingerprintjs/fingerprint-pro-server-api-php-sdk/issues/42)) ([18eb759](https://github.com/fingerprintjs/fingerprint-pro-server-api-php-sdk/commit/18eb759e1296dd7339cb711c02da077f359a5a0d))
14+
15+
## [0.3.0-develop.5](https://github.com/fingerprintjs/fingerprint-pro-server-api-php-sdk/compare/v0.3.0-develop.4...v0.3.0-develop.5) (2022-10-31)
16+
17+
18+
### Features
19+
20+
* simplified configuration api ([#40](https://github.com/fingerprintjs/fingerprint-pro-server-api-php-sdk/issues/40)) ([0ea6edd](https://github.com/fingerprintjs/fingerprint-pro-server-api-php-sdk/commit/0ea6eddfbce92318f570ce496cd878676f9698b3))
21+
122
## [0.3.0-develop.4](https://github.com/fingerprintjs/fingerprint-pro-server-api-php-sdk/compare/v0.3.0-develop.3...v0.3.0-develop.4) (2022-10-26)
223

324

README.md

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
3232

3333
- API version: 3
34-
- Package version: dev-0.3.0-4
34+
- Package version: dev-0.3.0-7
3535
- Build package: io.swagger.codegen.v3.generators.php.PhpClientCodegen
3636

3737
## Requirements
3838

39-
PHP 5.5 and later
39+
PHP 7.1 and later
4040

4141
## Installation & Usage
4242
### Composer
@@ -82,60 +82,71 @@ Please follow the [installation procedure](#installation--usage) and then run th
8282

8383
```php
8484
<?php
85+
8586
require_once(__DIR__ . '/vendor/autoload.php');
8687

87-
// Configure API key authorization: ApiKeyHeader
88-
$config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKey('Auth-API-Key', 'YOUR_API_KEY');
89-
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
90-
// $config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Auth-API-Key', 'Bearer');
91-
// Configure API key authorization: ApiKeyQuery
92-
$config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY');
93-
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
94-
// $config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
95-
96-
$apiInstance = new Fingerprint\ServerAPI\Api\FingerprintApi(
97-
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
98-
// This is optional, `GuzzleHttp\Client` will be used as default.
99-
new GuzzleHttp\Client(),
88+
// Our Fingerprint API Secret
89+
const FPJS_API_SECRET = "YOUR SECRET KEY COMES HERE";
90+
// A Request ID that made by a specific visitor
91+
const FPJS_REQUEST_ID = "REQUEST ID"; // Change this value with your request id
92+
// A Visitor ID of a specific visitor
93+
const FPJS_VISITOR_ID = "VISITOR ID"; // Change this value with your visitor id
94+
95+
// Linked id of the visit
96+
const FPJS_LINKED_ID = "LINKED ID"; // Change this value with your linked id
97+
// How many items to fetch, while paginating
98+
const LIMIT = 10;
99+
// How many items to skip, while paginating
100+
const BEFORE = 1;
101+
102+
// Import Fingerprint Classes and Guzzle Http Client
103+
use Fingerprint\ServerAPI\Api\FingerprintApi;
104+
use Fingerprint\ServerAPI\Configuration;
105+
use GuzzleHttp\Client;
106+
107+
// Create new Configuration instance with defaultValues, added our API Secret and our Region
108+
$config = Configuration::getDefaultConfiguration(FPJS_API_SECRET, Configuration::REGION_EUROPE);
109+
$client = new FingerprintApi(
110+
new Client(),
100111
$config
101112
);
102-
$request_id = "request_id_example"; // string | Request ID
103113

114+
// Let's try to get an event with given Request ID
104115
try {
105-
$result = $apiInstance->getEvent($request_id);
106-
print_r($result);
116+
// Fetch event with given Request ID
117+
$response = $client->getEvent(FPJS_REQUEST_ID);
118+
echo "<pre>" . $response->__toString() . "</pre>";
107119
} catch (Exception $e) {
108120
echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL;
109121
}
110122

111-
// Configure API key authorization: ApiKeyHeader
112-
$config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKey('Auth-API-Key', 'YOUR_API_KEY');
113-
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
114-
// $config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Auth-API-Key', 'Bearer');
115-
// Configure API key authorization: ApiKeyQuery
116-
$config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY');
117-
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
118-
// $config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
119-
120-
$apiInstance = new Fingerprint\ServerAPI\Api\FingerprintApi(
121-
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
122-
// This is optional, `GuzzleHttp\Client` will be used as default.
123-
new GuzzleHttp\Client(),
124-
$config
125-
);
126-
$visitor_id = "visitor_id_example"; // string |
127-
$request_id = "request_id_example"; // string | Filter events by requestId
128-
$linked_id = "linked_id_example"; // string | Filter events by custom identifier
129-
$limit = 56; // int | Limit scanned results
130-
$before = 56; // int | Used to paginate results
123+
// Let's try to get a specific visitor's all visits
124+
try {
125+
// Fetch all visits with given Visitor ID, with a page limit
126+
$response = $client->getVisits(FPJS_VISITOR_ID, null, null, LIMIT);
127+
echo "<pre>" . $response->__toString() . "</pre>";
128+
} catch (Exception $e) {
129+
echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL;
130+
}
131131

132+
// Let's try to get a specific visitor's all visits with linked id
132133
try {
133-
$result = $apiInstance->getVisits($visitor_id, $request_id, $linked_id, $limit, $before);
134-
print_r($result);
134+
// Fetch all visits with given Visitor ID, with a page limit, skipping first the first visit
135+
$response = $client->getVisits(FPJS_VISITOR_ID, null, FPJS_LINKED_ID, LIMIT, BEFORE);
136+
echo "<pre>" . $response->__toString() . "</pre>";
135137
} catch (Exception $e) {
136-
echo 'Exception when calling FingerprintApi->getVisits: ', $e->getMessage(), PHP_EOL;
138+
echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL;
137139
}
138-
?>
140+
141+
// Let's use all the parameters on getVisits
142+
try {
143+
// We fetch the visitor's all visits with given Request ID, Linked ID with a page limit while skipping first visit
144+
$response = $client->getVisits(FPJS_VISITOR_ID, FPJS_REQUEST_ID, FPJS_LINKED_ID, LIMIT, BEFORE);
145+
echo "<pre>" . $response->__toString() . "</pre>";
146+
} catch (Exception $e) {
147+
echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL;
148+
}
149+
139150
```
140151

141152
## Documentation for API Endpoints

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fingerprint/fingerprint-pro-server-api-sdk",
3-
"version": "dev-0.3.0-4",
3+
"version": "dev-0.3.0-7",
44
"description": "Fingerprint Pro Server API provides a way for validating visitors’ data issued by Fingerprint Pro.",
55
"keywords": [
66
"swagger",
@@ -17,7 +17,7 @@
1717
}
1818
],
1919
"require": {
20-
"php": ">=5.5",
20+
"php": ">=7.1",
2121
"ext-curl": "*",
2222
"ext-json": "*",
2323
"ext-mbstring": "*",

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"gitUserId": "fingerprintjs",
99
"gitRepoId": "fingerprint-pro-server-api-php-sdk",
1010
"description": "Fingerprint Pro Server API provides a way for validating visitors’ data issued by Fingerprint Pro.",
11-
"artifactVersion": "dev-0.3.0-4"
11+
"artifactVersion": "dev-0.3.0-7"
1212
}

docs/Api/FingerprintApi.md

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ All URIs are relative to *https://api.fpjs.io*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**getEvent**](FingerprintApi.md#getevent) | **GET** /events/{request_id} | Get event by request ID
8-
[**getVisits**](FingerprintApi.md#getvisits) | **GET** /visitors/{visitor_id} |
7+
[**getEvent**](FingerprintApi.md#getEvent) | **GET** /events/{request_id} | Get event by request ID
8+
[**getVisits**](FingerprintApi.md#getVisits) | **GET** /visitors/{visitor_id} |
99

1010
# **getEvent**
1111
> \Fingerprint\ServerAPI\Model\EventResponse getEvent($request_id)
@@ -17,26 +17,28 @@ This endpoint allows you to get events with all the information from each activa
1717
### Example
1818
```php
1919
<?php
20+
2021
require_once(__DIR__ . '/vendor/autoload.php');
21-
// Configure API key authorization: ApiKeyHeader
22-
$config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKey('Auth-API-Key', 'YOUR_API_KEY');
23-
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
24-
// $config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Auth-API-Key', 'Bearer');// Configure API key authorization: ApiKeyQuery
25-
$config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY');
26-
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
27-
// $config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
28-
29-
$apiInstance = new Fingerprint\ServerAPI\Api\FingerprintApi(
30-
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
31-
// This is optional, `GuzzleHttp\Client` will be used as default.
32-
new GuzzleHttp\Client(),
22+
23+
const FPJS_API_SECRET = "YOUR SECRET KEY COMES HERE"; // Our Fingerprint API Secret
24+
25+
// Import Fingerprint Classes and Guzzle Http Client
26+
use Fingerprint\ServerAPI\Api\FingerprintApi;
27+
use Fingerprint\ServerAPI\Configuration;
28+
use GuzzleHttp\Client;
29+
30+
// Create new Configuration instance with defaultValues, added our API Secret and our Region
31+
$config = Configuration::getDefaultConfiguration(FPJS_API_SECRET, Configuration::REGION_EUROPE);
32+
$client = new FingerprintApi(
33+
new Client(),
3334
$config
3435
);
36+
3537
$request_id = "request_id_example"; // string | Request ID
3638

3739
try {
38-
$result = $apiInstance->getEvent($request_id);
39-
print_r($result);
40+
$result = $client->getEvent($request_id);
41+
echo "<pre>" . $response->__toString() . "</pre>";
4042
} catch (Exception $e) {
4143
echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL;
4244
}
@@ -59,8 +61,8 @@ Name | Type | Description | Notes
5961

6062
### HTTP request headers
6163

62-
- **Content-Type**: Not defined
63-
- **Accept**: application/json
64+
- **Content-Type**: Not defined
65+
- **Accept**: application/json
6466

6567
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md)
6668

@@ -74,30 +76,32 @@ This endpoint allows you to get a history of visits with all available informati
7476
### Example
7577
```php
7678
<?php
79+
7780
require_once(__DIR__ . '/vendor/autoload.php');
78-
// Configure API key authorization: ApiKeyHeader
79-
$config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKey('Auth-API-Key', 'YOUR_API_KEY');
80-
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
81-
// $config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Auth-API-Key', 'Bearer');// Configure API key authorization: ApiKeyQuery
82-
$config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY');
83-
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
84-
// $config = Fingerprint\ServerAPI\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
85-
86-
$apiInstance = new Fingerprint\ServerAPI\Api\FingerprintApi(
87-
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
88-
// This is optional, `GuzzleHttp\Client` will be used as default.
89-
new GuzzleHttp\Client(),
81+
82+
const FPJS_API_SECRET = "YOUR SECRET KEY COMES HERE"; // Our Fingerprint API Secret
83+
84+
// Import Fingerprint Classes and Guzzle Http Client
85+
use Fingerprint\ServerAPI\Api\FingerprintApi;
86+
use Fingerprint\ServerAPI\Configuration;
87+
use GuzzleHttp\Client;
88+
89+
// Create new Configuration instance with defaultValues, added our API Secret and our Region
90+
$config = Configuration::getDefaultConfiguration(FPJS_API_SECRET, Configuration::REGION_EUROPE);
91+
$client = new FingerprintApi(
92+
new Client(),
9093
$config
9194
);
95+
9296
$visitor_id = "visitor_id_example"; // string |
9397
$request_id = "request_id_example"; // string | Filter events by requestId
9498
$linked_id = "linked_id_example"; // string | Filter events by custom identifier
9599
$limit = 56; // int | Limit scanned results
96100
$before = 56; // int | Used to paginate results
97101

98102
try {
99-
$result = $apiInstance->getVisits($visitor_id, $request_id, $linked_id, $limit, $before);
100-
print_r($result);
103+
$result = $client->getVisits($visitor_id, $request_id, $linked_id, $limit, $before);
104+
echo "<pre>" . $response->__toString() . "</pre>";
101105
} catch (Exception $e) {
102106
echo 'Exception when calling FingerprintApi->getVisits: ', $e->getMessage(), PHP_EOL;
103107
}
@@ -124,8 +128,8 @@ Name | Type | Description | Notes
124128

125129
### HTTP request headers
126130

127-
- **Content-Type**: Not defined
128-
- **Accept**: application/json
131+
- **Content-Type**: Not defined
132+
- **Accept**: application/json
129133

130134
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md)
131135

0 commit comments

Comments
 (0)