Skip to content

Commit 2b84049

Browse files
Copilotmehmet-yoti
andcommitted
Add brand_id support to SdkConfig and SdkConfigBuilder
Co-authored-by: mehmet-yoti <[email protected]>
1 parent 7e98493 commit 2b84049

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-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 identifier for applying custom themes
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 identifier for applying custom themes
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 identifier for applying custom themes
341+
342+
:param brand_id: the brand identifier
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: 28 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 = "test-brand-id-123"
1920

2021
def test_should_build_correctly(self):
2122
result = (
@@ -78,6 +79,33 @@ 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_brand_id(self):
83+
result = SdkConfigBuilder().with_brand_id(self.SOME_BRAND_ID).build()
84+
85+
assert result.brand_id == self.SOME_BRAND_ID
86+
87+
def test_not_passing_brand_id(self):
88+
result = SdkConfigBuilder().with_allows_camera().build()
89+
90+
assert result.brand_id is None
91+
92+
def test_should_include_brand_id_in_json(self):
93+
result = (
94+
SdkConfigBuilder()
95+
.with_allows_camera()
96+
.with_brand_id(self.SOME_BRAND_ID)
97+
.build()
98+
)
99+
100+
json_data = result.to_json()
101+
assert json_data["brand_id"] == self.SOME_BRAND_ID
102+
103+
def test_should_exclude_null_brand_id_from_json(self):
104+
result = SdkConfigBuilder().with_allows_camera().build()
105+
106+
json_data = result.to_json()
107+
assert "brand_id" not in json_data
108+
81109

82110
if __name__ == "__main__":
83111
unittest.main()

0 commit comments

Comments
 (0)