onfido-python 4.5.0__py3-none-any.whl → 5.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. onfido/__init__.py +2 -1
  2. onfido/api/default_api.py +279 -0
  3. onfido/api_client.py +2 -2
  4. onfido/configuration.py +151 -39
  5. onfido/exceptions.py +17 -0
  6. onfido/models/__init__.py +1 -0
  7. onfido/models/applicant_consent_name.py +1 -0
  8. onfido/models/check.py +2 -2
  9. onfido/models/check_response.py +2 -2
  10. onfido/models/check_status.py +1 -0
  11. onfido/models/country_codes.py +1 -0
  12. onfido/models/device_intelligence_breakdown_properties_device.py +10 -10
  13. onfido/models/device_intelligence_report.py +1 -11
  14. onfido/models/document.py +2 -12
  15. onfido/models/document_properties.py +6 -6
  16. onfido/models/document_report.py +3 -3
  17. onfido/models/document_report_shared.py +108 -0
  18. onfido/models/document_shared.py +2 -12
  19. onfido/models/document_types.py +1 -0
  20. onfido/models/document_video_report.py +3 -3
  21. onfido/models/document_video_with_address_information_report.py +3 -3
  22. onfido/models/document_with_address_information_report.py +3 -3
  23. onfido/models/document_with_driver_verification_report.py +3 -3
  24. onfido/models/document_with_driver_verification_report_all_of_properties.py +6 -6
  25. onfido/models/document_with_driving_licence_information_report.py +3 -3
  26. onfido/models/extraction_document_classification.py +2 -2
  27. onfido/models/extraction_extracted_data.py +2 -2
  28. onfido/models/facial_similarity_motion_report.py +3 -3
  29. onfido/models/facial_similarity_photo_fully_auto_report.py +3 -3
  30. onfido/models/facial_similarity_photo_report.py +3 -3
  31. onfido/models/facial_similarity_report_shared.py +11 -1
  32. onfido/models/facial_similarity_video_report.py +3 -3
  33. onfido/models/id_number.py +2 -2
  34. onfido/models/identity_enhanced_report.py +1 -11
  35. onfido/models/india_pan_report.py +1 -11
  36. onfido/models/known_faces_report.py +1 -11
  37. onfido/models/proof_of_address_properties.py +2 -2
  38. onfido/models/proof_of_address_report.py +1 -11
  39. onfido/models/repeat_attempts_list_repeat_attempts_inner.py +6 -6
  40. onfido/models/report_name.py +1 -0
  41. onfido/models/report_result.py +1 -0
  42. onfido/models/report_shared.py +1 -11
  43. onfido/models/report_status.py +1 -0
  44. onfido/models/report_sub_result.py +1 -0
  45. onfido/models/results_feedback.py +2 -2
  46. onfido/models/us_driving_licence_builder.py +6 -6
  47. onfido/models/us_driving_licence_report.py +1 -11
  48. onfido/models/us_driving_licence_shared.py +6 -6
  49. onfido/models/watchlist_aml_properties.py +2 -2
  50. onfido/models/watchlist_aml_report.py +1 -11
  51. onfido/models/watchlist_enhanced_report.py +1 -11
  52. onfido/models/watchlist_monitor.py +2 -2
  53. onfido/models/watchlist_monitor_builder.py +2 -2
  54. onfido/models/watchlist_monitor_shared.py +2 -2
  55. onfido/models/watchlist_peps_only_report.py +1 -11
  56. onfido/models/watchlist_sanctions_only_report.py +1 -11
  57. onfido/models/watchlist_standard_properties.py +2 -2
  58. onfido/models/watchlist_standard_report.py +1 -11
  59. onfido/models/webhook_event_object_status.py +1 -0
  60. onfido/models/webhook_event_payload_object.py +1 -1
  61. onfido/models/webhook_event_payload_resource.py +4 -2
  62. onfido/models/webhook_event_resource_type.py +1 -0
  63. onfido/models/webhook_event_type.py +1 -1
  64. onfido/models/workflow_run_link.py +2 -2
  65. onfido/models/workflow_run_status.py +1 -0
  66. onfido/webhook_event_verifier.py +3 -2
  67. {onfido_python-4.5.0.dist-info → onfido_python-5.0.0.dist-info}/METADATA +10 -2
  68. {onfido_python-4.5.0.dist-info → onfido_python-5.0.0.dist-info}/RECORD +71 -70
  69. {onfido_python-4.5.0.dist-info → onfido_python-5.0.0.dist-info}/WHEEL +1 -1
  70. {onfido_python-4.5.0.dist-info → onfido_python-5.0.0.dist-info}/LICENSE +0 -0
  71. {onfido_python-4.5.0.dist-info → onfido_python-5.0.0.dist-info}/top_level.txt +0 -0
