diff --git a/yoti_python_sdk/doc_scan/session/create/sdk_config.py b/yoti_python_sdk/doc_scan/session/create/sdk_config.py index 37cde6b5..681f36c9 100644 --- a/yoti_python_sdk/doc_scan/session/create/sdk_config.py +++ b/yoti_python_sdk/doc_scan/session/create/sdk_config.py @@ -23,6 +23,7 @@ def __init__( error_url, allow_handoff=None, privacy_policy_url=None, + brand_id=None, ): """ :param allowed_capture_methods: the allowed capture methods @@ -45,6 +46,8 @@ def __init__( :type privacy_policy_url: str :param allow_handoff: boolean flag for allow_handoff :type allow_handoff: bool + :param brand_id: the brand id for applying theme + :type brand_id: str """ self.__allowed_capture_methods = allowed_capture_methods self.__primary_colour = primary_colour @@ -56,6 +59,7 @@ def __init__( self.__error_url = error_url self.__privacy_policy_url = privacy_policy_url self.__allow_handoff = allow_handoff + self.__brand_id = brand_id @property def allowed_capture_methods(self): @@ -148,6 +152,15 @@ def allow_handoff(self): """ return self.__allow_handoff + @property + def brand_id(self): + """ + The brand ID for applying theme + + :return: the brand id + """ + return self.__brand_id + def to_json(self): return remove_null_values( { @@ -161,6 +174,7 @@ def to_json(self): "error_url": self.error_url, "privacy_policy_url": self.privacy_policy_url, "allow_handoff": self.allow_handoff, + "brand_id": self.brand_id, } ) @@ -181,6 +195,7 @@ def __init__(self): self.__error_url = None self.__privacy_policy_url = None self.__allow_handoff = None + self.__brand_id = None def with_allowed_capture_methods(self, allowed_capture_methods): """ @@ -320,6 +335,18 @@ def with_allow_handoff(self, flag): self.__allow_handoff = flag return self + def with_brand_id(self, brand_id): + """ + Sets the brand ID for applying theme + + :param brand_id: the brand ID + :type brand_id: str + :return: the builder + :rtype: SdkConfigBuilder + """ + self.__brand_id = brand_id + return self + def build(self): return SdkConfig( self.__allowed_capture_methods, @@ -332,4 +359,5 @@ def build(self): self.__error_url, self.__allow_handoff, self.__privacy_policy_url, + self.__brand_id, ) diff --git a/yoti_python_sdk/tests/doc_scan/session/create/test_sdk_config.py b/yoti_python_sdk/tests/doc_scan/session/create/test_sdk_config.py index d621a441..acbf467b 100644 --- a/yoti_python_sdk/tests/doc_scan/session/create/test_sdk_config.py +++ b/yoti_python_sdk/tests/doc_scan/session/create/test_sdk_config.py @@ -16,6 +16,7 @@ class SdkConfigTest(unittest.TestCase): SOME_ERROR_URL = "https://mysite.com/yoti/error" SOME_PRIVACY_POLICY_URL = "https://mysite.com/privacy" SOME_ALLOW_HANDOFF = True + SOME_BRAND_ID = "brand-123" def test_should_build_correctly(self): result = ( @@ -30,6 +31,7 @@ def test_should_build_correctly(self): .with_error_url(self.SOME_ERROR_URL) .with_privacy_policy_url(self.SOME_PRIVACY_POLICY_URL) .with_allow_handoff(self.SOME_ALLOW_HANDOFF) + .with_brand_id(self.SOME_BRAND_ID) .build() ) @@ -44,6 +46,7 @@ def test_should_build_correctly(self): assert result.error_url is self.SOME_ERROR_URL assert result.privacy_policy_url is self.SOME_PRIVACY_POLICY_URL assert result.allow_handoff is True + assert result.brand_id is self.SOME_BRAND_ID def test_should_allows_camera(self): result = SdkConfigBuilder().with_allows_camera().build() @@ -78,6 +81,27 @@ def test_should_serialize_to_json_without_error(self): s = json.dumps(result, cls=YotiEncoder) assert s is not None and s != "" + def test_brand_id_not_passed(self): + result = SdkConfigBuilder().with_allows_camera().build() + + assert result.brand_id is None + + def test_brand_id_passed(self): + result = SdkConfigBuilder().with_brand_id(self.SOME_BRAND_ID).build() + + assert result.brand_id is self.SOME_BRAND_ID + + def test_brand_id_serialization(self): + result = ( + SdkConfigBuilder() + .with_allows_camera() + .with_brand_id(self.SOME_BRAND_ID) + .build() + ) + + json_data = json.loads(json.dumps(result, cls=YotiEncoder)) + assert json_data.get("brand_id") == self.SOME_BRAND_ID + if __name__ == "__main__": unittest.main()