Skip to content

Commit 5be853f

Browse files
committed
SDK-1718: Move remove_null_values to be called in each to_json method, rather than adding on an exposed method
1 parent 66e6883 commit 5be853f

14 files changed

+68
-107
lines changed

yoti_python_sdk/doc_scan/session/create/check/document_authenticity.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from __future__ import unicode_literals
33

44
from yoti_python_sdk.doc_scan.constants import ID_DOCUMENT_AUTHENTICITY
5-
from yoti_python_sdk.utils import YotiSerializable
5+
from yoti_python_sdk.utils import YotiSerializable, remove_null_values
66
from .requested_check import RequestedCheck
77

88

@@ -12,10 +12,7 @@ class RequestedDocumentAuthenticityCheckConfig(YotiSerializable):
1212
"""
1313

1414
def to_json(self):
15-
return {}
16-
17-
def include_null_values(self):
18-
return False
15+
return remove_null_values({})
1916

2017

2118
class RequestedDocumentAuthenticityCheck(RequestedCheck):

yoti_python_sdk/doc_scan/session/create/check/face_match.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from __future__ import unicode_literals
33

44
from yoti_python_sdk.doc_scan import constants
5-
from yoti_python_sdk.utils import YotiSerializable
5+
from yoti_python_sdk.utils import YotiSerializable, remove_null_values
66
from .requested_check import RequestedCheck
77

88

@@ -30,10 +30,7 @@ def manual_check(self):
3030
return self.__manual_check
3131

3232
def to_json(self):
33-
return {"manual_check": self.manual_check}
34-
35-
def include_null_values(self):
36-
return False
33+
return remove_null_values({"manual_check": self.manual_check})
3734

3835

3936
class RequestedFaceMatchCheck(RequestedCheck):

yoti_python_sdk/doc_scan/session/create/check/liveness.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from __future__ import unicode_literals
33

44
from yoti_python_sdk.doc_scan import constants
5-
from yoti_python_sdk.utils import YotiSerializable
5+
from yoti_python_sdk.utils import YotiSerializable, remove_null_values
66
from .requested_check import RequestedCheck
77

88

@@ -40,10 +40,9 @@ def max_retries(self):
4040
return self.__max_retries
4141

4242
def to_json(self):
43-
return {"liveness_type": self.liveness_type, "max_retries": self.max_retries}
44-
45-
def include_null_values(self):
46-
return False
43+
return remove_null_values(
44+
{"liveness_type": self.liveness_type, "max_retries": self.max_retries}
45+
)
4746

4847

4948
class RequestedLivenessCheck(RequestedCheck):

yoti_python_sdk/doc_scan/session/create/check/requested_check.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from abc import ABCMeta
22
from abc import abstractmethod
33

4-
from yoti_python_sdk.utils import YotiSerializable
4+
from yoti_python_sdk.utils import YotiSerializable, remove_null_values
55

66

77
class RequestedCheck(YotiSerializable):
@@ -33,7 +33,4 @@ def config(self):
3333
raise NotImplementedError
3434

3535
def to_json(self):
36-
return {"type": self.type, "config": self.config}
37-
38-
def include_null_values(self):
39-
return False
36+
return remove_null_values({"type": self.type, "config": self.config})

yoti_python_sdk/doc_scan/session/create/filter/document_filter.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from abc import ABCMeta
22

3-
from yoti_python_sdk.utils import YotiSerializable
3+
from yoti_python_sdk.utils import YotiSerializable, remove_null_values
44

55

66
class DocumentFilter(YotiSerializable):
@@ -14,7 +14,4 @@ def type(self):
1414
return self.__filter_type
1515

1616
def to_json(self):
17-
return {"type": self.type}
18-
19-
def include_null_values(self):
20-
return False
17+
return remove_null_values({"type": self.type})

yoti_python_sdk/doc_scan/session/create/filter/document_restrictions_filter.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
INCLUSION_BLACKLIST,
44
INCLUSION_WHITELIST,
55
)
6-
from yoti_python_sdk.utils import YotiSerializable
6+
from yoti_python_sdk.utils import YotiSerializable, remove_null_values
77
from .document_filter import DocumentFilter
88

99

@@ -21,13 +21,12 @@ def document_types(self):
2121
return self.__document_types
2222

2323
def to_json(self):
24-
return {
25-
"country_codes": self.country_codes,
26-
"document_types": self.document_types,
27-
}
28-
29-
def include_null_values(self):
30-
return False
24+
return remove_null_values(
25+
{
26+
"country_codes": self.country_codes,
27+
"document_types": self.document_types,
28+
}
29+
)
3130

3231

3332
class DocumentRestrictionBuilder(object):
@@ -88,10 +87,7 @@ def to_json(self):
8887
parent = DocumentFilter.to_json(self)
8988
parent["inclusion"] = self.inclusion
9089
parent["documents"] = self.documents
91-
return parent
92-
93-
def include_null_values(self):
94-
return False
90+
return remove_null_values(parent)
9591

9692

9793
class DocumentRestrictionsFilterBuilder(object):

yoti_python_sdk/doc_scan/session/create/filter/orthogonal_restrictions_filter.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from yoti_python_sdk.doc_scan.constants import INCLUSION_BLACKLIST
22
from yoti_python_sdk.doc_scan.constants import INCLUSION_WHITELIST
33
from yoti_python_sdk.doc_scan.constants import ORTHOGONAL_RESTRICTIONS
4-
from yoti_python_sdk.utils import YotiSerializable
4+
from yoti_python_sdk.utils import YotiSerializable, remove_null_values
55
from .document_filter import DocumentFilter
66

77

@@ -31,10 +31,9 @@ def country_codes(self):
3131
return self.__country_codes
3232

3333
def to_json(self):
34-
return {"inclusion": self.inclusion, "country_codes": self.country_codes}
35-
36-
def include_null_values(self):
37-
return False
34+
return remove_null_values(
35+
{"inclusion": self.inclusion, "country_codes": self.country_codes}
36+
)
3837

3938

4039
class TypeRestriction(YotiSerializable):
@@ -63,10 +62,9 @@ def document_types(self):
6362
return self.__document_types
6463

6564
def to_json(self):
66-
return {"inclusion": self.inclusion, "document_types": self.document_types}
67-
68-
def include_null_values(self):
69-
return False
65+
return remove_null_values(
66+
{"inclusion": self.inclusion, "document_types": self.document_types}
67+
)
7068

7169

7270
class OrthogonalRestrictionsFilter(DocumentFilter):
@@ -100,10 +98,7 @@ def to_json(self):
10098
parent = DocumentFilter.to_json(self)
10199
parent["country_restriction"] = self.country_restriction
102100
parent["type_restriction"] = self.type_restriction
103-
return parent
104-
105-
def include_null_values(self):
106-
return False
101+
return remove_null_values(parent)
107102

108103

109104
class OrthogonalRestrictionsFilterBuilder(object):

yoti_python_sdk/doc_scan/session/create/filter/required_id_document.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from yoti_python_sdk.doc_scan.constants import ID_DOCUMENT
2+
from yoti_python_sdk.utils import remove_null_values
23
from .document_filter import DocumentFilter # noqa: F401
34
from .required_document import RequiredDocument
45

@@ -20,10 +21,7 @@ def filter(self):
2021
return self.__doc_filter
2122

2223
def to_json(self):
23-
return {"type": self.type, "filter": self.__doc_filter}
24-
25-
def include_null_values(self):
26-
return False
24+
return remove_null_values({"type": self.type, "filter": self.__doc_filter})
2725

2826

2927
class RequiredIdDocumentBuilder(object):

yoti_python_sdk/doc_scan/session/create/notification_config.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from yoti_python_sdk.doc_scan.constants import RESOURCE_UPDATE
66
from yoti_python_sdk.doc_scan.constants import SESSION_COMPLETION
77
from yoti_python_sdk.doc_scan.constants import TASK_COMPLETION
8-
from yoti_python_sdk.utils import YotiSerializable
8+
from yoti_python_sdk.utils import YotiSerializable, remove_null_values
99

1010

1111
class NotificationConfig(YotiSerializable):
@@ -63,14 +63,13 @@ def topics(self):
6363
return self.__topics
6464

6565
def to_json(self):
66-
return {
67-
"auth_token": self.auth_token,
68-
"endpoint": self.endpoint,
69-
"topics": self.topics,
70-
}
71-
72-
def include_null_values(self):
73-
return False
66+
return remove_null_values(
67+
{
68+
"auth_token": self.auth_token,
69+
"endpoint": self.endpoint,
70+
"topics": self.topics,
71+
}
72+
)
7473

7574

7675
class NotificationConfigBuilder(object):

yoti_python_sdk/doc_scan/session/create/sdk_config.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from yoti_python_sdk.doc_scan.constants import CAMERA
55
from yoti_python_sdk.doc_scan.constants import CAMERA_AND_UPLOAD
6-
from yoti_python_sdk.utils import YotiSerializable
6+
from yoti_python_sdk.utils import YotiSerializable, remove_null_values
77

88

99
class SdkConfig(YotiSerializable):
@@ -122,19 +122,18 @@ def error_url(self):
122122
return self.__error_url
123123

124124
def to_json(self):
125-
return {
126-
"allowed_capture_methods": self.allowed_capture_methods,
127-
"primary_colour": self.primary_colour,
128-
"secondary_colour": self.secondary_colour,
129-
"font_colour": self.font_colour,
130-
"locale": self.locale,
131-
"preset_issuing_country": self.preset_issuing_country,
132-
"success_url": self.success_url,
133-
"error_url": self.error_url,
134-
}
135-
136-
def include_null_values(self):
137-
return False
125+
return remove_null_values(
126+
{
127+
"allowed_capture_methods": self.allowed_capture_methods,
128+
"primary_colour": self.primary_colour,
129+
"secondary_colour": self.secondary_colour,
130+
"font_colour": self.font_colour,
131+
"locale": self.locale,
132+
"preset_issuing_country": self.preset_issuing_country,
133+
"success_url": self.success_url,
134+
"error_url": self.error_url,
135+
}
136+
)
138137

139138

140139
class SdkConfigBuilder(object):

0 commit comments

Comments
 (0)