onfido/configuration.py CHANGED
@@ -13,14 +13,15 @@
13
13
 
14
14
 
15
15
  import copy
16
+ import http.client as httplib
16
17
  import logging
17
18
  from logging import FileHandler
18
19
  import multiprocessing
19
20
  import sys
20
- from typing import Optional
21
- import urllib3
21
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict
22
+ from typing_extensions import NotRequired, Self
22
23
 
23
- import http.client as httplib
24
+ import urllib3
24
25
 
25
26
  from enum import Enum
26
27
 
@@ -37,6 +38,107 @@ JSON_SCHEMA_VALIDATION_KEYWORDS = {
37
38
  'minLength', 'pattern', 'maxItems', 'minItems'
38
39
  }
39
40
 
41
+ ServerVariablesT = Dict[str, str]
42
+
43
+ GenericAuthSetting = TypedDict(
44
+ "GenericAuthSetting",
45
+ {
46
+ "type": str,
47
+ "in": str,
48
+ "key": str,
49
+ "value": str,
50
+ },
51
+ )
52
+
53
+
54
+ OAuth2AuthSetting = TypedDict(
55
+ "OAuth2AuthSetting",
56
+ {
57
+ "type": Literal["oauth2"],
58
+ "in": Literal["header"],
59
+ "key": Literal["Authorization"],
60
+ "value": str,
61
+ },
62
+ )
63
+
64
+
65
+ APIKeyAuthSetting = TypedDict(
66
+ "APIKeyAuthSetting",
67
+ {
68
+ "type": Literal["api_key"],
69
+ "in": str,
70
+ "key": str,
71
+ "value": Optional[str],
72
+ },
73
+ )
74
+
75
+
76
+ BasicAuthSetting = TypedDict(
77
+ "BasicAuthSetting",
78
+ {
79
+ "type": Literal["basic"],
80
+ "in": Literal["header"],
81
+ "key": Literal["Authorization"],
82
+ "value": Optional[str],
83
+ },
84
+ )
85
+
86
+
87
+ BearerFormatAuthSetting = TypedDict(
88
+ "BearerFormatAuthSetting",
89
+ {
90
+ "type": Literal["bearer"],
91
+ "in": Literal["header"],
92
+ "format": Literal["JWT"],
93
+ "key": Literal["Authorization"],
94
+ "value": str,
95
+ },
96
+ )
97
+
98
+
99
+ BearerAuthSetting = TypedDict(
100
+ "BearerAuthSetting",
101
+ {
102
+ "type": Literal["bearer"],
103
+ "in": Literal["header"],
104
+ "key": Literal["Authorization"],
105
+ "value": str,
106
+ },
107
+ )
108
+
109
+
110
+ HTTPSignatureAuthSetting = TypedDict(
111
+ "HTTPSignatureAuthSetting",
112
+ {
113
+ "type": Literal["http-signature"],
114
+ "in": Literal["header"],
115
+ "key": Literal["Authorization"],
116
+ "value": None,
117
+ },
118
+ )
119
+
120
+
121
+ AuthSettings = TypedDict(
122
+ "AuthSettings",
123
+ {
124
+ "Token": APIKeyAuthSetting,
125
+ },
126
+ total=False,
127
+ )
128
+
129
+
130
+ class HostSettingVariable(TypedDict):
131
+ description: str
132
+ default_value: str
133
+ enum_values: List[str]
134
+
135
+
136
+ class HostSetting(TypedDict):
137
+ url: str
138
+ description: str
139
+ variables: NotRequired[Dict[str, HostSettingVariable]]
140
+
141
+
40
142
  class Configuration:
