Skip to content

Update tests and documentation to use optional params as named params #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ try {
// Search for specific events
try {
// Search events for given visitor id marked as suspicious and "bad" bot
list($model, $response) = $client->searchEvents(LIMIT, null, FPJS_VISITOR_ID, 'bad', null, null, null, null, null, true);
list($model, $response) = $client->searchEvents(LIMIT, visitor_id: FPJS_VISITOR_ID, bot: 'bad', suspect: true);
// Use pagination key to get the next page
// list($model, $response) = $client->searchEvents(LIMIT, pagination_key: $model->getPaginationKey(), visitor_id: FPJS_VISITOR_ID, bot: 'bad', suspect: true);
echo "<pre>" . $response->getBody()->getContents() . "</pre>";
} catch (Exception $e) {
echo 'Exception when calling FingerprintApi->searchEvents: ', $e->getMessage(), PHP_EOL;
Expand Down
4 changes: 2 additions & 2 deletions docs/Api/FingerprintApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ $pagination_key = "pagination_key_example"; // string | Use `paginationKey` to g
$before = 789; // int | ⚠️ Deprecated pagination method, please use `paginationKey` instead. Timestamp (in milliseconds since epoch) used to paginate results.

try {
list($model, $httpResponse) = $client->getVisits($visitor_id, $request_id, $linked_id, $limit, $pagination_key, $before);
list($model, $httpResponse) = $client->getVisits($visitor_id, request_id: $request_id, linked_id: $linked_id, limit: $limit, pagination_key: $pagination_key, before: $before);
echo "<pre>" . $httpResponse->getBody()->getContents() . "</pre>";
} catch (Exception $e) {
echo 'Exception when calling FingerprintApi->getVisits: ', $e->getMessage(), PHP_EOL;
Expand Down Expand Up @@ -307,7 +307,7 @@ $reverse = true; // bool | Sort events in reverse timestamp order.
$suspect = true; // bool | 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.

try {
list($model, $httpResponse) = $client->searchEvents($limit, $pagination_key, $visitor_id, $bot, $ip_address, $linked_id, $start, $end, $reverse, $suspect);
list($model, $httpResponse) = $client->searchEvents($limit, pagination_key: $pagination_key, visitor_id: $visitor_id, bot: $bot, ip_address: $ip_address, linked_id: $linked_id, start: $start, end: $end, reverse: $reverse, suspect: $suspect);
echo "<pre>" . $httpResponse->getBody()->getContents() . "</pre>";
} catch (Exception $e) {
echo 'Exception when calling FingerprintApi->searchEvents: ', $e->getMessage(), PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion run_checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
$end = new DateTime();

/** @var SearchEventsResponse $result */
list($result, $response) = $client->searchEvents(10, null, null, null, null, null, $start->getTimestamp() * 1000, $end->getTimestamp() * 1000);
list($result, $response) = $client->searchEvents(10, start: $start->getTimestamp() * 1000, end: $end->getTimestamp() * 1000);
if (!is_countable($result->getEvents()) || count($result->getEvents()) === 0) {
throw new Exception('No events found');
}
Expand Down
4 changes: 3 additions & 1 deletion template/README.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ try {
// Search for specific events
try {
// Search events for given visitor id marked as suspicious and "bad" bot
list($model, $response) = $client->searchEvents(LIMIT, null, FPJS_VISITOR_ID, 'bad', null, null, null, null, null, true);
list($model, $response) = $client->searchEvents(LIMIT, visitor_id: FPJS_VISITOR_ID, bot: 'bad', suspect: true);
// Use pagination key to get the next page
// list($model, $response) = $client->searchEvents(LIMIT, pagination_key: $model->getPaginationKey(), visitor_id: FPJS_VISITOR_ID, bot: 'bad', suspect: true);
echo "<pre>" . $response->getBody()->getContents() . "</pre>";
} catch (Exception $e) {
echo 'Exception when calling FingerprintApi->searchEvents: ', $e->getMessage(), PHP_EOL;
Expand Down
4 changes: 2 additions & 2 deletions template/api_doc.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $config
{{/allParams}}

try {
{{#returnType}}list($model, $httpResponse) = {{/returnType}}$client->{{{operationId}}}({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
{{#returnType}}list($model, $httpResponse) = {{/returnType}}$client->{{{operationId}}}({{#allParams}}{{^required}}{{paramName}}: {{/required}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
echo "<pre>" . $httpResponse->getBody()->getContents() . "</pre>";{{/returnType}}
} catch (Exception $e) {
echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL;
Expand Down Expand Up @@ -75,4 +75,4 @@ Array:
[[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)

{{/operation}}
{{/operations}}
{{/operations}}
6 changes: 3 additions & 3 deletions test/FingerprintApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ public function testSearchEventsWithPartialParams()
return $this->returnMockResponse("get_event_search_200.json");
});

list($events) = $this->fingerprint_api->searchEvents(10, null, self::MOCK_VISITOR_ID, null, null, "linked_id", null, null, true);
list($events) = $this->fingerprint_api->searchEvents(10, visitor_id: self::MOCK_VISITOR_ID, linked_id: "linked_id", reverse: true);

$this->assertCount(1, $events->getEvents());
$this->assertEquals("Ibk1527CUFmcnjLwIs4A9", $events->getEvents()[0]->getProducts()->getIdentification()->getData()->getVisitorId());
Expand Down Expand Up @@ -831,7 +831,7 @@ public function testSearchEventsWithAllParams()
return $this->returnMockResponse('get_event_search_200.json');
});

list($events) = $this->fingerprint_api->searchEvents(10, 'pagination', self::MOCK_VISITOR_ID, 'good', '127.0.0.1/16', 'linked_id', $start->getTimestamp(), $end->getTimestamp(), true, true);
list($events) = $this->fingerprint_api->searchEvents(10, pagination_key: 'pagination', visitor_id: self::MOCK_VISITOR_ID, bot: 'good', ip_address: '127.0.0.1/16', linked_id: 'linked_id', start: $start->getTimestamp(), end: $end->getTimestamp(), reverse: true, suspect: true);

$this->assertCount(1, $events->getEvents());
$this->assertEquals('Ibk1527CUFmcnjLwIs4A9', $events->getEvents()[0]->getProducts()->getIdentification()->getData()->getVisitorId());
Expand All @@ -846,7 +846,7 @@ public function testSearchEvents400Error()
$this->expectExceptionCode(400);

try {
$this->fingerprint_api->searchEvents(10, 'pagination', self::MOCK_VISITOR_ID, 'invalid',);
$this->fingerprint_api->searchEvents(10, pagination_key: 'pagination', visitor_id: self::MOCK_VISITOR_ID, bot: 'invalid');
} catch (ApiException $e) {
$this->assertEquals(ErrorResponse::class, get_class($e->getErrorDetails()));
$this->assertEquals(ErrorCode::REQUEST_CANNOT_BE_PARSED, $e->getErrorDetails()->getError()->getCode());
Expand Down
Loading