Coverage for fingerprint_pro_server_api_sdk/api/fingerprint_api.py: 89%
106 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-27 22:39 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-27 22:39 +0000
1# coding: utf-8
3"""
4 Fingerprint Pro Server API
6 Fingerprint Pro Server API allows you to get information about visitors and about individual events in a server environment. It can be used for data exports, decision-making, and data analysis scenarios. Server API is intended for server-side usage, it's not intended to be used from the client side, whether it's a browser or a mobile device. # noqa: E501
8 OpenAPI spec version: 3
9 Contact: support@fingerprint.com
10 Generated by: https://github.com/swagger-api/swagger-codegen.git
11"""
13from __future__ import absolute_import
15import re # noqa: F401
17# python 2 and python 3 compatibility library
18import six
20from fingerprint_pro_server_api_sdk.api_client import ApiClient
21from fingerprint_pro_server_api_sdk.extend_exception import extend_exception
22from fingerprint_pro_server_api_sdk.rest import ApiException
25class FingerprintApi(object):
26 """NOTE: This class is auto generated by the swagger code generator program.
28 Do not edit the class manually.
29 Ref: https://github.com/swagger-api/swagger-codegen
30 """
32 def __init__(self, configuration=None, pool=None):
33 if configuration is None:
34 raise ValueError("Missing the required parameter `configuration` when calling `FingerprintApi`") # noqa: E501
35 self.api_client = ApiClient(configuration, pool=pool)
37 def get_event(self, request_id, **kwargs): # noqa: E501
38 """Get event by requestId # noqa: E501
40 This endpoint allows you to get a detailed analysis of an individual request. **Only for Enterprise customers:** 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
41 This method makes a synchronous HTTP request by default. To make an
42 asynchronous HTTP request, please pass async_req=True
43 >>> thread = api.get_event(request_id, async_req=True)
44 >>> result = thread.get()
46 :param async_req bool
47 :param str request_id: The unique [identifier](https://dev.fingerprint.com/docs/js-agent#requestid) of each analysis request. (required)
48 :return: EventResponse
49 If the method is called asynchronously,
50 returns the request thread.
51 """
52 kwargs['_return_http_data_only'] = True
53 if kwargs.get('async_req'):
54 return self.get_event_with_http_info(request_id, **kwargs) # noqa: E501
55 else:
56 (data) = self.get_event_with_http_info(request_id, **kwargs) # noqa: E501
57 return data
59 def get_event_with_http_info(self, request_id, **kwargs): # noqa: E501
60 """Get event by requestId # noqa: E501
62 This endpoint allows you to get a detailed analysis of an individual request. **Only for Enterprise customers:** 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
63 This method makes a synchronous HTTP request by default. To make an
64 asynchronous HTTP request, please pass async_req=True
65 >>> thread = api.get_event_with_http_info(request_id, async_req=True)
66 >>> result = thread.get()
68 :param async_req bool
69 :param str request_id: The unique [identifier](https://dev.fingerprint.com/docs/js-agent#requestid) of each analysis request. (required)
70 :return: EventResponse
71 If the method is called asynchronously,
72 returns the request thread.
73 """
75 all_params = ['request_id'] # noqa: E501
76 all_params.append('async_req')
77 all_params.append('_return_http_data_only')
78 all_params.append('_preload_content')
79 all_params.append('_request_timeout')
81 params = locals()
82 for key, val in six.iteritems(params['kwargs']):
83 if key not in all_params:
84 raise TypeError(
85 "Got an unexpected keyword argument '%s'"
86 " to method get_event" % key
87 )
88 params[key] = val
89 del params['kwargs']
90 # verify the required parameter 'request_id' is set
91 if ('request_id' not in params or
92 params['request_id'] is None): # noqa: E501
93 raise ValueError("Missing the required parameter `request_id` when calling `get_event`") # noqa: E501
95 collection_formats = {}
97 path_params = {}
98 if 'request_id' in params:
99 path_params['request_id'] = params['request_id'] # noqa: E501
101 query_params = []
102 query_params.append(('ii', 'fingerprint-pro-server-python-sdk/5.0.0'))
104 header_params = {}
106 form_params = []
107 local_var_files = {}
109 body_params = None
110 # HTTP header `Accept`
111 header_params['Accept'] = self.api_client.select_header_accept(
112 ['application/json']) # noqa: E501
114 # Authentication setting
115 auth_settings = ['ApiKeyHeader', 'ApiKeyQuery'] # noqa: E501
117 try:
118 return self.api_client.call_api(
119 '/events/{request_id}', 'GET',
120 path_params,
121 query_params,
122 header_params,
123 body=body_params,
124 post_params=form_params,
125 files=local_var_files,
126 response_type='EventResponse', # noqa: E501
127 auth_settings=auth_settings,
128 async_req=params.get('async_req'),
129 _return_http_data_only=params.get('_return_http_data_only'),
130 _preload_content=params.get('_preload_content', True),
131 _request_timeout=params.get('_request_timeout'),
132 collection_formats=collection_formats)
133 except ApiException as e:
134 if e.status == 403:
135 error = self.api_client.deserialize(e, 'ErrorEvent403Response', True)
136 raise extend_exception(e, error)
137 if e.status == 404:
138 error = self.api_client.deserialize(e, 'ErrorEvent404Response', True)
139 raise extend_exception(e, error)
140 raise e
142 def get_visits(self, visitor_id, **kwargs): # noqa: E501
143 """Get visits by visitorId # noqa: E501
145 This endpoint allows you to get a history of visits 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
146 This method makes a synchronous HTTP request by default. To make an
147 asynchronous HTTP request, please pass async_req=True
148 >>> thread = api.get_visits(visitor_id, async_req=True)
149 >>> result = thread.get()
151 :param async_req bool
152 :param str visitor_id: Unique identifier of the visitor issued by Fingerprint Pro. (required)
153 :param str request_id: Filter visits by `requestId`. Every identification request has a unique identifier associated with it called `requestId`. This identifier is returned to the client in the identification [result](https://dev.fingerprint.com/docs/js-agent#requestid). When you filter visits by `requestId`, only one visit will be returned.
154 :param str linked_id: 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.
155 :param int limit: 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.
156 :param str pagination_key: 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.
157 :param int before: ⚠️ Deprecated pagination method, please use `paginationKey` instead. Timestamp (in milliseconds since epoch) used to paginate results.
158 :return: Response
159 If the method is called asynchronously,
160 returns the request thread.
161 """
162 kwargs['_return_http_data_only'] = True
163 if kwargs.get('async_req'):
164 return self.get_visits_with_http_info(visitor_id, **kwargs) # noqa: E501
165 else:
166 (data) = self.get_visits_with_http_info(visitor_id, **kwargs) # noqa: E501
167 return data
169 def get_visits_with_http_info(self, visitor_id, **kwargs): # noqa: E501
170 """Get visits by visitorId # noqa: E501
172 This endpoint allows you to get a history of visits 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
173 This method makes a synchronous HTTP request by default. To make an
174 asynchronous HTTP request, please pass async_req=True
175 >>> thread = api.get_visits_with_http_info(visitor_id, async_req=True)
176 >>> result = thread.get()
178 :param async_req bool
179 :param str visitor_id: Unique identifier of the visitor issued by Fingerprint Pro. (required)
180 :param str request_id: Filter visits by `requestId`. Every identification request has a unique identifier associated with it called `requestId`. This identifier is returned to the client in the identification [result](https://dev.fingerprint.com/docs/js-agent#requestid). When you filter visits by `requestId`, only one visit will be returned.
181 :param str linked_id: 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.
182 :param int limit: 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.
183 :param str pagination_key: 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.
184 :param int before: ⚠️ Deprecated pagination method, please use `paginationKey` instead. Timestamp (in milliseconds since epoch) used to paginate results.
185 :return: Response
186 If the method is called asynchronously,
187 returns the request thread.
188 """
190 all_params = ['visitor_id', 'request_id', 'linked_id', 'limit', 'pagination_key', 'before'] # noqa: E501
191 all_params.append('async_req')
192 all_params.append('_return_http_data_only')
193 all_params.append('_preload_content')
194 all_params.append('_request_timeout')
196 params = locals()
197 for key, val in six.iteritems(params['kwargs']):
198 if key not in all_params:
199 raise TypeError(
200 "Got an unexpected keyword argument '%s'"
201 " to method get_visits" % key
202 )
203 params[key] = val
204 del params['kwargs']
205 # verify the required parameter 'visitor_id' is set
206 if ('visitor_id' not in params or
207 params['visitor_id'] is None): # noqa: E501
208 raise ValueError("Missing the required parameter `visitor_id` when calling `get_visits`") # noqa: E501
210 collection_formats = {}
212 path_params = {}
213 if 'visitor_id' in params:
214 path_params['visitor_id'] = params['visitor_id'] # noqa: E501
216 query_params = []
217 query_params.append(('ii', 'fingerprint-pro-server-python-sdk/5.0.0'))
218 if 'request_id' in params:
219 query_params.append(('request_id', params['request_id'])) # noqa: E501
220 if 'linked_id' in params:
221 query_params.append(('linked_id', params['linked_id'])) # noqa: E501
222 if 'limit' in params:
223 query_params.append(('limit', params['limit'])) # noqa: E501
224 if 'pagination_key' in params:
225 query_params.append(('paginationKey', params['pagination_key'])) # noqa: E501
226 if 'before' in params:
227 query_params.append(('before', params['before'])) # noqa: E501
229 header_params = {}
231 form_params = []
232 local_var_files = {}
234 body_params = None
235 # HTTP header `Accept`
236 header_params['Accept'] = self.api_client.select_header_accept(
237 ['application/json']) # noqa: E501
239 # Authentication setting
240 auth_settings = ['ApiKeyHeader', 'ApiKeyQuery'] # noqa: E501
242 try:
243 return self.api_client.call_api(
244 '/visitors/{visitor_id}', 'GET',
245 path_params,
246 query_params,
247 header_params,
248 body=body_params,
249 post_params=form_params,
250 files=local_var_files,
251 response_type='Response', # noqa: E501
252 auth_settings=auth_settings,
253 async_req=params.get('async_req'),
254 _return_http_data_only=params.get('_return_http_data_only'),
255 _preload_content=params.get('_preload_content', True),
256 _request_timeout=params.get('_request_timeout'),
257 collection_formats=collection_formats)
258 except ApiException as e:
259 if e.status == 403:
260 error = self.api_client.deserialize(e, 'ErrorVisits403', True)
261 raise extend_exception(e, error)
262 if e.status == 429:
263 error = self.api_client.deserialize(e, 'ManyRequestsResponse', True)
264 raise extend_exception(e, error)
265 raise e