Skip to content

Commit

Permalink
chore: improve async response typing, add example for async response
Browse files Browse the repository at this point in the history
  • Loading branch information
ilfa committed Aug 8, 2024
1 parent 0723f0d commit ac9e6f1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
10 changes: 5 additions & 5 deletions fingerprint_pro_server_api_sdk/api/fingerprint_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import re # noqa: F401
from multiprocessing import Pool
from threading import Thread
from multiprocessing.pool import ApplyResult as AsyncResult
from typing import Optional, Union

from fingerprint_pro_server_api_sdk.configuration import Configuration
Expand Down Expand Up @@ -45,7 +45,7 @@ def __init__(self, configuration: Optional[Configuration] = None, pool: Optional
raise ValueError("Missing the required parameter `configuration` when calling `FingerprintApi`") # noqa: E501
self.api_client = ApiClient(configuration, pool=pool)

def delete_visitor_data(self, visitor_id: str, **kwargs) -> Union[None, Thread]: # noqa: E501
def delete_visitor_data(self, visitor_id: str, **kwargs) -> Union[None, AsyncResult[None]]: # noqa: E501
"""Delete data by visitor ID # noqa: E501
Request deleting all data associated with the specified visitor ID. This API is useful for compliance with privacy regulations. All delete requests are queued: * Recent data (10 days or newer) belonging to the specified visitor will be deleted within 24 hours. * Data from older (11 days or more) identification events will be deleted after 90 days. If you are interested in using this API, please [contact our support team](https://fingerprint.com/support/) to enable it for you. Otherwise, you will receive a 403. # noqa: E501
Expand Down Expand Up @@ -155,7 +155,7 @@ def delete_visitor_data_with_http_info(self, visitor_id: str, **kwargs): # noqa
raise extend_exception(e, error)
raise e

def get_event(self, request_id: str, **kwargs) -> Union[EventResponse, Thread]: # noqa: E501
def get_event(self, request_id: str, **kwargs) -> Union[EventResponse, AsyncResult[EventResponse]]: # noqa: E501
"""Get event by request ID # noqa: E501
Get a detailed analysis of an individual identification event, including Smart Signals. Please note that the response includes mobile signals (e.g. `rootApps`) even if the request originated from a non-mobile platform. It is highly recommended that you **ignore** the mobile signals for such requests. Use `requestId` as the URL path parameter. This API method is scoped to a request, i.e. all returned information is by `requestId`. # noqa: E501
Expand Down Expand Up @@ -259,7 +259,7 @@ def get_event_with_http_info(self, request_id: str, **kwargs): # noqa: E501
raise extend_exception(e, error)
raise e

def get_visits(self, visitor_id: str, **kwargs) -> Union[Response, Thread]: # noqa: E501
def get_visits(self, visitor_id: str, **kwargs) -> Union[Response, AsyncResult[Response]]: # noqa: E501
"""Get visits by visitor ID # noqa: E501
Get a history of visits (identification events) for a specific `visitorId`. Use the `visitorId` as a URL path parameter. Only information from the _Identification_ product is returned. #### Headers * `Retry-After` — Present in case of `429 Too many requests`. Indicates how long you should wait before making a follow-up request. The value is non-negative decimal integer indicating the seconds to delay after the response is received. # noqa: E501
Expand Down Expand Up @@ -388,7 +388,7 @@ def get_visits_with_http_info(self, visitor_id: str, **kwargs): # noqa: E501
raise extend_exception(e, error)
raise e

def update_event(self, body: EventUpdateRequest, request_id: str, **kwargs) -> Union[None, Thread]: # noqa: E501
def update_event(self, body: EventUpdateRequest, request_id: str, **kwargs) -> Union[None, AsyncResult[None]]: # noqa: E501
"""Update an event with a given request ID # noqa: E501
Change information in existing events specified by `requestId` or *flag suspicious events*. When an event is created, it is assigned `linkedId` and `tag` submitted through the JS agent parameters. This information might not be available on the client so the Server API allows for updating the attributes after the fact. **Warning** It's not possible to update events older than 10 days. # noqa: E501
Expand Down
12 changes: 12 additions & 0 deletions run_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
print("Exception when calling DefaultApi->get_event: %s\n" % e)
exit(1)

# Async methods examples
try:
visits_response_request = api_instance.get_visits(visitor_id, limit=2, async_req=True)
events_response_request = api_instance.get_event(request_id, async_req=True)
visits_response = visits_response_request.get()
print("\n\n\nVisits async response: \n", visits_response)
events_response = events_response_request.get()
print("\n\n\nEvent async response: \n", events_response.products)
except ApiException as e:
print("Exception when calling Async example: %s\n" % e)
exit(1)

print("Checks passed!")

exit(0)
4 changes: 2 additions & 2 deletions template/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import re # noqa: F401
from multiprocessing import Pool
from threading import Thread
from multiprocessing.pool import ApplyResult as AsyncResult
from typing import Optional, Union

from {{packageName}}.configuration import Configuration
Expand All @@ -30,7 +30,7 @@ class {{classname}}:
self.api_client = ApiClient(configuration, pool=pool)
{{#operation}}

def {{operationId}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}: {{dataType}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) -> Union[{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}, Thread]: # noqa: E501
def {{operationId}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}: {{dataType}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) -> Union[{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}, AsyncResult[{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}]]: # noqa: E501
"""{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501

{{#notes}}
Expand Down

0 comments on commit ac9e6f1

Please sign in to comment.