41
143
  """This class contains various settings of the API client.
42
144
 
@@ -76,20 +178,23 @@ conf = onfido.Configuration(
76
178
  Cookie: JSESSIONID abc123
77
179
  """
78
180
 
79
- _default = None
80
-
81
- def __init__(self, host=None,
82
- api_token=None,
83
- region=Region.EU,
84
- timeout=None,
85
- server_index=None,
86
- server_operation_index=None, server_operation_variables=None,
87
- ignore_operation_servers=False,
88
- ssl_ca_cert=None,
89
- retries=None,
90
- *,
91
- debug: Optional[bool] = None
92
- ) -> None:
181
+ _default: ClassVar[Optional[Self]] = None
182
+
183
+ def __init__(
184
+ self,
185
+ host: Optional[str]=None,
186
+ api_token: Optional[str]=None,
187
+ region: Optional[Region]=Region.EU,
188
+ timeout: Optional[urllib3.util.Timeout]=None,
189
+ server_index: Optional[int]=None,
190
+ server_operation_index: Optional[Dict[int, int]]=None,
191
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
192
+ ignore_operation_servers: bool=False,
193
+ ssl_ca_cert: Optional[str]=None,
194
+ retries: Optional[int] = None,
195
+ *,
196
+ debug: Optional[bool] = None,
197
+ ) -> None:
93
198
  """Constructor
94
199
  """
95
200
  self._base_path = "https://api.eu.onfido.com/v3.6" if host is None else host
