Skip to content

Commit 2db45e9

Browse files
Merge pull request #81 from onfido/release-upgrade
Refresh onfido-python after onfido-openapi-spec update (0eec622)
2 parents 15e1e93 + 1ea13ca commit 2db45e9

40 files changed

+465
-206
lines changed

.release.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"source": {
33
"repo_url": "https://github.com/onfido/onfido-openapi-spec",
4-
"short_sha": "be823e7",
5-
"long_sha": "be823e7815c93bfbfc3fb764c0548f57cb851fe9",
6-
"version": "v4.6.0"
4+
"short_sha": "0eec622",
5+
"long_sha": "0eec6225e66b9f905dac23fe4eb18a1584517f64",
6+
"version": ""
77
},
8-
"release": "v4.6.0"
8+
"release": "v5.0.0"
99
}

onfido/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
""" # noqa: E501
1515

1616

17-
__version__ = "4.6.0"
17+
__version__ = "5.0.0"
1818

1919
# import apis into sdk package
2020
from onfido.api.default_api import DefaultApi
@@ -113,6 +113,7 @@
113113
from onfido.models.document_properties_extracted_data import DocumentPropertiesExtractedData
114114
from onfido.models.document_properties_nfc import DocumentPropertiesNfc
115115
from onfido.models.document_report import DocumentReport
116+
from onfido.models.document_report_shared import DocumentReportShared
116117
from onfido.models.document_response import DocumentResponse
117118
from onfido.models.document_shared import DocumentShared
118119
from onfido.models.document_types import DocumentTypes

onfido/api/default_api.py

Lines changed: 279 additions & 0 deletions
Large diffs are not rendered by default.

onfido/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __init__(
9090
self.default_headers[header_name] = header_value
9191
self.cookie = cookie
9292
# Set default User-Agent.
93-
self.user_agent = 'onfido-python/4.6.0'
93+
self.user_agent = 'onfido-python/5.0.0'
9494
self.client_side_validation = configuration.client_side_validation
9595

9696
def __enter__(self):

onfido/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def to_debug_report(self):
394394
"OS: {env}\n"\
395395
"Python Version: {pyversion}\n"\
396396
"Version of the API: v3.6\n"\
397-
"SDK Package Version: 4.6.0".\
397+
"SDK Package Version: 5.0.0".\
398398
format(env=sys.platform, pyversion=sys.version)
399399

400400
def get_host_settings(self):

onfido/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
from onfido.models.document_properties_extracted_data import DocumentPropertiesExtractedData
9797
from onfido.models.document_properties_nfc import DocumentPropertiesNfc
9898
from onfido.models.document_report import DocumentReport
99+
from onfido.models.document_report_shared import DocumentReportShared
99100
from onfido.models.document_response import DocumentResponse
100101
from onfido.models.document_shared import DocumentShared
101102
from onfido.models.document_types import DocumentTypes

onfido/models/device_intelligence_report.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from pydantic import BaseModel, ConfigDict, Field, StrictStr
2222
from typing import Any, ClassVar, Dict, List, Optional
2323
from onfido.models.device_intelligence_breakdown import DeviceIntelligenceBreakdown
24-
from onfido.models.report_document import ReportDocument
2524
from onfido.models.report_name import ReportName
2625
from onfido.models.report_result import ReportResult
2726
from onfido.models.report_status import ReportStatus
@@ -40,11 +39,10 @@ class DeviceIntelligenceReport(BaseModel):
4039
result: Optional[ReportResult] = None
4140
sub_result: Optional[ReportSubResult] = None
4241
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]")
4442
name: ReportName
4543
breakdown: Optional[DeviceIntelligenceBreakdown] = None
4644
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"]
4846

4947
model_config = ConfigDict(
5048
populate_by_name=True,
@@ -87,13 +85,6 @@ def to_dict(self) -> Dict[str, Any]:
8785
exclude=excluded_fields,
8886
exclude_none=True,
8987
)
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
9788
# override the default output from pydantic by calling `to_dict()` of breakdown
9889
if self.breakdown:
9990
_dict['breakdown'] = self.breakdown.to_dict()
@@ -121,7 +112,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
121112
"result": obj.get("result"),
122113
"sub_result": obj.get("sub_result"),
123114
"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,
125115
"name": obj.get("name"),
126116
"breakdown": DeviceIntelligenceBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None
127117
})

onfido/models/document.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@ class Document(BaseModel):
4343
additional_properties: Dict[str, Any] = {}
4444
__properties: ClassVar[List[str]] = ["file_type", "type", "side", "issuing_country", "applicant_id", "id", "created_at", "href", "download_href", "file_name", "file_size"]
4545

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-
5646
@field_validator('side')
5747
def side_validate_enum(cls, value):
5848
"""Validates the enum"""

onfido/models/document_report.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ class DocumentReport(BaseModel):
4141
result: Optional[ReportResult] = None
4242
sub_result: Optional[ReportSubResult] = None
4343
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]")
4544
name: ReportName
45+
documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.")
4646
breakdown: Optional[DocumentBreakdown] = None
4747
properties: Optional[DocumentProperties] = None
4848
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"]
5050

5151
model_config = ConfigDict(
5252
populate_by_name=True,
@@ -126,8 +126,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
126126
"result": obj.get("result"),
127127
"sub_result": obj.get("sub_result"),
128128
"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,
130129
"name": obj.get("name"),
130+
"documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None,
131131
"breakdown": DocumentBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None,
132132
"properties": DocumentProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None
133133
})
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# coding: utf-8
2+
3+
"""
4+
Onfido API v3.6
5+
6+
The Onfido API (v3.6)
7+
8+
The version of the OpenAPI document: v3.6
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
""" # noqa: E501
13+
14+
15+
from __future__ import annotations
16+
import pprint
17+
import re # noqa: F401
18+
import json
19+
20+
from pydantic import BaseModel, ConfigDict, Field
21+
from typing import Any, ClassVar, Dict, List, Optional
22+
from onfido.models.report_document import ReportDocument
23+
from typing import Optional, Set
24+
from typing_extensions import Self
25+
26+
class DocumentReportShared(BaseModel):
27+
"""
28+
DocumentReportShared
29+
""" # noqa: E501
30+
documents: Optional[List[ReportDocument]] = Field(default=None, description="Array of objects with document ids that were used in the Onfido engine.")
31+
additional_properties: Dict[str, Any] = {}
32+
__properties: ClassVar[List[str]] = ["documents"]
33+
34+
model_config = ConfigDict(
35+
populate_by_name=True,
36+
validate_assignment=True,
37+
protected_namespaces=(),
38+
)
39+
40+
41+
def to_str(self) -> str:
42+
"""Returns the string representation of the model using alias"""
43+
return pprint.pformat(self.model_dump(by_alias=True))
44+
45+
def to_json(self) -> str:
46+
"""Returns the JSON representation of the model using alias"""
47+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48+
return json.dumps(self.to_dict())
49+
50+
@classmethod
51+
def from_json(cls, json_str: str) -> Optional[Self]:
52+
"""Create an instance of DocumentReportShared from a JSON string"""
53+
return cls.from_dict(json.loads(json_str))
54+
55+
def to_dict(self) -> Dict[str, Any]:
56+
"""Return the dictionary representation of the model using alias.
57+
58+
This has the following differences from calling pydantic's
59+
`self.model_dump(by_alias=True)`:
60+
61+
* `None` is only added to the output dict for nullable fields that
62+
were set at model initialization. Other fields with value `None`
63+
are ignored.
64+
* Fields in `self.additional_properties` are added to the output dict.
65+
"""
66+
excluded_fields: Set[str] = set([
67+
"additional_properties",
68+
])
69+
70+
_dict = self.model_dump(
71+
by_alias=True,
72+
exclude=excluded_fields,
73+
exclude_none=True,
74+
)
75+
# override the default output from pydantic by calling `to_dict()` of each item in documents (list)
76+
_items = []
77+
if self.documents:
78+
for _item_documents in self.documents:
79+
if _item_documents:
80+
_items.append(_item_documents.to_dict())
81+
_dict['documents'] = _items
82+
# puts key-value pairs in additional_properties in the top level
83+
if self.additional_properties is not None:
84+
for _key, _value in self.additional_properties.items():
85+
_dict[_key] = _value
86+
87+
return _dict
88+
89+
@classmethod
90+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91+
"""Create an instance of DocumentReportShared from a dict"""
92+
if obj is None:
93+
return None
94+
95+
if not isinstance(obj, dict):
96+
return cls.model_validate(obj)
97+
98+
_obj = cls.model_validate({
99+
"documents": [ReportDocument.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None
100+
})
101+
# store additional fields in additional_properties
102+
for _key in obj.keys():
103+
if _key not in cls.__properties:
104+
_obj.additional_properties[_key] = obj.get(_key)
105+
106+
return _obj
107+
108+

0 commit comments

Comments
 (0)