Skip to content

Commit c5b6065

Browse files
Merge pull request #344 from getyoti/feat/session_deadline
[SDK-1980] Add support for Session Deadline
2 parents e3e31e9 + 8ca2f92 commit c5b6065

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

yoti_python_sdk/doc_scan/session/create/session_spec.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def __init__(
2121
requested_tasks=None,
2222
required_documents=None,
2323
block_biometric_consent=None,
24+
session_deadline=None,
2425
):
2526
"""
2627
:param client_session_token_ttl: the client session token TTL
@@ -41,6 +42,8 @@ def __init__(
4142
:type required_documents: list[RequiredDocument] or None
4243
:param block_biometric_consent: block the collection of biometric consent
4344
:type block_biometric_consent: bool
45+
:param session_deadline: session deadline using a Zoned timestamp
46+
"type session_deadline: str
4447
"""
4548
if requested_tasks is None:
4649
requested_tasks = []
@@ -58,6 +61,7 @@ def __init__(
5861
self.__requested_tasks = requested_tasks
5962
self.__required_documents = required_documents
6063
self.__block_biometric_consent = block_biometric_consent
64+
self.__session_deadline = session_deadline
6165

6266
@property
6367
def client_session_token_ttl(self):
@@ -152,6 +156,16 @@ def block_biometric_consent(self):
152156
"""
153157
return self.__block_biometric_consent
154158

159+
@property
160+
def session_deadline(self):
161+
"""
162+
Session deadline used by IDV
163+
164+
:return: session deadline
165+
:rtype: str
166+
"""
167+
return self.__session_deadline
168+
155169
def to_json(self):
156170
return remove_null_values(
157171
{
@@ -164,6 +178,7 @@ def to_json(self):
164178
"sdk_config": self.sdk_config,
165179
"required_documents": self.required_documents,
166180
"block_biometric_consent": self.block_biometric_consent,
181+
"session_deadline": self.session_deadline,
167182
}
168183
)
169184

@@ -183,6 +198,7 @@ def __init__(self):
183198
self.__requested_tasks = []
184199
self.__required_documents = []
185200
self.__block_biometric_consent = None
201+
self.__session_deadline = None
186202

187203
def with_client_session_token_ttl(self, value):
188204
"""
@@ -196,6 +212,19 @@ def with_client_session_token_ttl(self, value):
196212
self.__client_session_token_ttl = value
197213
return self
198214

215+
def with_session_deadline(self, value):
216+
"""
217+
Sets the deadline that the session needs to be completed by.
218+
Can be used as an alternative to with_client_session_token_ttl.
219+
220+
:param value: the session deadline
221+
:type value: str
222+
:return: the builder
223+
:rtype: SessionSpecBuilder
224+
"""
225+
self.__session_deadline = value
226+
return self
227+
199228
def with_resources_ttl(self, value):
200229
"""
201230
Sets the resources TTL (time-to-live)
@@ -309,4 +338,5 @@ def build(self):
309338
self.__requested_tasks,
310339
self.__required_documents,
311340
self.__block_biometric_consent,
341+
self.__session_deadline,
312342
)

yoti_python_sdk/doc_scan/session/retrieve/create_session_result.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def __init__(self, data=None):
1616
data = dict()
1717

1818
self.__client_session_token_ttl = data.get("client_session_token_ttl", None)
19+
self.__session_deadline = data.get("session_deadline", None)
1920
self.__session_id = data.get("session_id", None)
2021
self.__client_session_token = data.get("client_session_token", None)
2122

@@ -49,3 +50,13 @@ def session_id(self):
4950
:rtype: str or None
5051
"""
5152
return self.__session_id
53+
54+
@property
55+
def session_deadline(self):
56+
"""
57+
The deadline that the session needs to be completed by.
58+
59+
:return: the session deadline
60+
:rtype: str or None
61+
"""
62+
return self.__session_deadline

yoti_python_sdk/tests/doc_scan/session/create/test_session_spec.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class SessionSpecTest(unittest.TestCase):
2121
SOME_CLIENT_SESSION_TOKEN_TTL = 300
2222
SOME_RESOURCES_TTL = 100000
2323
SOME_USER_TRACKING_ID = "someUserTrackingId"
24+
SOME_SESSION_DEADLINE = "2021-09-03T11:40:54.727619+02:00"
2425

2526
def test_should_build_correctly(self):
2627
sdk_config_mock = Mock(spec=SdkConfig)
@@ -31,6 +32,7 @@ def test_should_build_correctly(self):
3132
result = (
3233
SessionSpecBuilder()
3334
.with_client_session_token_ttl(self.SOME_CLIENT_SESSION_TOKEN_TTL)
35+
.with_session_deadline(self.SOME_SESSION_DEADLINE)
3436
.with_resources_ttl(self.SOME_RESOURCES_TTL)
3537
.with_user_tracking_id(self.SOME_USER_TRACKING_ID)
3638
.with_notifications(notification_mock)
@@ -49,6 +51,7 @@ def test_should_build_correctly(self):
4951
assert requested_check_mock in result.requested_checks
5052
assert len(result.requested_tasks) == 1
5153
assert requested_task_mock in result.requested_tasks
54+
assert result.session_deadline == self.SOME_SESSION_DEADLINE
5255

5356
def test_should_serialize_to_json_without_error(self):
5457
sdk_config_mock = Mock(spec=SdkConfig)
@@ -66,6 +69,7 @@ def test_should_serialize_to_json_without_error(self):
6669
result = (
6770
SessionSpecBuilder()
6871
.with_client_session_token_ttl(self.SOME_CLIENT_SESSION_TOKEN_TTL)
72+
.with_session_deadline(self.SOME_SESSION_DEADLINE)
6973
.with_resources_ttl(self.SOME_RESOURCES_TTL)
7074
.with_user_tracking_id(self.SOME_USER_TRACKING_ID)
7175
.with_notifications(notification_mock)

0 commit comments

Comments
 (0)