Skip to content

Commit

Permalink
docs: update readme examples, add examples for delete_visitor_data
Browse files Browse the repository at this point in the history
…and `update_event` methods
  • Loading branch information
ilfa committed Jul 18, 2024
1 parent b57ad40 commit 2a23750
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 18 deletions.
61 changes: 52 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ from fingerprint_pro_server_api_sdk.rest import ApiException, KnownApiException
configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)

visitor_id = 'visitor_id_example' # str |
#request_id = 'request_id_example' # str | Filter events by requestId (optional)
#linked_id = 'linked_id_example' # str | Filter events by custom identifier (optional)
limit = 10 # int | Limit scanned results (optional)
#before = 56 # int | Used to paginate results (optional)
visitor_id = 'visitor_id_example' # str | Unique [visitor identifier](https://dev.fingerprint.com/docs/js-agent#visitorid) issued by Fingerprint Pro.
#request_id = 'request_id_example' # str | The unique event [identifier](https://dev.fingerprint.com/docs/js-agent#requestid).
#linked_id = 'linked_id_example' # str | Filter visits by your custom identifier. You can use [`linkedId`](https://dev.fingerprint.com/docs/js-agent#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)
limit = 10 # int | 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)
#pagination_key = 'pagination_key_example' # str | 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)

try:
api_response: Response = api_instance.get_visits(visitor_id, limit=2)
Expand All @@ -108,7 +108,26 @@ except KnownApiException as e:
structured_error = e.structured_error
print("Error: %s\n" % structured_error.error)
except ApiException as e:
print("Exception when calling DefaultApi->visitors_visitor_id_get: %s\n" % e)
print("Exception when calling FingerprintApi->visitors_visitor_id_get: %s\n" % e)
```

Delete visits using visitorId:
```python
import fingerprint_pro_server_api_sdk
from fingerprint_pro_server_api_sdk.rest import ApiException, KnownApiException

configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)

visitor_id = 'visitor_id_example' # str | Unique [visitor identifier](https://dev.fingerprint.com/docs/js-agent#visitorid) issued by Fingerprint Pro.

try:
api_instance.delete_visitor_data(visitor_id)
except KnownApiException as e:
structured_error = e.structured_error
print("Error: %s\n" % structured_error.error)
except ApiException as e:
print("Exception when calling FingerprintApi->delete_visitor_data: %s\n" % e)
```

Fetching events for requestId:
Expand All @@ -120,7 +139,7 @@ from fingerprint_pro_server_api_sdk.rest import ApiException, KnownApiException
configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)

request_id = 'request_id_example' # str
request_id = 'request_id_example' # str | The unique event [identifier](https://dev.fingerprint.com/docs/js-agent#requestid).

try:
events_response: EventResponse = api_instance.get_event(request_id)
Expand All @@ -129,7 +148,31 @@ except KnownApiException as e:
structured_error = e.structured_error
print("Error code: %s. Error message: %s\n" % (structured_error.error.code, structured_error.error.message))
except ApiException as e:
print("Exception when calling DefaultApi->get_event: %s\n" % e)
print("Exception when calling FingerprintApi->get_event: %s\n" % e)
```

Update event for requestId:
```python
import fingerprint_pro_server_api_sdk
from fingerprint_pro_server_api_sdk import EventUpdateRequest
from fingerprint_pro_server_api_sdk.rest import ApiException, KnownApiException

configuration = fingerprint_pro_server_api_sdk.Configuration(api_key="SECRET_API_KEY")
api_instance = fingerprint_pro_server_api_sdk.FingerprintApi(configuration)

request_id = 'request_id_example' # str | The unique event [identifier](https://dev.fingerprint.com/docs/js-agent#requestid).
body = EventUpdateRequest(linked_id='foo') # EventUpdateRequest |
# body = EventUpdateRequest(tag={'bar': 123})
# body = EventUpdateRequest(suspect=True)
# body = EventUpdateRequest(linked_id='foo', tag={'bar': 123}, suspect=False)

try:
api_instance.update_event(request_id, body)
except KnownApiException as e:
structured_error = e.structured_error
print("Error code: %s. Error message: %s\n" % (structured_error.error.code, structured_error.error.message))
except ApiException as e:
print("Exception when calling FingerprintApi->update_event: %s\n" % e)
```

