Skip to content

Commit f0c20da

Browse files
Copilotmehmet-yoti
andcommitted
Add brand_id support to SdkConfig with tests
Co-authored-by: mehmet-yoti <[email protected]>
1 parent fee1ec3 commit f0c20da

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

yoti_python_sdk/doc_scan/session/create/sdk_config.py

Lines changed: 28 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+
brand_id=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 brand_id: the brand id for applying theme
50+
:type brand_id: str
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.__brand_id = brand_id
5963

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

155+
@property
156+
def brand_id(self):
157+
"""
158+
The brand ID for applying theme
159+
160+
:return: the brand id
161+
"""
162+
return self.__brand_id
163+
151164
def to_json(self):
152165
return remove_null_values(
153166
{
@@ -161,6 +174,7 @@ def to_json(self):
161174
"error_url": self.error_url,
162175
"privacy_policy_url": self.privacy_policy_url,
163176
"allow_handoff": self.allow_handoff,
177+
"brand_id": self.brand_id,
164178
}
165179
)
166180

@@ -181,6 +195,7 @@ def __init__(self):
181195
self.__error_url = None
182196
self.__privacy_policy_url = None
183197
self.__allow_handoff = None
198+
self.__brand_id = None
184199

185200
def with_allowed_capture_methods(self, allowed_capture_methods):
186201
"""
@@ -320,6 +335,18 @@ def with_allow_handoff(self, flag):
320335
self.__allow_handoff = flag
321336
return self
322337

338+
def with_brand_id(self, brand_id):
339+
"""
340+
Sets the brand ID for applying theme
341+
342+
:param brand_id: the brand ID
343+
:type brand_id: str
344+
:return: the builder
345+
:rtype: SdkConfigBuilder
346+
"""
347+
self.__brand_id = brand_id
348+
return self
349+
323350
def build(self):
324351
return SdkConfig(
325352
self.__allowed_capture_methods,
@@ -332,4 +359,5 @@ def build(self):
332359
self.__error_url,
333360
self.__allow_handoff,
334361
self.__privacy_policy_url,
362+
self.__brand_id,
335363
)

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

Lines changed: 24 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_BRAND_ID = "brand-123"
1920

2021
def test_should_build_correctly(self):
2122
result = (
@@ -30,6 +31,7 @@ def test_should_build_correctly(self):
3031
.with_error_url(self.SOME_ERROR_URL)
3132
.with_privacy_policy_url(self.SOME_PRIVACY_POLICY_URL)
3233
.with_allow_handoff(self.SOME_ALLOW_HANDOFF)
34+
.with_brand_id(self.SOME_BRAND_ID)
3335
.build()
3436
)
3537

@@ -44,6 +46,7 @@ def test_should_build_correctly(self):
4446
assert result.error_url is self.SOME_ERROR_URL
4547
assert result.privacy_policy_url is self.SOME_PRIVACY_POLICY_URL
4648
assert result.allow_handoff is True
49+
assert result.brand_id is self.SOME_BRAND_ID
4750

4851
def test_should_allows_camera(self):
4952
result = SdkConfigBuilder().with_allows_camera().build()
@@ -78,6 +81,27 @@ def test_should_serialize_to_json_without_error(self):
7881
s = json.dumps(result, cls=YotiEncoder)
7982
assert s is not None and s != ""
8083

84+
def test_brand_id_not_passed(self):
85+
result = SdkConfigBuilder().with_allows_camera().build()
86+
87+
assert result.brand_id is None
88+
89+
def test_brand_id_passed(self):
90+
result = SdkConfigBuilder().with_brand_id(self.SOME_BRAND_ID).build()
91+
92+
assert result.brand_id is self.SOME_BRAND_ID
93+
94+
def test_brand_id_serialization(self):
95+
result = (
96+
SdkConfigBuilder()
97+
.with_allows_camera()
98+
.with_brand_id(self.SOME_BRAND_ID)
99+
.build()
100+
)
101+
102+
json_data = json.loads(json.dumps(result, cls=YotiEncoder))
103+
assert json_data.get("brand_id") == self.SOME_BRAND_ID
104+
81105

82106
if __name__ == "__main__":
83107
unittest.main()

0 commit comments

Comments
 (0)