From 1ea13ca80fbee100006192de7393f29b928bdf3c Mon Sep 17 00:00:00 2001 From: dvacca-onfido <134616519+dvacca-onfido@users.noreply.github.com> Date: Tue, 18 Feb 2025 09:26:23 +0000 Subject: [PATCH] Upgrade after onfido-openapi-spec change 0eec622 --- .release.json | 8 +- onfido/__init__.py | 3 +- onfido/api/default_api.py | 279 ++++++++++++++++++ onfido/api_client.py | 2 +- onfido/configuration.py | 2 +- onfido/models/__init__.py | 1 + onfido/models/device_intelligence_report.py | 12 +- onfido/models/document.py | 10 - onfido/models/document_report.py | 6 +- onfido/models/document_report_shared.py | 108 +++++++ onfido/models/document_shared.py | 10 - onfido/models/document_video_report.py | 6 +- ...t_video_with_address_information_report.py | 6 +- ...ocument_with_address_information_report.py | 6 +- ...ocument_with_driver_verification_report.py | 6 +- ...with_driving_licence_information_report.py | 6 +- .../models/facial_similarity_motion_report.py | 6 +- ...cial_similarity_photo_fully_auto_report.py | 6 +- .../models/facial_similarity_photo_report.py | 6 +- .../models/facial_similarity_report_shared.py | 12 +- .../models/facial_similarity_video_report.py | 6 +- onfido/models/identity_enhanced_report.py | 12 +- onfido/models/india_pan_report.py | 12 +- onfido/models/known_faces_report.py | 12 +- onfido/models/proof_of_address_report.py | 12 +- onfido/models/report_shared.py | 12 +- onfido/models/us_driving_licence_report.py | 12 +- onfido/models/watchlist_aml_properties.py | 4 +- onfido/models/watchlist_aml_report.py | 12 +- onfido/models/watchlist_enhanced_report.py | 12 +- onfido/models/watchlist_peps_only_report.py | 12 +- .../models/watchlist_sanctions_only_report.py | 12 +- .../models/watchlist_standard_properties.py | 4 +- onfido/models/watchlist_standard_report.py | 12 +- onfido/models/webhook_event_payload_object.py | 2 +- onfido/models/webhook_event_type.py | 1 - onfido/webhook_event_verifier.py | 5 +- poetry.lock | 12 +- pyproject.toml | 2 +- setup.py | 2 +- 40 files changed, 465 insertions(+), 206 deletions(-) create mode 100644 onfido/models/document_report_shared.py diff --git a/.release.json b/.release.json index df80558..cf84c29 100644 --- a/.release.json +++ b/.release.json @@ -1,9 +1,9 @@ { "source": { "repo_url": "https://github.com/onfido/onfido-openapi-spec", - "short_sha": "be823e7", - "long_sha": "be823e7815c93bfbfc3fb764c0548f57cb851fe9", - "version": "v4.6.0" + "short_sha": "0eec622", + "long_sha": "0eec6225e66b9f905dac23fe4eb18a1584517f64", + "version": "" }, - "release": "v4.6.0" + "release": "v5.0.0" } diff --git a/onfido/__init__.py b/onfido/__init__.py index 7c59a67..aa031b1 100644 --- a/onfido/__init__.py +++ b/onfido/__init__.py @@ -14,7 +14,7 @@ """ # noqa: E501 -__version__ = "4.6.0" +__version__ = "5.0.0" # import apis into sdk package from onfido.api.default_api import DefaultApi @@ -113,6 +113,7 @@ from onfido.models.document_properties_extracted_data import DocumentPropertiesExtractedData from onfido.models.document_properties_nfc import DocumentPropertiesNfc from onfido.models.document_report import DocumentReport +from onfido.models.document_report_shared import DocumentReportShared from onfido.models.document_response import DocumentResponse from onfido.models.document_shared import DocumentShared from onfido.models.document_types import DocumentTypes diff --git a/onfido/api/default_api.py b/onfido/api/default_api.py index c138246..46011a2 100644 --- a/onfido/api/default_api.py +++ b/onfido/api/default_api.py @@ -5684,6 +5684,268 @@ def _download_motion_capture_frame_serialize( + @validate_call + def download_nfc_face( + self, + document_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> bytearray: + """Download NFC face + + Downloads digital photos extracted from specific documents belonging to an applicant. If successful, the response will be the binary data representing the image. + + :param document_id: (required) + :type document_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._download_nfc_face_serialize( + document_id=document_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "bytearray", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def download_nfc_face_with_http_info( + self, + document_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[bytearray]: + """Download NFC face + + Downloads digital photos extracted from specific documents belonging to an applicant. If successful, the response will be the binary data representing the image. + + :param document_id: (required) + :type document_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._download_nfc_face_serialize( + document_id=document_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "bytearray", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def download_nfc_face_without_preload_content( + self, + document_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Download NFC face + + Downloads digital photos extracted from specific documents belonging to an applicant. If successful, the response will be the binary data representing the image. + + :param document_id: (required) + :type document_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._download_nfc_face_serialize( + document_id=document_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "bytearray", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _download_nfc_face_serialize( + self, + document_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if document_id is not None: + _path_params['document_id'] = document_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*', + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'Token' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/documents/{document_id}/nfc_face', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def download_qes_document( self, @@ -14187,6 +14449,7 @@ def list_workflow_runs( created_at_gt: Annotated[Optional[datetime], Field(description="A ISO-8601 date to filter results with a created date greater than (after) the one provided.")] = None, created_at_lt: Annotated[Optional[datetime], Field(description="A ISO-8601 date to filter results with a created date less than (before) the one provided.")] = None, sort: Annotated[Optional[StrictStr], Field(description="A string with the value 'desc' or 'asc' that allows to sort the returned list by the completed datetime either descending or ascending, respectively. If not specified, defaults to 'desc'.")] = None, + applicant_id: Annotated[Optional[StrictStr], Field(description="the applicant's id.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -14214,6 +14477,8 @@ def list_workflow_runs( :type created_at_lt: datetime :param sort: A string with the value 'desc' or 'asc' that allows to sort the returned list by the completed datetime either descending or ascending, respectively. If not specified, defaults to 'desc'. :type sort: str + :param applicant_id: the applicant's id. + :type applicant_id: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -14242,6 +14507,7 @@ def list_workflow_runs( created_at_gt=created_at_gt, created_at_lt=created_at_lt, sort=sort, + applicant_id=applicant_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -14270,6 +14536,7 @@ def list_workflow_runs_with_http_info( created_at_gt: Annotated[Optional[datetime], Field(description="A ISO-8601 date to filter results with a created date greater than (after) the one provided.")] = None, created_at_lt: Annotated[Optional[datetime], Field(description="A ISO-8601 date to filter results with a created date less than (before) the one provided.")] = None, sort: Annotated[Optional[StrictStr], Field(description="A string with the value 'desc' or 'asc' that allows to sort the returned list by the completed datetime either descending or ascending, respectively. If not specified, defaults to 'desc'.")] = None, + applicant_id: Annotated[Optional[StrictStr], Field(description="the applicant's id.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -14297,6 +14564,8 @@ def list_workflow_runs_with_http_info( :type created_at_lt: datetime :param sort: A string with the value 'desc' or 'asc' that allows to sort the returned list by the completed datetime either descending or ascending, respectively. If not specified, defaults to 'desc'. :type sort: str + :param applicant_id: the applicant's id. + :type applicant_id: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -14325,6 +14594,7 @@ def list_workflow_runs_with_http_info( created_at_gt=created_at_gt, created_at_lt=created_at_lt, sort=sort, + applicant_id=applicant_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -14353,6 +14623,7 @@ def list_workflow_runs_without_preload_content( created_at_gt: Annotated[Optional[datetime], Field(description="A ISO-8601 date to filter results with a created date greater than (after) the one provided.")] = None, created_at_lt: Annotated[Optional[datetime], Field(description="A ISO-8601 date to filter results with a created date less than (before) the one provided.")] = None, sort: Annotated[Optional[StrictStr], Field(description="A string with the value 'desc' or 'asc' that allows to sort the returned list by the completed datetime either descending or ascending, respectively. If not specified, defaults to 'desc'.")] = None, + applicant_id: Annotated[Optional[StrictStr], Field(description="the applicant's id.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -14380,6 +14651,8 @@ def list_workflow_runs_without_preload_content( :type created_at_lt: datetime :param sort: A string with the value 'desc' or 'asc' that allows to sort the returned list by the completed datetime either descending or ascending, respectively. If not specified, defaults to 'desc'. :type sort: str + :param applicant_id: the applicant's id. + :type applicant_id: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -14408,6 +14681,7 @@ def list_workflow_runs_without_preload_content( created_at_gt=created_at_gt, created_at_lt=created_at_lt, sort=sort, + applicant_id=applicant_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -14431,6 +14705,7 @@ def _list_workflow_runs_serialize( created_at_gt, created_at_lt, sort, + applicant_id, _request_auth, _content_type, _headers, @@ -14491,6 +14766,10 @@ def _list_workflow_runs_serialize( _query_params.append(('sort', sort)) + if applicant_id is not None: + + _query_params.append(('applicant_id', applicant_id)) + # process the header parameters # process the form parameters # process the body parameter diff --git a/onfido/api_client.py b/onfido/api_client.py index 6ae005d..18c1452 100644 --- a/onfido/api_client.py +++ b/onfido/api_client.py @@ -90,7 +90,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'onfido-python/4.6.0' + self.user_agent = 'onfido-python/5.0.0' self.client_side_validation = configuration.client_side_validation def __enter__(self): diff --git a/onfido/configuration.py b/onfido/configuration.py index 0a3a9c8..521b974 100644 --- a/onfido/configuration.py +++ b/onfido/configuration.py @@ -394,7 +394,7 @@ def to_debug_report(self): "OS: {env}\n"\ "Python Version: {pyversion}\n"\ "Version of the API: v3.6\n"\ - "SDK Package Version: 4.6.0".\ + "SDK Package Version: 5.0.0".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self): diff --git a/onfido/models/__init__.py b/onfido/models/__init__.py index 263d015..6f0a409 100644 --- a/onfido/models/__init__.py +++ b/onfido/models/__init__.py @@ -96,6 +96,7 @@ from onfido.models.document_properties_extracted_data import DocumentPropertiesExtractedData from onfido.models.document_properties_nfc import DocumentPropertiesNfc from onfido.models.document_report import DocumentReport +from onfido.models.document_report_shared import DocumentReportShared from onfido.models.document_response import DocumentResponse from onfido.models.document_shared import DocumentShared from onfido.models.document_types import DocumentTypes diff --git a/onfido/models/device_intelligence_report.py b/onfido/models/device_intelligence_report.py index 33ee0f7..edbbfcb 100644 --- a/onfido/models/device_intelligence_report.py +++ b/onfido/models/device_intelligence_report.py @@ -21,7 +21,6 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from onfido.models.device_intelligence_breakdown import DeviceIntelligenceBreakdown -from onfido.models.report_document import ReportDocument from onfido.models.report_name import ReportName from onfido.models.report_result import ReportResult from onfido.models.report_status import ReportStatus @@ -40,11 +39,10 @@ class DeviceIntelligenceReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName breakdown: Optional[DeviceIntelligenceBreakdown] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "breakdown"] model_config = ConfigDict( populate_by_name=True, @@ -87,13 +85,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in documents (list) - _items = [] - if self.documents: - for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) - _dict['documents'] = _items # override the default output from pydantic by calling `to_dict()` of breakdown if self.breakdown: _dict['breakdown'] = self.breakdown.to_dict() @@ -121,7 +112,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), "breakdown": DeviceIntelligenceBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None }) diff --git a/onfido/models/document.py b/onfido/models/document.py index 5672e5f..c808484 100644 --- a/onfido/models/document.py +++ b/onfido/models/document.py @@ -43,16 +43,6 @@ class Document(BaseModel): additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["file_type", "type", "side", "issuing_country", "applicant_id", "id", "created_at", "href", "download_href", "file_name", "file_size"] - @field_validator('file_type') - def file_type_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['jpg', 'jpeg', 'png', 'pdf']): - raise ValueError("must be one of enum values ('jpg', 'jpeg', 'png', 'pdf')") - return value - @field_validator('side') def side_validate_enum(cls, value): """Validates the enum""" diff --git a/onfido/models/document_report.py b/onfido/models/document_report.py index 9a48d7a..3a1a758 100644 --- a/onfido/models/document_report.py +++ b/onfido/models/document_report.py @@ -41,12 +41,12 @@ class DocumentReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName + documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.") breakdown: Optional[DocumentBreakdown] = None properties: Optional[DocumentProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "documents", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -126,8 +126,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), + "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "breakdown": DocumentBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": DocumentProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None }) diff --git a/onfido/models/document_report_shared.py b/onfido/models/document_report_shared.py new file mode 100644 index 0000000..b948e8e --- /dev/null +++ b/onfido/models/document_report_shared.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" + Onfido API v3.6 + + The Onfido API (v3.6) + + The version of the OpenAPI document: v3.6 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from onfido.models.report_document import ReportDocument +from typing import Optional, Set +from typing_extensions import Self + +class DocumentReportShared(BaseModel): + """ + DocumentReportShared + """ # noqa: E501 + documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["documents"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of DocumentReportShared from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in documents (list) + _items = [] + if self.documents: + for _item_documents in self.documents: + if _item_documents: + _items.append(_item_documents.to_dict()) + _dict['documents'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of DocumentReportShared from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/onfido/models/document_shared.py b/onfido/models/document_shared.py index f7e1051..834ed38 100644 --- a/onfido/models/document_shared.py +++ b/onfido/models/document_shared.py @@ -36,16 +36,6 @@ class DocumentShared(BaseModel): additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["file_type", "type", "side", "issuing_country", "applicant_id"] - @field_validator('file_type') - def file_type_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['jpg', 'jpeg', 'png', 'pdf']): - raise ValueError("must be one of enum values ('jpg', 'jpeg', 'png', 'pdf')") - return value - @field_validator('side') def side_validate_enum(cls, value): """Validates the enum""" diff --git a/onfido/models/document_video_report.py b/onfido/models/document_video_report.py index df7e15b..24137b5 100644 --- a/onfido/models/document_video_report.py +++ b/onfido/models/document_video_report.py @@ -41,12 +41,12 @@ class DocumentVideoReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName + documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.") breakdown: Optional[DocumentBreakdown] = None properties: Optional[DocumentProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "documents", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -126,8 +126,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), + "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "breakdown": DocumentBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": DocumentProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None }) diff --git a/onfido/models/document_video_with_address_information_report.py b/onfido/models/document_video_with_address_information_report.py index 67e2106..5c8d71e 100644 --- a/onfido/models/document_video_with_address_information_report.py +++ b/onfido/models/document_video_with_address_information_report.py @@ -41,12 +41,12 @@ class DocumentVideoWithAddressInformationReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName + documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.") breakdown: Optional[DocumentBreakdown] = None properties: Optional[DocumentProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "documents", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -126,8 +126,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), + "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "breakdown": DocumentBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": DocumentProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None }) diff --git a/onfido/models/document_with_address_information_report.py b/onfido/models/document_with_address_information_report.py index 752b840..f5bcf01 100644 --- a/onfido/models/document_with_address_information_report.py +++ b/onfido/models/document_with_address_information_report.py @@ -41,12 +41,12 @@ class DocumentWithAddressInformationReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName + documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.") breakdown: Optional[DocumentBreakdown] = None properties: Optional[DocumentProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "documents", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -126,8 +126,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), + "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "breakdown": DocumentBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": DocumentProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None }) diff --git a/onfido/models/document_with_driver_verification_report.py b/onfido/models/document_with_driver_verification_report.py index c8a9968..6b560bf 100644 --- a/onfido/models/document_with_driver_verification_report.py +++ b/onfido/models/document_with_driver_verification_report.py @@ -41,12 +41,12 @@ class DocumentWithDriverVerificationReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName + documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.") breakdown: Optional[DocumentBreakdown] = None properties: Optional[DocumentWithDriverVerificationReportAllOfProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "documents", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -126,8 +126,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), + "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "breakdown": DocumentBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": DocumentWithDriverVerificationReportAllOfProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None }) diff --git a/onfido/models/document_with_driving_licence_information_report.py b/onfido/models/document_with_driving_licence_information_report.py index 9c8d3c2..5bd6f3f 100644 --- a/onfido/models/document_with_driving_licence_information_report.py +++ b/onfido/models/document_with_driving_licence_information_report.py @@ -41,12 +41,12 @@ class DocumentWithDrivingLicenceInformationReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName + documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.") breakdown: Optional[DocumentBreakdown] = None properties: Optional[DocumentProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "documents", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -126,8 +126,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), + "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "breakdown": DocumentBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": DocumentProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None }) diff --git a/onfido/models/facial_similarity_motion_report.py b/onfido/models/facial_similarity_motion_report.py index 1a3d908..671f187 100644 --- a/onfido/models/facial_similarity_motion_report.py +++ b/onfido/models/facial_similarity_motion_report.py @@ -42,8 +42,8 @@ class FacialSimilarityMotionReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName + documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.") live_photos: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with live photo ids that were used in the Onfido engine.") live_videos: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with live video ids that were used in the Onfido engine.") motion_captures: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with motion capture ids that were used in the Onfido engine.") @@ -51,7 +51,7 @@ class FacialSimilarityMotionReport(BaseModel): breakdown: Optional[FacialSimilarityMotionBreakdown] = None properties: Optional[FacialSimilarityMotionProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "live_photos", "live_videos", "motion_captures", "id_photos", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "documents", "live_photos", "live_videos", "motion_captures", "id_photos", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -159,8 +159,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), + "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "live_photos": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["live_photos"]] if obj.get("live_photos") is not None else None, "live_videos": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["live_videos"]] if obj.get("live_videos") is not None else None, "motion_captures": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["motion_captures"]] if obj.get("motion_captures") is not None else None, diff --git a/onfido/models/facial_similarity_photo_fully_auto_report.py b/onfido/models/facial_similarity_photo_fully_auto_report.py index 3d481b0..e19c6d6 100644 --- a/onfido/models/facial_similarity_photo_fully_auto_report.py +++ b/onfido/models/facial_similarity_photo_fully_auto_report.py @@ -42,8 +42,8 @@ class FacialSimilarityPhotoFullyAutoReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName + documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.") live_photos: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with live photo ids that were used in the Onfido engine.") live_videos: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with live video ids that were used in the Onfido engine.") motion_captures: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with motion capture ids that were used in the Onfido engine.") @@ -51,7 +51,7 @@ class FacialSimilarityPhotoFullyAutoReport(BaseModel): breakdown: Optional[FacialSimilarityPhotoFullyAutoBreakdown] = None properties: Optional[FacialSimilarityPhotoFullyAutoProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "live_photos", "live_videos", "motion_captures", "id_photos", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "documents", "live_photos", "live_videos", "motion_captures", "id_photos", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -159,8 +159,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), + "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "live_photos": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["live_photos"]] if obj.get("live_photos") is not None else None, "live_videos": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["live_videos"]] if obj.get("live_videos") is not None else None, "motion_captures": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["motion_captures"]] if obj.get("motion_captures") is not None else None, diff --git a/onfido/models/facial_similarity_photo_report.py b/onfido/models/facial_similarity_photo_report.py index 1e798c9..f58c8d2 100644 --- a/onfido/models/facial_similarity_photo_report.py +++ b/onfido/models/facial_similarity_photo_report.py @@ -42,8 +42,8 @@ class FacialSimilarityPhotoReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName + documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.") live_photos: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with live photo ids that were used in the Onfido engine.") live_videos: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with live video ids that were used in the Onfido engine.") motion_captures: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with motion capture ids that were used in the Onfido engine.") @@ -51,7 +51,7 @@ class FacialSimilarityPhotoReport(BaseModel): breakdown: Optional[FacialSimilarityPhotoBreakdown] = None properties: Optional[FacialSimilarityPhotoProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "live_photos", "live_videos", "motion_captures", "id_photos", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "documents", "live_photos", "live_videos", "motion_captures", "id_photos", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -159,8 +159,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), + "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "live_photos": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["live_photos"]] if obj.get("live_photos") is not None else None, "live_videos": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["live_videos"]] if obj.get("live_videos") is not None else None, "motion_captures": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["motion_captures"]] if obj.get("motion_captures") is not None else None, diff --git a/onfido/models/facial_similarity_report_shared.py b/onfido/models/facial_similarity_report_shared.py index 61b60f2..5b78762 100644 --- a/onfido/models/facial_similarity_report_shared.py +++ b/onfido/models/facial_similarity_report_shared.py @@ -20,6 +20,7 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from onfido.models.facial_similarity_report_media import FacialSimilarityReportMedia +from onfido.models.report_document import ReportDocument from typing import Optional, Set from typing_extensions import Self @@ -27,12 +28,13 @@ class FacialSimilarityReportShared(BaseModel): """ FacialSimilarityReportShared """ # noqa: E501 + documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.") live_photos: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with live photo ids that were used in the Onfido engine.") live_videos: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with live video ids that were used in the Onfido engine.") motion_captures: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with motion capture ids that were used in the Onfido engine.") id_photos: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with id photo ids that were used in the Onfido engine.") additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["live_photos", "live_videos", "motion_captures", "id_photos"] + __properties: ClassVar[List[str]] = ["documents", "live_photos", "live_videos", "motion_captures", "id_photos"] model_config = ConfigDict( populate_by_name=True, @@ -75,6 +77,13 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of each item in documents (list) + _items = [] + if self.documents: + for _item_documents in self.documents: + if _item_documents: + _items.append(_item_documents.to_dict()) + _dict['documents'] = _items # override the default output from pydantic by calling `to_dict()` of each item in live_photos (list) _items = [] if self.live_photos: @@ -120,6 +129,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) _obj = cls.model_validate({ + "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "live_photos": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["live_photos"]] if obj.get("live_photos") is not None else None, "live_videos": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["live_videos"]] if obj.get("live_videos") is not None else None, "motion_captures": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["motion_captures"]] if obj.get("motion_captures") is not None else None, diff --git a/onfido/models/facial_similarity_video_report.py b/onfido/models/facial_similarity_video_report.py index f24747b..70e0200 100644 --- a/onfido/models/facial_similarity_video_report.py +++ b/onfido/models/facial_similarity_video_report.py @@ -42,8 +42,8 @@ class FacialSimilarityVideoReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName + documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.") live_photos: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with live photo ids that were used in the Onfido engine.") live_videos: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with live video ids that were used in the Onfido engine.") motion_captures: Optional[List[FacialSimilarityReportMedia]] = Field(default=None, description="Array of objects with motion capture ids that were used in the Onfido engine.") @@ -51,7 +51,7 @@ class FacialSimilarityVideoReport(BaseModel): breakdown: Optional[FacialSimilarityVideoBreakdown] = None properties: Optional[FacialSimilarityVideoProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "live_photos", "live_videos", "motion_captures", "id_photos", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "documents", "live_photos", "live_videos", "motion_captures", "id_photos", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -159,8 +159,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), + "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "live_photos": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["live_photos"]] if obj.get("live_photos") is not None else None, "live_videos": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["live_videos"]] if obj.get("live_videos") is not None else None, "motion_captures": [FacialSimilarityReportMedia.from_dict(_item) for _item in obj["motion_captures"]] if obj.get("motion_captures") is not None else None, diff --git a/onfido/models/identity_enhanced_report.py b/onfido/models/identity_enhanced_report.py index ec446d9..7fb778d 100644 --- a/onfido/models/identity_enhanced_report.py +++ b/onfido/models/identity_enhanced_report.py @@ -22,7 +22,6 @@ from typing import Any, ClassVar, Dict, List, Optional from onfido.models.identity_enhanced_breakdown import IdentityEnhancedBreakdown from onfido.models.identity_enhanced_properties import IdentityEnhancedProperties -from onfido.models.report_document import ReportDocument from onfido.models.report_name import ReportName from onfido.models.report_result import ReportResult from onfido.models.report_status import ReportStatus @@ -41,12 +40,11 @@ class IdentityEnhancedReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName breakdown: Optional[IdentityEnhancedBreakdown] = None properties: Optional[IdentityEnhancedProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -89,13 +87,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in documents (list) - _items = [] - if self.documents: - for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) - _dict['documents'] = _items # override the default output from pydantic by calling `to_dict()` of breakdown if self.breakdown: _dict['breakdown'] = self.breakdown.to_dict() @@ -126,7 +117,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), "breakdown": IdentityEnhancedBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": IdentityEnhancedProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None diff --git a/onfido/models/india_pan_report.py b/onfido/models/india_pan_report.py index c74fdd8..dadabab 100644 --- a/onfido/models/india_pan_report.py +++ b/onfido/models/india_pan_report.py @@ -22,7 +22,6 @@ from typing import Any, ClassVar, Dict, List, Optional from onfido.models.india_pan_report_all_of_breakdown import IndiaPanReportAllOfBreakdown from onfido.models.india_pan_report_all_of_properties import IndiaPanReportAllOfProperties -from onfido.models.report_document import ReportDocument from onfido.models.report_name import ReportName from onfido.models.report_result import ReportResult from onfido.models.report_status import ReportStatus @@ -41,12 +40,11 @@ class IndiaPanReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName breakdown: Optional[IndiaPanReportAllOfBreakdown] = None properties: Optional[IndiaPanReportAllOfProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -89,13 +87,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in documents (list) - _items = [] - if self.documents: - for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) - _dict['documents'] = _items # override the default output from pydantic by calling `to_dict()` of breakdown if self.breakdown: _dict['breakdown'] = self.breakdown.to_dict() @@ -126,7 +117,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), "breakdown": IndiaPanReportAllOfBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": IndiaPanReportAllOfProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None diff --git a/onfido/models/known_faces_report.py b/onfido/models/known_faces_report.py index 17a3124..b72d388 100644 --- a/onfido/models/known_faces_report.py +++ b/onfido/models/known_faces_report.py @@ -22,7 +22,6 @@ from typing import Any, ClassVar, Dict, List, Optional from onfido.models.known_faces_breakdown import KnownFacesBreakdown from onfido.models.known_faces_properties import KnownFacesProperties -from onfido.models.report_document import ReportDocument from onfido.models.report_name import ReportName from onfido.models.report_result import ReportResult from onfido.models.report_status import ReportStatus @@ -41,12 +40,11 @@ class KnownFacesReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName breakdown: Optional[KnownFacesBreakdown] = None properties: Optional[KnownFacesProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -89,13 +87,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in documents (list) - _items = [] - if self.documents: - for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) - _dict['documents'] = _items # override the default output from pydantic by calling `to_dict()` of breakdown if self.breakdown: _dict['breakdown'] = self.breakdown.to_dict() @@ -126,7 +117,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), "breakdown": KnownFacesBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": KnownFacesProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None diff --git a/onfido/models/proof_of_address_report.py b/onfido/models/proof_of_address_report.py index 03490e8..96397ae 100644 --- a/onfido/models/proof_of_address_report.py +++ b/onfido/models/proof_of_address_report.py @@ -22,7 +22,6 @@ from typing import Any, ClassVar, Dict, List, Optional from onfido.models.proof_of_address_breakdown import ProofOfAddressBreakdown from onfido.models.proof_of_address_properties import ProofOfAddressProperties -from onfido.models.report_document import ReportDocument from onfido.models.report_name import ReportName from onfido.models.report_result import ReportResult from onfido.models.report_status import ReportStatus @@ -41,12 +40,11 @@ class ProofOfAddressReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName breakdown: Optional[ProofOfAddressBreakdown] = None properties: Optional[ProofOfAddressProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -89,13 +87,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in documents (list) - _items = [] - if self.documents: - for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) - _dict['documents'] = _items # override the default output from pydantic by calling `to_dict()` of breakdown if self.breakdown: _dict['breakdown'] = self.breakdown.to_dict() @@ -126,7 +117,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), "breakdown": ProofOfAddressBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": ProofOfAddressProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None diff --git a/onfido/models/report_shared.py b/onfido/models/report_shared.py index 1dcd1b4..e6a8d2c 100644 --- a/onfido/models/report_shared.py +++ b/onfido/models/report_shared.py @@ -20,7 +20,6 @@ from datetime import datetime from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -from onfido.models.report_document import ReportDocument from onfido.models.report_name import ReportName from onfido.models.report_result import ReportResult from onfido.models.report_status import ReportStatus @@ -39,10 +38,9 @@ class ReportShared(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name"] model_config = ConfigDict( populate_by_name=True, @@ -85,13 +83,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in documents (list) - _items = [] - if self.documents: - for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) - _dict['documents'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: for _key, _value in self.additional_properties.items(): @@ -116,7 +107,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name") }) # store additional fields in additional_properties diff --git a/onfido/models/us_driving_licence_report.py b/onfido/models/us_driving_licence_report.py index 0a7bf93..5a420dc 100644 --- a/onfido/models/us_driving_licence_report.py +++ b/onfido/models/us_driving_licence_report.py @@ -21,7 +21,6 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from onfido.models.document_properties import DocumentProperties -from onfido.models.report_document import ReportDocument from onfido.models.report_name import ReportName from onfido.models.report_result import ReportResult from onfido.models.report_status import ReportStatus @@ -41,12 +40,11 @@ class UsDrivingLicenceReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName breakdown: Optional[UsDrivingLicenceBreakdown] = None properties: Optional[DocumentProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -89,13 +87,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in documents (list) - _items = [] - if self.documents: - for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) - _dict['documents'] = _items # override the default output from pydantic by calling `to_dict()` of breakdown if self.breakdown: _dict['breakdown'] = self.breakdown.to_dict() @@ -126,7 +117,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), "breakdown": UsDrivingLicenceBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": DocumentProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None diff --git a/onfido/models/watchlist_aml_properties.py b/onfido/models/watchlist_aml_properties.py index 8852d47..15ea20b 100644 --- a/onfido/models/watchlist_aml_properties.py +++ b/onfido/models/watchlist_aml_properties.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set from typing_extensions import Self @@ -26,7 +26,7 @@ class WatchlistAmlProperties(BaseModel): """ WatchlistAmlProperties """ # noqa: E501 - records: Optional[List[StrictStr]] = Field(default=None, description="Returns any matches including, but not limited to, name and date of birth of match, aliases and associates, and relevant events and sources.") + records: Optional[List[Dict[str, Any]]] = Field(default=None, description="Returns any matches including, but not limited to, name and date of birth of match, aliases and associates, and relevant events and sources.") additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["records"] diff --git a/onfido/models/watchlist_aml_report.py b/onfido/models/watchlist_aml_report.py index e16eba6..d5afe9b 100644 --- a/onfido/models/watchlist_aml_report.py +++ b/onfido/models/watchlist_aml_report.py @@ -20,7 +20,6 @@ from datetime import datetime from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -from onfido.models.report_document import ReportDocument from onfido.models.report_name import ReportName from onfido.models.report_result import ReportResult from onfido.models.report_status import ReportStatus @@ -41,12 +40,11 @@ class WatchlistAmlReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName breakdown: Optional[WatchlistAmlBreakdown] = None properties: Optional[WatchlistAmlProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -89,13 +87,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in documents (list) - _items = [] - if self.documents: - for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) - _dict['documents'] = _items # override the default output from pydantic by calling `to_dict()` of breakdown if self.breakdown: _dict['breakdown'] = self.breakdown.to_dict() @@ -126,7 +117,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), "breakdown": WatchlistAmlBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": WatchlistAmlProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None diff --git a/onfido/models/watchlist_enhanced_report.py b/onfido/models/watchlist_enhanced_report.py index dceca86..4ecdc6a 100644 --- a/onfido/models/watchlist_enhanced_report.py +++ b/onfido/models/watchlist_enhanced_report.py @@ -20,7 +20,6 @@ from datetime import datetime from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -from onfido.models.report_document import ReportDocument from onfido.models.report_name import ReportName from onfido.models.report_result import ReportResult from onfido.models.report_status import ReportStatus @@ -41,12 +40,11 @@ class WatchlistEnhancedReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName breakdown: Optional[WatchlistEnhancedBreakdown] = None properties: Optional[WatchlistEnhancedProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -89,13 +87,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in documents (list) - _items = [] - if self.documents: - for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) - _dict['documents'] = _items # override the default output from pydantic by calling `to_dict()` of breakdown if self.breakdown: _dict['breakdown'] = self.breakdown.to_dict() @@ -126,7 +117,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), "breakdown": WatchlistEnhancedBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": WatchlistEnhancedProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None diff --git a/onfido/models/watchlist_peps_only_report.py b/onfido/models/watchlist_peps_only_report.py index cd98d50..03f661a 100644 --- a/onfido/models/watchlist_peps_only_report.py +++ b/onfido/models/watchlist_peps_only_report.py @@ -20,7 +20,6 @@ from datetime import datetime from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -from onfido.models.report_document import ReportDocument from onfido.models.report_name import ReportName from onfido.models.report_result import ReportResult from onfido.models.report_status import ReportStatus @@ -41,12 +40,11 @@ class WatchlistPepsOnlyReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName breakdown: Optional[WatchlistStandardBreakdown] = None properties: Optional[WatchlistStandardProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -89,13 +87,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in documents (list) - _items = [] - if self.documents: - for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) - _dict['documents'] = _items # override the default output from pydantic by calling `to_dict()` of breakdown if self.breakdown: _dict['breakdown'] = self.breakdown.to_dict() @@ -126,7 +117,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), "breakdown": WatchlistStandardBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": WatchlistStandardProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None diff --git a/onfido/models/watchlist_sanctions_only_report.py b/onfido/models/watchlist_sanctions_only_report.py index 52d3bae..b10e510 100644 --- a/onfido/models/watchlist_sanctions_only_report.py +++ b/onfido/models/watchlist_sanctions_only_report.py @@ -20,7 +20,6 @@ from datetime import datetime from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -from onfido.models.report_document import ReportDocument from onfido.models.report_name import ReportName from onfido.models.report_result import ReportResult from onfido.models.report_status import ReportStatus @@ -41,12 +40,11 @@ class WatchlistSanctionsOnlyReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName breakdown: Optional[WatchlistStandardBreakdown] = None properties: Optional[WatchlistStandardProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -89,13 +87,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in documents (list) - _items = [] - if self.documents: - for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) - _dict['documents'] = _items # override the default output from pydantic by calling `to_dict()` of breakdown if self.breakdown: _dict['breakdown'] = self.breakdown.to_dict() @@ -126,7 +117,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), "breakdown": WatchlistStandardBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": WatchlistStandardProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None diff --git a/onfido/models/watchlist_standard_properties.py b/onfido/models/watchlist_standard_properties.py index c492b7c..eb0adc9 100644 --- a/onfido/models/watchlist_standard_properties.py +++ b/onfido/models/watchlist_standard_properties.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set from typing_extensions import Self @@ -26,7 +26,7 @@ class WatchlistStandardProperties(BaseModel): """ WatchlistStandardProperties """ # noqa: E501 - records: Optional[List[StrictStr]] = Field(default=None, description="Returns any matches including, but not limited to, name and date of birth of match, aliases and associates, and relevant events and sources.") + records: Optional[List[Dict[str, Any]]] = Field(default=None, description="Returns any matches including, but not limited to, name and date of birth of match, aliases and associates, and relevant events and sources.") additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["records"] diff --git a/onfido/models/watchlist_standard_report.py b/onfido/models/watchlist_standard_report.py index e7b13d5..e63e87d 100644 --- a/onfido/models/watchlist_standard_report.py +++ b/onfido/models/watchlist_standard_report.py @@ -20,7 +20,6 @@ from datetime import datetime from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -from onfido.models.report_document import ReportDocument from onfido.models.report_name import ReportName from onfido.models.report_result import ReportResult from onfido.models.report_status import ReportStatus @@ -41,12 +40,11 @@ class WatchlistStandardReport(BaseModel): result: Optional[ReportResult] = None sub_result: Optional[ReportSubResult] = None check_id: Optional[StrictStr] = Field(default=None, description="The ID of the check to which the report belongs. Read-only.") - 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]") name: ReportName breakdown: Optional[WatchlistStandardBreakdown] = None properties: Optional[WatchlistStandardProperties] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"] + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "name", "breakdown", "properties"] model_config = ConfigDict( populate_by_name=True, @@ -89,13 +87,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of each item in documents (list) - _items = [] - if self.documents: - for _item_documents in self.documents: - if _item_documents: - _items.append(_item_documents.to_dict()) - _dict['documents'] = _items # override the default output from pydantic by calling `to_dict()` of breakdown if self.breakdown: _dict['breakdown'] = self.breakdown.to_dict() @@ -126,7 +117,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "result": obj.get("result"), "sub_result": obj.get("sub_result"), "check_id": obj.get("check_id"), - "documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, "name": obj.get("name"), "breakdown": WatchlistStandardBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None, "properties": WatchlistStandardProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None diff --git a/onfido/models/webhook_event_payload_object.py b/onfido/models/webhook_event_payload_object.py index 570a7d2..608577a 100644 --- a/onfido/models/webhook_event_payload_object.py +++ b/onfido/models/webhook_event_payload_object.py @@ -32,7 +32,7 @@ class WebhookEventPayloadObject(BaseModel): status: Optional[WebhookEventObjectStatus] = None started_at_iso8601: Optional[datetime] = Field(default=None, description="The date and time when the operation was started, if available.") completed_at_iso8601: Optional[datetime] = Field(default=None, description="The date and time when the operation was completed, if available.") - href: StrictStr = Field(description="The uri of the resource.") + href: Optional[StrictStr] = Field(default=None, description="The uri of the resource.") additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["id", "status", "started_at_iso8601", "completed_at_iso8601", "href"] diff --git a/onfido/models/webhook_event_type.py b/onfido/models/webhook_event_type.py index fcca273..131d942 100644 --- a/onfido/models/webhook_event_type.py +++ b/onfido/models/webhook_event_type.py @@ -42,7 +42,6 @@ class WebhookEventType(str, Enum): REPORT_DOT_AWAITING_APPROVAL = 'report.awaiting_approval' REPORT_DOT_COMPLETED = 'report.completed' WORKFLOW_TIMELINE_FILE_DOT_CREATED = 'workflow_timeline_file.created' - WORKFLOW_SIGNED_EVIDENCE_FILE_DOT_CREATED = 'workflow_signed_evidence_file.created' WORKFLOW_RUN_EVIDENCE_FOLDER_DOT_CREATED = 'workflow_run_evidence_folder.created' @classmethod diff --git a/onfido/webhook_event_verifier.py b/onfido/webhook_event_verifier.py index d69e670..5c36ca8 100644 --- a/onfido/webhook_event_verifier.py +++ b/onfido/webhook_event_verifier.py @@ -1,5 +1,6 @@ import hmac import hashlib +from typing import Optional from .models import WebhookEvent @@ -9,10 +10,10 @@ class OnfidoInvalidSignatureError(Exception): class WebhookEventVerifier: - def __init__(self, webhook_token): + def __init__(self, webhook_token: str) -> None: self.webhook_token = webhook_token - def read_payload(self, raw_event, signature): + def read_payload(self, raw_event: str, signature: str) -> Optional[WebhookEvent]: # Compute the the actual HMAC signature from the raw request body. event_signature = hmac.new( key=self.webhook_token.encode("utf-8"), diff --git a/poetry.lock b/poetry.lock index 1f3acee..a1c258a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -338,13 +338,13 @@ files = [ [[package]] name = "pydantic" -version = "2.10.5" +version = "2.10.6" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.10.5-py3-none-any.whl", hash = "sha256:4dd4e322dbe55472cb7ca7e73f4b63574eecccf2835ffa2af9021ce113c83c53"}, - {file = "pydantic-2.10.5.tar.gz", hash = "sha256:278b38dbbaec562011d659ee05f63346951b3a248a6f3642e1bc68894ea2b4ff"}, + {file = "pydantic-2.10.6-py3-none-any.whl", hash = "sha256:427d664bf0b8a2b34ff5dd0f5a18df00591adcee7198fbd71981054cef37b584"}, + {file = "pydantic-2.10.6.tar.gz", hash = "sha256:ca5daa827cce33de7a42be142548b0096bf05a7e7b365aebfa5f8eeec7128236"}, ] [package.dependencies] @@ -672,13 +672,13 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "virtualenv" -version = "20.29.1" +version = "20.29.2" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.8" files = [ - {file = "virtualenv-20.29.1-py3-none-any.whl", hash = "sha256:4e4cb403c0b0da39e13b46b1b2476e505cb0046b25f242bee80f62bf990b2779"}, - {file = "virtualenv-20.29.1.tar.gz", hash = "sha256:b8b8970138d32fb606192cb97f6cd4bb644fa486be9308fb9b63f81091b5dc35"}, + {file = "virtualenv-20.29.2-py3-none-any.whl", hash = "sha256:febddfc3d1ea571bdb1dc0f98d7b45d24def7428214d4fb73cc486c9568cce6a"}, + {file = "virtualenv-20.29.2.tar.gz", hash = "sha256:fdaabebf6d03b5ba83ae0a02cfe96f48a716f4fae556461d180825866f75b728"}, ] [package.dependencies] diff --git a/pyproject.toml b/pyproject.toml index 422cb03..00f9199 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "onfido-python" -version = "4.6.0" +version = "5.0.0" description = "Python library for the Onfido API" authors = ["OpenAPI Generator Community "] license = "MIT" diff --git a/setup.py b/setup.py index e713524..4465a86 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools NAME = "onfido-python" -VERSION = "4.6.0" +VERSION = "5.0.0" PYTHON_REQUIRES = ">= 3.8" REQUIRES = [ "urllib3 >= 1.25.3, < 3.0.0",