## Sealed results
Expand Down Expand Up @@ -293,4 +336,4 @@ If you need private support, you can email us at [[email protected]](m

## License

This project is licensed under the [MIT License](https://github.com/fingerprintjs/fingerprint-pro-server-api-python-sdk/blob/main/LICENSE).
This project is licensed under the [MIT License](https://github.com/fingerprintjs/fingerprint-pro-server-api-python-sdk/blob/main/LICENSE).
61 changes: 52 additions & 9 deletions template/README.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ from {{packageName}}.rest import ApiException, KnownApiException
configuration = {{packageName}}.Configuration(api_key="SECRET_API_KEY")
api_instance = {{packageName}}.FingerprintApi(configuration)

visitor_id = 'visitor_id_example' # str |
#request_id = 'request_id_example' # str | Filter events by requestId (optional)
#linked_id = 'linked_id_example' # str | Filter events by custom identifier (optional)
limit = 10 # int | Limit scanned results (optional)
#before = 56 # int | Used to paginate results (optional)
visitor_id = 'visitor_id_example' # str | Unique [visitor identifier](https://dev.fingerprint.com/docs/js-agent#visitorid) issued by Fingerprint Pro.
#request_id = 'request_id_example' # str | The unique event [identifier](https://dev.fingerprint.com/docs/js-agent#requestid).
#linked_id = 'linked_id_example' # str | Filter visits by your custom identifier. You can use [`linkedId`](https://dev.fingerprint.com/docs/js-agent#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)
limit = 10 # int | 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)
#pagination_key = 'pagination_key_example' # str | 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)

try:
api_response: Response = api_instance.get_visits(visitor_id, limit=2)
Expand All @@ -114,7 +114,26 @@ except KnownApiException as e:
structured_error = e.structured_error
print("Error: %s\n" % structured_error.error)
except ApiException as e:
print("Exception when calling DefaultApi->visitors_visitor_id_get: %s\n" % e)
print("Exception when calling FingerprintApi->visitors_visitor_id_get: %s\n" % e)
```

Delete visits using visitorId:
```python
import {{packageName}}
from {{packageName}}.rest import ApiException, KnownApiException

configuration = {{packageName}}.Configuration(api_key="SECRET_API_KEY")
api_instance = {{packageName}}.FingerprintApi(configuration)

visitor_id = 'visitor_id_example' # str | Unique [visitor identifier](https://dev.fingerprint.com/docs/js-agent#visitorid) issued by Fingerprint Pro.

try:
api_instance.delete_visitor_data(visitor_id)
except KnownApiException as e:
structured_error = e.structured_error
print("Error: %s\n" % structured_error.error)
except ApiException as e:
print("Exception when calling FingerprintApi->delete_visitor_data: %s\n" % e)
```

Fetching events for requestId:
Expand All @@ -126,7 +145,7 @@ from {{packageName}}.rest import ApiException, KnownApiException
configuration = {{packageName}}.Configuration(api_key="SECRET_API_KEY")
api_instance = {{packageName}}.FingerprintApi(configuration)

request_id = 'request_id_example' # str
request_id = 'request_id_example' # str | The unique event [identifier](https://dev.fingerprint.com/docs/js-agent#requestid).

try:
events_response: EventResponse = api_instance.get_event(request_id)
Expand All @@ -135,7 +154,31 @@ except KnownApiException as e:
structured_error = e.structured_error
print("Error code: %s. Error message: %s\n" % (structured_error.error.code, structured_error.error.message))
except ApiException as e:
print("Exception when calling DefaultApi->get_event: %s\n" % e)
print("Exception when calling FingerprintApi->get_event: %s\n" % e)
```

Update event for requestId:
```python
import {{packageName}}
from {{packageName}} import EventUpdateRequest
from {{packageName}}.rest import ApiException, KnownApiException

configuration = {{packageName}}.Configuration(api_key="SECRET_API_KEY")
api_instance = {{packageName}}.FingerprintApi(configuration)

request_id = 'request_id_example' # str | The unique event [identifier](https://dev.fingerprint.com/docs/js-agent#requestid).
body = EventUpdateRequest(linked_id='foo') # EventUpdateRequest |
# body = EventUpdateRequest(tag={'bar': 123})
# body = EventUpdateRequest(suspect=True)
# body = EventUpdateRequest(linked_id='foo', tag={'bar': 123}, suspect=False)

try:
api_instance.update_event(request_id, body)
except KnownApiException as e:
structured_error = e.structured_error
print("Error code: %s. Error message: %s\n" % (structured_error.error.code, structured_error.error.message))
except ApiException as e:
print("Exception when calling FingerprintApi->update_event: %s\n" % e)
```

## Sealed results
Expand Down Expand Up @@ -216,4 +259,4 @@ If you need private support, you can email us at [[email protected]](m

## License

This project is licensed under the [MIT License](https://github.com/fingerprintjs/fingerprint-pro-server-api-python-sdk/blob/main/LICENSE).
This project is licensed under the [MIT License](https://github.com/fingerprintjs/fingerprint-pro-server-api-python-sdk/blob/main/LICENSE).

0 comments on commit 2a23750

Please sign in to comment.