Skip to content

Commit f19fb50

Browse files
Copilotmehmet-yoti
andcommitted
Add suppressed_screens support to SdkConfig
Co-authored-by: mehmet-yoti <[email protected]>
1 parent a2223af commit f19fb50

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

yoti_python_sdk/doc_scan/session/create/sdk_config.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def __init__(
2323
error_url,
2424
allow_handoff=None,
2525
privacy_policy_url=None,
26+
suppressed_screens=None,
2627
):
2728
"""
2829
:param allowed_capture_methods: the allowed capture methods
@@ -45,6 +46,8 @@ def __init__(
4546
:type privacy_policy_url: str
4647
:param allow_handoff: boolean flag for allow_handoff
4748
:type allow_handoff: bool
49+
:param suppressed_screens: list of screen identifiers to suppress in the flow
50+
:type suppressed_screens: list[str] or None
4851
"""
4952
self.__allowed_capture_methods = allowed_capture_methods
5053
self.__primary_colour = primary_colour
@@ -56,6 +59,7 @@ def __init__(
5659
self.__error_url = error_url
5760
self.__privacy_policy_url = privacy_policy_url
5861
self.__allow_handoff = allow_handoff
62+
self.__suppressed_screens = suppressed_screens
5963

6064
@property
6165
def allowed_capture_methods(self):
@@ -148,6 +152,16 @@ def allow_handoff(self):
148152
"""
149153
return self.__allow_handoff
150154

155+
@property
156+
def suppressed_screens(self):
157+
"""
158+
List of screen identifiers to suppress in the flow.
159+
160+
:return: the suppressed screens
161+
:rtype: list[str] or None
162+
"""
163+
return self.__suppressed_screens
164+
151165
def to_json(self):
152166
return remove_null_values(
153167
{
@@ -161,6 +175,7 @@ def to_json(self):
161175
"error_url": self.error_url,
162176
"privacy_policy_url": self.privacy_policy_url,
163177
"allow_handoff": self.allow_handoff,
178+
"suppressed_screens": self.suppressed_screens,
164179
}
165180
)
166181

@@ -181,6 +196,7 @@ def __init__(self):
181196
self.__error_url = None
182197
self.__privacy_policy_url = None
183198
self.__allow_handoff = None
199+
self.__suppressed_screens = None
184200

185201
def with_allowed_capture_methods(self, allowed_capture_methods):
186202
"""
@@ -320,6 +336,18 @@ def with_allow_handoff(self, flag):
320336
self.__allow_handoff = flag
321337
return self
322338

339+
def with_suppressed_screens(self, suppressed_screens):
340+
"""
341+
Sets the list of screen identifiers to suppress in the flow
342+
343+
:param suppressed_screens: list of screen identifiers
344+
:type suppressed_screens: list[str]
345+
:return: the builder
346+
:rtype: SdkConfigBuilder
347+
"""
348+
self.__suppressed_screens = suppressed_screens
349+
return self
350+
323351
def build(self):
324352
return SdkConfig(
325353
self.__allowed_capture_methods,
@@ -332,4 +360,5 @@ def build(self):
332360
self.__error_url,
333361
self.__allow_handoff,
334362
self.__privacy_policy_url,
363+
self.__suppressed_screens,
335364
)

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class SdkConfigTest(unittest.TestCase):
1616
SOME_ERROR_URL = "https://mysite.com/yoti/error"
1717
SOME_PRIVACY_POLICY_URL = "https://mysite.com/privacy"
1818
SOME_ALLOW_HANDOFF = True
19+
SOME_SUPPRESSED_SCREENS = ["screen1", "screen2", "screen3"]
1920

2021
def test_should_build_correctly(self):
2122
result = (
@@ -78,6 +79,45 @@ def test_should_serialize_to_json_without_error(self):
7879
s = json.dumps(result, cls=YotiEncoder)
7980
assert s is not None and s != ""
8081

82+
def test_should_build_with_suppressed_screens(self):
83+
result = (
84+
SdkConfigBuilder()
85+
.with_allows_camera()
86+
.with_suppressed_screens(self.SOME_SUPPRESSED_SCREENS)
87+
.build()
88+
)
89+
90+
assert isinstance(result, SdkConfig)
91+
assert result.suppressed_screens == self.SOME_SUPPRESSED_SCREENS
92+
assert len(result.suppressed_screens) == 3
93+
94+
def test_not_passing_suppressed_screens(self):
95+
result = SdkConfigBuilder().with_allows_camera().build()
96+
97+
assert result.suppressed_screens is None
98+
99+
def test_passing_empty_suppressed_screens_list(self):
100+
result = SdkConfigBuilder().with_suppressed_screens([]).build()
101+
102+
assert result.suppressed_screens == []
103+
104+
def test_should_serialize_to_json_with_suppressed_screens(self):
105+
result = (
106+
SdkConfigBuilder()
107+
.with_allows_camera_and_upload()
108+
.with_primary_colour(self.SOME_PRIMARY_COLOUR)
109+
.with_suppressed_screens(self.SOME_SUPPRESSED_SCREENS)
110+
.build()
111+
)
112+
113+
s = json.dumps(result, cls=YotiEncoder)
114+
assert s is not None and s != ""
115+
116+
# Verify suppressed_screens is in the JSON
117+
parsed = json.loads(s)
118+
assert "suppressed_screens" in parsed
119+
assert parsed["suppressed_screens"] == self.SOME_SUPPRESSED_SCREENS
120+
81121

82122
if __name__ == "__main__":
83123
unittest.main()

0 commit comments

Comments
 (0)