@@ -199,7 +304,7 @@ conf = onfido.Configuration(
199
304
  """date format
200
305
  """
201
306
 
202
- def __deepcopy__(self, memo):
307
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
203
308
  cls = self.__class__
204
309
  result = cls.__new__(cls)
205
310
  memo[id(self)] = result
@@ -213,11 +318,11 @@ conf = onfido.Configuration(
213
318
  result.debug = self.debug
214
319
  return result
215
320
 
216
- def __setattr__(self, name, value):
321
+ def __setattr__(self, name: str, value: Any) -> None:
217
322
  object.__setattr__(self, name, value)
218
323
 
219
324
  @classmethod
220
- def set_default(cls, default):
325
+ def set_default(cls, default: Optional[Self]) -> None:
221
326
  """Set default instance of configuration.
222
327
 
223
328
  It stores default configuration, which can be
@@ -228,7 +333,7 @@ conf = onfido.Configuration(
228
333
  cls._default = default
229
334
 
230
335
  @classmethod
231
- def get_default_copy(cls):
336
+ def get_default_copy(cls) -> Self:
232
337
  """Deprecated. Please use `get_default` instead.
233
338
 
234
339
  Deprecated. Please use `get_default` instead.
@@ -238,7 +343,7 @@ conf = onfido.Configuration(
238
343
  return cls.get_default()
239
344
 
240
345
  @classmethod
241
- def get_default(cls):
346
+ def get_default(cls) -> Self:
242
347
  """Return the default configuration.
243
348
 
244
349
  This method returns newly created, based on default constructor,
@@ -248,11 +353,11 @@ conf = onfido.Configuration(
248
353
  :return: The configuration object.
249
354
  """
250
355
  if cls._default is None:
251
- cls._default = Configuration()
356
+ cls._default = cls()
252
357
  return cls._default
253
358
 
254
359
  @property
255
- def logger_file(self):
360
+ def logger_file(self) -> Optional[str]:
256
361
  """The logger file.
257
362
 
258
363
  If the logger_file is None, then add stream handler and remove file
@@ -264,7 +369,7 @@ conf = onfido.Configuration(
264
369
  return self.__logger_file
265
370
 
266
371
  @logger_file.setter
267
- def logger_file(self, value):
372
+ def logger_file(self, value: Optional[str]) -> None:
268
373
  """The logger file.
269
374
 
270
375
  If the logger_file is None, then add stream handler and remove file
@@ -283,7 +388,7 @@ conf = onfido.Configuration(
283
388
  logger.addHandler(self.logger_file_handler)
284
389
 
285
390
  @property
286
- def debug(self):
391
+ def debug(self) -> bool:
287
392
  """Debug status
288
393
 
289
394
  :param value: The debug status, True or False.
@@ -292,7 +397,7 @@ conf = onfido.Configuration(
292
397
  return self.__debug
293
398
 
294
399
  @debug.setter
295
- def debug(self, value):
400
+ def debug(self, value: bool) -> None:
296
401
  """Debug status
297
402
 
298
403
  :param value: The debug status, True or False.
@@ -314,7 +419,7 @@ conf = onfido.Configuration(
314
419
  httplib.HTTPConnection.debuglevel = 0
315
420
 
316
421
  @property
317
- def logger_format(self):
422
+ def logger_format(self) -> str:
318
423
  """The logger format.
319
424
 
320
425
  The logger_formatter will be updated when sets logger_format.
@@ -325,7 +430,7 @@ conf = onfido.Configuration(
325
430
  return self.__logger_format
326
431
 
327
432
  @logger_format.setter
328
- def logger_format(self, value):
433
+ def logger_format(self, value: str) -> None:
329
434
  """The logger format.
330
435
 
331
436
  The logger_formatter will be updated when sets logger_format.
@@ -336,7 +441,7 @@ conf = onfido.Configuration(
336
441
  self.__logger_format = value
337
442
  self.logger_formatter = logging.Formatter(self.__logger_format)
338
443
 
339
- def get_api_key_with_prefix(self, identifier, alias=None):
444
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
340
445
  """Gets API key (with prefix if set).
341
446
 
342
447
  :param identifier: The identifier of apiKey.
@@ -353,7 +458,9 @@ conf = onfido.Configuration(
353
458
  else:
354
459
  return key
355
460
 
356
- def get_basic_auth_token(self):
461
+ return None
462
+
463
+ def get_basic_auth_token(self) -> Optional[str]:
357
464
  """Gets HTTP basic authentication header (string).
358
465
 
359
466
  :return: The token for basic HTTP authentication.
@@ -368,12 +475,12 @@ conf = onfido.Configuration(
368
475
  basic_auth=username + ':' + password
369
476
  ).get('authorization')
370
477
 
371
- def auth_settings(self):
478
+ def auth_settings(self)-> AuthSettings:
372
479
  """Gets Auth Settings dict for api client.
373
480
 
374
481
  :return: The Auth Settings information dict.
375
482
  """
376
- auth = {}
483
+ auth: AuthSettings = {}
377
484
  if 'Token' in self.api_key:
378
485
  auth['Token'] = {
379
486
  'type': 'api_key',
@@ -385,7 +492,7 @@ conf = onfido.Configuration(
385
492
  }
386
493
  return auth
387
494
 
388
- def to_debug_report(self):
495
+ def to_debug_report(self) -> str:
389
496
  """Gets the essential information for debugging.
390
497
 
391
498
  :return: The report for debugging.
@@ -394,10 +501,10 @@ conf = onfido.Configuration(
394
501
  "OS: {env}\n"\
395
502
  "Python Version: {pyversion}\n"\
396
503
  "Version of the API: v3.6\n"\
397
- "SDK Package Version: 4.5.0".\
504
+ "SDK Package Version: 5.0.0".\
398
505
  format(env=sys.platform, pyversion=sys.version)
399
506
 
400
- def get_host_settings(self):
507
+ def get_host_settings(self) -> List[HostSetting]:
401
508
  """Gets an array of host settings
402
509
 
403
510
  :return: An array of host settings
@@ -420,7 +527,12 @@ conf = onfido.Configuration(
420
527
  }
421
528
  ]
422
529
 
423
- def get_host_from_settings(self, index, variables=None, servers=None):
530
+ def get_host_from_settings(
531
+ self,
532
+ index: Optional[int],
533
+ variables: Optional[ServerVariablesT]=None,
534
+ servers: Optional[List[HostSetting]]=None,
535
+ ) -> str:
424
536
  """Gets host URL based on the index and variables
425
537
  :param index: array index of the host settings
426
538
  :param variables: hash of variable and the corresponding value
@@ -460,12 +572,12 @@ conf = onfido.Configuration(
460
572
  return url
461
573
 
462
574
  @property
463
- def host(self):
575
+ def host(self) -> str:
464
576
  """Return generated host."""
465
577
  return self.get_host_from_settings(self.server_index, variables=self.server_variables)
466
578
 
467
579
  @host.setter
468
- def host(self, value):
580
+ def host(self, value: str) -> None:
469
581
  """Fix base path."""
470
582
  self._base_path = value
471
583
  self.server_index = None
onfido/exceptions.py CHANGED
@@ -150,6 +150,13 @@ class ApiException(OpenApiException):
150
150
  if http_resp.status == 404:
151
151
  raise NotFoundException(http_resp=http_resp, body=body, data=data)
152
152
 
153
+ # Added new conditions for 409 and 422
154
+ if http_resp.status == 409:
155
+ raise ConflictException(http_resp=http_resp, body=body, data=data)
156
+
157
+ if http_resp.status == 422:
158
+ raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
159
+
153
160
  if 500 <= http_resp.status <= 599:
154
161
  raise ServiceException(http_resp=http_resp, body=body, data=data)
155
162
  raise ApiException(http_resp=http_resp, body=body, data=data)
@@ -188,6 +195,16 @@ class ServiceException(ApiException):
188
195
  pass
189
196
 
190
197
 
198
+ class ConflictException(ApiException):
199
+ """Exception for HTTP 409 Conflict."""
200
+ pass
201
+
202
+
203
+ class UnprocessableEntityException(ApiException):
204
+ """Exception for HTTP 422 Unprocessable Entity."""
205
+ pass
206
+
207
+
191
208
  def render_path(path_to_item):
192
209
  """Returns a string representation of a path"""
193
210
  result = ""
onfido/models/__init__.py CHANGED
@@ -96,6 +96,7 @@ from onfido.models.document_properties_driving_licence_information import Docume
96
96
  from onfido.models.document_properties_extracted_data import DocumentPropertiesExtractedData
97
97
  from onfido.models.document_properties_nfc import DocumentPropertiesNfc
98
98
  from onfido.models.document_report import DocumentReport
99
+ from onfido.models.document_report_shared import DocumentReportShared
99
100
  from onfido.models.document_response import DocumentResponse
100
101
  from onfido.models.document_shared import DocumentShared
101
102
  from onfido.models.document_types import DocumentTypes
@@ -29,6 +29,7 @@ class ApplicantConsentName(str, Enum):
29
29
  PRIVACY_NOTICES_READ = 'privacy_notices_read'
30
30
  SSN_VERIFICATION = 'ssn_verification'
31
31
  PHONE_NUMBER_VERIFICATION = 'phone_number_verification'
32
+ UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api'
32
33
 
33
34
  @classmethod
34
35
  def from_json(cls, json_str: str) -> Self:
onfido/models/check.py CHANGED
@@ -54,8 +54,8 @@ class Check(BaseModel):
54
54
  if value is None:
55
55
  return value
56
56
 
57
- if value not in set(['clear', 'consider']):
58
- raise ValueError("must be one of enum values ('clear', 'consider')")
57
+ if value not in set(['clear', 'consider', 'unknown_default_open_api']):
58
+ raise ValueError("must be one of enum values ('clear', 'consider', 'unknown_default_open_api')")
59
59
  return value
60
60
 
61
61
  model_config = ConfigDict(
@@ -47,8 +47,8 @@ class CheckResponse(BaseModel):
47
47
  if value is None:
48
48
  return value
49
49
 
50
- if value not in set(['clear', 'consider']):
51
- raise ValueError("must be one of enum values ('clear', 'consider')")
50
+ if value not in set(['clear', 'consider', 'unknown_default_open_api']):
51
+ raise ValueError("must be one of enum values ('clear', 'consider', 'unknown_default_open_api')")
52
52
  return value
53
53
 
54
54
  model_config = ConfigDict(
@@ -32,6 +32,7 @@ class CheckStatus(str, Enum):
32
32
  WITHDRAWN = 'withdrawn'
33
33
  PAUSED = 'paused'
34
34
  REOPENED = 'reopened'
35
+ UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api'
35
36
 
36
37
  @classmethod
37
38
  def from_json(cls, json_str: str) -> Self:
@@ -276,6 +276,7 @@ class CountryCodes(str, Enum):
276
276
  ZAF = 'ZAF'
277
277
  ZMB = 'ZMB'
278
278
  ZWE = 'ZWE'
279
+ UNKNOWN_DEFAULT_OPEN_API = 'unknown_default_open_api'
279
280
 
280
281
  @classmethod
281
282
  def from_json(cls, json_str: str) -> Self:
@@ -49,8 +49,8 @@ class DeviceIntelligenceBreakdownPropertiesDevice(BaseModel):
49
49
  if value is None:
50
50
  return value
51
51
 
52
- if value not in set(['onfido-android-sdk', 'onfido-ios-sdk', 'onfido-web-sdk']):
53
- raise ValueError("must be one of enum values ('onfido-android-sdk', 'onfido-ios-sdk', 'onfido-web-sdk')")
52
+ if value not in set(['onfido-android-sdk', 'onfido-ios-sdk', 'onfido-web-sdk', 'unknown_default_open_api']):
53
+ raise ValueError("must be one of enum values ('onfido-android-sdk', 'onfido-ios-sdk', 'onfido-web-sdk', 'unknown_default_open_api')")
54
54
  return value
55
55
 
56
56
  @field_validator('authentication_type')
@@ -59,8 +59,8 @@ class DeviceIntelligenceBreakdownPropertiesDevice(BaseModel):
59
59
  if value is None:
60
60
  return value
61
61
 
62
- if value not in set(['sdk_token', 'mobile_token', 'api_token']):
63
- raise ValueError("must be one of enum values ('sdk_token', 'mobile_token', 'api_token')")
62
+ if value not in set(['sdk_token', 'mobile_token', 'api_token', 'unknown_default_open_api']):
63
+ raise ValueError("must be one of enum values ('sdk_token', 'mobile_token', 'api_token', 'unknown_default_open_api')")
64
64
  return value
65
65
 
66
66
  @field_validator('ip_reputation')
@@ -69,8 +69,8 @@ class DeviceIntelligenceBreakdownPropertiesDevice(BaseModel):
69
69
  if value is None:
70
70
  return value
71
71
 
72
- if value not in set(['NOT_ENOUGH_DATA', 'HIGH_RISK', 'LOW_RISK']):
73
- raise ValueError("must be one of enum values ('NOT_ENOUGH_DATA', 'HIGH_RISK', 'LOW_RISK')")
72
+ if value not in set(['NOT_ENOUGH_DATA', 'HIGH_RISK', 'LOW_RISK', 'unknown_default_open_api']):
73
+ raise ValueError("must be one of enum values ('NOT_ENOUGH_DATA', 'HIGH_RISK', 'LOW_RISK', 'unknown_default_open_api')")
74
74
  return value
75
75
 
76
76
  @field_validator('document_capture')
@@ -79,8 +79,8 @@ class DeviceIntelligenceBreakdownPropertiesDevice(BaseModel):
79
79
  if value is None:
80
80
  return value
81
81
 
82
- if value not in set(['live', 'unknown_method']):
83
- raise ValueError("must be one of enum values ('live', 'unknown_method')")
82
+ if value not in set(['live', 'unknown_method', 'unknown_default_open_api']):
83
+ raise ValueError("must be one of enum values ('live', 'unknown_method', 'unknown_default_open_api')")
84
84
  return value
85
85
 
86
86
  @field_validator('biometric_capture')
@@ -89,8 +89,8 @@ class DeviceIntelligenceBreakdownPropertiesDevice(BaseModel):
89
89
  if value is None:
90
90
  return value
91
91
 
92
- if value not in set(['live', 'unknown_method']):
93
- raise ValueError("must be one of enum values ('live', 'unknown_method')")
92
+ if value not in set(['live', 'unknown_method', 'unknown_default_open_api']):
93
+ raise ValueError("must be one of enum values ('live', 'unknown_method', 'unknown_default_open_api')")
94
94
  return value
95
95
 
96
96
  model_config = ConfigDict(
@@ -21,7 +21,6 @@ from datetime import datetime
21
21
  from pydantic import BaseModel, ConfigDict, Field, StrictStr
22
22
  from typing import Any, ClassVar, Dict, List, Optional
23
23
  from onfido.models.device_intelligence_breakdown import DeviceIntelligenceBreakdown
24
- from onfido.models.report_document import ReportDocument
25
24
  from onfido.models.report_name import ReportName
26
25
  from onfido.models.report_result import ReportResult
27
26
  from onfido.models.report_status import ReportStatus
@@ -40,11 +39,10 @@ class DeviceIntelligenceReport(BaseModel):
40
39
  result: Optional[ReportResult] = None
41
40
  sub_result: Optional[ReportSubResult] = None
42
41
  check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.")
43
- documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine. [ONLY POPULATED FOR DOCUMENT AND FACIAL SIMILARITY REPORTS]")
44
42
  name: ReportName
45
43
  breakdown: Optional[DeviceIntelligenceBreakdown] = None
46
44
  additional_properties: Dict[str, Any] = {}
47
- __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown"]
45
+ __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "breakdown"]
48
46
 
49
47
  model_config = ConfigDict(
50
48
  populate_by_name=True,
@@ -87,13 +85,6 @@ class DeviceIntelligenceReport(BaseModel):
87
85
  exclude=excluded_fields,
88
86
  exclude_none=True,
89
87
  )
90
- # override the default output from pydantic by calling `to_dict()` of each item in documents (list)
91
- _items = []
92
- if self.documents:
93
- for _item_documents in self.documents:
94
- if _item_documents:
95
- _items.append(_item_documents.to_dict())
96
- _dict['documents'] = _items
97
88
  # override the default output from pydantic by calling `to_dict()` of breakdown
98
89
  if self.breakdown:
99
90
  _dict['breakdown'] = self.breakdown.to_dict()
@@ -121,7 +112,6 @@ class DeviceIntelligenceReport(BaseModel):
121
112
  "result": obj.get("result"),
122
113
  "sub_result": obj.get("sub_result"),
123
114
  "check_id": obj.get("check_id"),
124
- "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None,
125
115
  "name": obj.get("name"),
126
116
  "breakdown": DeviceIntelligenceBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None
127
117
  })
onfido/models/document.py CHANGED
@@ -43,24 +43,14 @@ class Document(BaseModel):
43
43
  additional_properties: Dict[str, Any] = {}
44
44
  __properties: ClassVar[List[str]] = ["file_type", "type", "side", "issuing_country", "applicant_id", "id", "created_at", "href", "download_href", "file_name", "file_size"]
45
45
 
46
- @field_validator('file_type')
47
- def file_type_validate_enum(cls, value):
48
- """Validates the enum"""
49
- if value is None:
50
- return value
51
-
52
- if value not in set(['jpg', 'jpeg', 'png', 'pdf']):
53
- raise ValueError("must be one of enum values ('jpg', 'jpeg', 'png', 'pdf')")
54
- return value
55
-
56
46
  @field_validator('side')
57
47
  def side_validate_enum(cls, value):
58
48
  """Validates the enum"""
59
49
  if value is None:
60
50
  return value
61
51
 
62
- if value not in set(['front', 'back']):
63
- raise ValueError("must be one of enum values ('front', 'back')")
52
+ if value not in set(['front', 'back', 'unknown_default_open_api']):
53
+ raise ValueError("must be one of enum values ('front', 'back', 'unknown_default_open_api')")
64
54
  return value
65
55
 
66
56
  model_config = ConfigDict(
@@ -88,8 +88,8 @@ class DocumentProperties(BaseModel):
88
88
  if value is None:
89
89
  return value
90
90
 
91
- if value not in set(['superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength']):
92
- raise ValueError("must be one of enum values ('superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength')")
91
+ if value not in set(['superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength', 'unknown_default_open_api']):
92
+ raise ValueError("must be one of enum values ('superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength', 'unknown_default_open_api')")
93
93
  return value
94
94
 
95
95
  @field_validator('has_issuance_confirmation')
@@ -98,8 +98,8 @@ class DocumentProperties(BaseModel):
98
98
  if value is None:
99
99
  return value
100
100
 
101
- if value not in set(['true', 'false', 'unspecified']):
102
- raise ValueError("must be one of enum values ('true', 'false', 'unspecified')")
101
+ if value not in set(['true', 'false', 'unspecified', 'unknown_default_open_api']):
102
+ raise ValueError("must be one of enum values ('true', 'false', 'unspecified', 'unknown_default_open_api')")
103
103
  return value
104
104
 
105
105
  @field_validator('security_tier')
@@ -108,8 +108,8 @@ class DocumentProperties(BaseModel):
108
108
  if value is None:
109
109
  return value
110
110
 
111
- if value not in set(['tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier']):
112
- raise ValueError("must be one of enum values ('tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier')")
111
+ if value not in set(['tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier', 'unknown_default_open_api']):
112
+ raise ValueError("must be one of enum values ('tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier', 'unknown_default_open_api')")
113
113
  return value
114
114
 
115
115
  model_config = ConfigDict(
@@ -41,12 +41,12 @@ class DocumentReport(BaseModel):
41
41
  result: Optional[ReportResult] = None
42
42
  sub_result: Optional[ReportSubResult] = None
43
43
  check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.")
44
- documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine. [ONLY POPULATED FOR DOCUMENT AND FACIAL SIMILARITY REPORTS]")
45
44
  name: ReportName
45
+ documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.")
46
46
  breakdown: Optional[DocumentBreakdown] = None
47
47
  properties: Optional[DocumentProperties] = None
48
48
  additional_properties: Dict[str, Any] = {}
49
- __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"]
49
+ __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "documents", "breakdown", "properties"]
50
50
 
51
51
  model_config = ConfigDict(
52
52
  populate_by_name=True,
@@ -126,8 +126,8 @@ class DocumentReport(BaseModel):
126
126
  "result": obj.get("result"),
127
127
  "sub_result": obj.get("sub_result"),
128
128
  "check_id": obj.get("check_id"),
129
- "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None,
130
129
  "name": obj.get("name"),
130
+ "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None,
131
131
  "breakdown": DocumentBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None,
132
132
  "properties": DocumentProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None
133
133
  })