Skip to content

Commit c46a784

Browse files
committed
Modify reponse
1 parent 47b76c9 commit c46a784

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

uid2_client/identity_map_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import base64
22
import datetime as dt
33
import json
4+
import time
45
from datetime import timezone
56

67
from .identity_buckets_response import IdentityBucketsResponse
@@ -37,10 +38,13 @@ def __init__(self, base_url, api_key, client_secret):
3738
def generate_identity_map(self, identity_map_input):
3839
req, nonce = make_v2_request(self._client_secret, dt.datetime.now(tz=timezone.utc),
3940
identity_map_input.get_identity_map_input_as_json_string().encode())
41+
start_time = time.time()
4042
resp = post(self._base_url, '/v2/identity/map', headers=auth_headers(self._api_key), data=req)
4143
resp.raise_for_status()
4244
resp_body = parse_v2_response(self._client_secret, resp.text, nonce)
43-
return IdentityMapResponse(resp_body, identity_map_input)
45+
end_time = time.time()
46+
elapsed_time = end_time - start_time
47+
return IdentityMapResponse(resp_body, identity_map_input, elapsed_time)
4448

4549
def get_identity_buckets(self, since_timestamp):
4650
req, nonce = make_v2_request(self._client_secret, dt.datetime.now(tz=timezone.utc),

uid2_client/identity_map_response.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33

44
class IdentityMapResponse:
5-
def __init__(self, response, identity_map_input):
5+
def __init__(self, response, identity_map_input, elapsed_time=None):
66
self._mapped_identities = {}
77
self._unmapped_identities = {}
8+
self._response = response
9+
self._elapsed_time = None
810
response_json = json.loads(response)
911
self._status = response_json["status"]
1012

13+
if elapsed_time is not None:
14+
self._elapsed_time = elapsed_time
15+
1116
if not self.is_success():
1217
raise ValueError("Got unexpected identity map status: " + self._status)
1318

@@ -44,6 +49,14 @@ def unmapped_identities(self):
4449
@property
4550
def status(self):
4651
return self._status
52+
53+
@property
54+
def elapsed_time(self):
55+
return self._elapsed_time
56+
57+
@property
58+
def response(self):
59+
return self._response
4760

4861

4962
class MappedIdentity:

0 commit comments

Comments
 (0)