Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh onfido-python after onfido-openapi-spec update (38a8740) #61

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip and install poetry
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Poetry cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.POETRY_CACHE_DIR }}
key: ${{ runner.os }}-poetry${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
Expand All @@ -54,8 +54,7 @@ jobs:
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude onfido
- name: Test with pytest
if: ${{ matrix.python-version == '3.11' &&
github.repository_owner == 'onfido' &&
github.actor != 'dependabot[bot]' }}
github.repository_owner == 'onfido' }}
run: |
poetry run pytest --show-capture=no
env:
Expand All @@ -69,11 +68,14 @@ jobs:
publish:
runs-on: ubuntu-latest
needs: integration-tests
environment: delivery
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_ACTION_ACCESS_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
Expand All @@ -87,3 +89,31 @@ jobs:
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Update CHANGELOG.md
run: |
TMP_FILE=$(mktemp)

RELEASE_VERSION=$(jq -r '.release' .release.json)
RELEASE_DATE=`date +'%dth %B %Y' | sed -E 's/^0//;s/^([2,3]?)1th/\11st/;s/^([2]?)2th/\12nd/;s/^([2]?)3th/\13rd/'`

SPEC_COMMIT_SHA=$(jq -r '.source.short_sha' .release.json)
SPEC_COMMIT_URL=$(jq -r '.source.repo_url + "/commit/" + .source.long_sha' .release.json)
SPEC_RELEASE_VERSION=$(jq -r '.source.version' .release.json)
SPEC_RELEASE_URL=$(jq -r '.source.repo_url + "/releases/tag/" + .source.version' .release.json)

echo -e "# Changelog\n\n## $RELEASE_VERSION $RELEASE_DATE\n\n" >| $TMP_FILE
echo -en "${{ github.event.release.body }}\nBased on Onfido OpenAPI spec " >> $TMP_FILE

if [ -z $SPEC_RELEASE_VERSION ]; then
echo "up to commit [$SPEC_COMMIT_SHA](${SPEC_COMMIT_URL})." >> $TMP_FILE
else
echo "version [$SPEC_RELEASE_VERSION](${SPEC_RELEASE_URL})." >> $TMP_FILE
fi

grep -v "^# Changelog" CHANGELOG.md >> $TMP_FILE
mv $TMP_FILE CHANGELOG.md

git config user.name "GitHub Actions Bot"
git config user.email "<>"
git commit -m "Update CHANGELOG.md after library release" CHANGELOG.md
git push
9 changes: 9 additions & 0 deletions .release.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"source": {
"repo_url": "https://github.com/onfido/onfido-openapi-spec",
"short_sha": "38a8740",
"long_sha": "38a87401552386cb0b17aae28385c5e2f4af7bfc",
"version": ""
},
"release": "v3.0.0"
}
5 changes: 0 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Changelog

## v3.0.0 14th Jun 2024

- Make library auto-generated and based on [Onfido OpenAPI spec](https://github.com/onfido/onfido-openapi-spec)
- Refresh library up to commit: [62dc554](https://github.com/onfido/onfido-openapi-spec/commit/62dc5541a4a51e8de313fc99fb3dec496033a23e)

## v2.10.0 24th November 2023

- Added core methods for [WorkflowRuns](https://documentation.onfido.com/#workflow-runs)
Expand Down
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,15 @@ Webhook events payload needs to be verified before it can be accessed. Library a
pass
```

### Recommendations

#### Do not use additional properties

Retain from using `additional_properties` dictionary to access not defined properties to avoid breaking changes when these fields will appear.

## Contributing

This library is automatically generated using [OpenAPI Generator](https://openapi-generator.tech) - version: 7.6.0; therefore all the contributions, except tests files, should target [Onfido OpenAPI specification repository](https://github.com/onfido/onfido-openapi-spec/tree/master) instead of this repository.
This library is automatically generated using [OpenAPI Generator](https://openapi-generator.tech) (version: 7.6.0); therefore all the contributions, except tests files, should target [Onfido OpenAPI specification repository](https://github.com/onfido/onfido-openapi-spec/tree/master) instead of this repository.

For contributions to the tests instead, please follow the steps below:

Expand All @@ -121,11 +127,27 @@ For contributions to the tests instead, please follow the steps below:
5. Push to the branch (`git push origin my-new-feature`)
6. Create a new Pull Request

## Versioning policy

[Semantic Versioning](https://semver.org) policy is used for library versioning, following guidelines and limitations below:

- MAJOR versions (x.0.0) might:
- target a new API version
- include non-backward compatible change
- MINOR versions (0.x.0) might:
- add a new functionality, non-mandatory parameter or property
- deprecate an old functionality
- include non-backward compatible change to a functionality which is:
- labelled as alpha or beta
- completely broken and not usable
- PATCH version (0.0.x) might:
- fix a bug
- include backward compatible changes only

## More documentation

More documentation and code examples can be found at <https://documentation.onfido.com>.

## Support

Should you encounter any technical issues during integration, please contact Onfido's Customer Support team
via the [Customer Experience Portal](https://public.support.onfido.com/) which also includes support documentation.
Should you encounter any technical issues during integration, please contact Onfido's Customer Support team via the [Customer Experience Portal](https://public.support.onfido.com/) which also includes support documentation.
4 changes: 4 additions & 0 deletions onfido/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
from onfido.models.facial_similarity_motion_breakdown_visual_authenticity import FacialSimilarityMotionBreakdownVisualAuthenticity
from onfido.models.facial_similarity_motion_breakdown_visual_authenticity_breakdown import FacialSimilarityMotionBreakdownVisualAuthenticityBreakdown
from onfido.models.facial_similarity_motion_breakdown_visual_authenticity_breakdown_spoofing_detection import FacialSimilarityMotionBreakdownVisualAuthenticityBreakdownSpoofingDetection
from onfido.models.facial_similarity_motion_properties import FacialSimilarityMotionProperties
from onfido.models.facial_similarity_motion_report import FacialSimilarityMotionReport
from onfido.models.facial_similarity_photo_breakdown import FacialSimilarityPhotoBreakdown
from onfido.models.facial_similarity_photo_breakdown_face_comparison import FacialSimilarityPhotoBreakdownFaceComparison
Expand All @@ -159,7 +160,9 @@
from onfido.models.facial_similarity_photo_fully_auto_breakdown_image_integrity import FacialSimilarityPhotoFullyAutoBreakdownImageIntegrity
from onfido.models.facial_similarity_photo_fully_auto_breakdown_image_integrity_breakdown import FacialSimilarityPhotoFullyAutoBreakdownImageIntegrityBreakdown
from onfido.models.facial_similarity_photo_fully_auto_breakdown_image_integrity_breakdown_source_integrity import FacialSimilarityPhotoFullyAutoBreakdownImageIntegrityBreakdownSourceIntegrity
from onfido.models.facial_similarity_photo_fully_auto_properties import FacialSimilarityPhotoFullyAutoProperties
from onfido.models.facial_similarity_photo_fully_auto_report import FacialSimilarityPhotoFullyAutoReport
from onfido.models.facial_similarity_photo_properties import FacialSimilarityPhotoProperties
from onfido.models.facial_similarity_photo_report import FacialSimilarityPhotoReport
from onfido.models.facial_similarity_video_breakdown import FacialSimilarityVideoBreakdown
from onfido.models.facial_similarity_video_breakdown_face_comparison import FacialSimilarityVideoBreakdownFaceComparison
Expand All @@ -171,6 +174,7 @@
from onfido.models.facial_similarity_video_breakdown_visual_authenticity_breakdown import FacialSimilarityVideoBreakdownVisualAuthenticityBreakdown
from onfido.models.facial_similarity_video_breakdown_visual_authenticity_breakdown_liveness_detected import FacialSimilarityVideoBreakdownVisualAuthenticityBreakdownLivenessDetected
from onfido.models.facial_similarity_video_breakdown_visual_authenticity_breakdown_spoofing_detection import FacialSimilarityVideoBreakdownVisualAuthenticityBreakdownSpoofingDetection
from onfido.models.facial_similarity_video_properties import FacialSimilarityVideoProperties
from onfido.models.facial_similarity_video_report import FacialSimilarityVideoReport
from onfido.models.id_number import IdNumber
from onfido.models.id_photo import IdPhoto
Expand Down
4 changes: 4 additions & 0 deletions onfido/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
from onfido.models.facial_similarity_motion_breakdown_visual_authenticity import FacialSimilarityMotionBreakdownVisualAuthenticity
from onfido.models.facial_similarity_motion_breakdown_visual_authenticity_breakdown import FacialSimilarityMotionBreakdownVisualAuthenticityBreakdown
from onfido.models.facial_similarity_motion_breakdown_visual_authenticity_breakdown_spoofing_detection import FacialSimilarityMotionBreakdownVisualAuthenticityBreakdownSpoofingDetection
from onfido.models.facial_similarity_motion_properties import FacialSimilarityMotionProperties
from onfido.models.facial_similarity_motion_report import FacialSimilarityMotionReport
from onfido.models.facial_similarity_photo_breakdown import FacialSimilarityPhotoBreakdown
from onfido.models.facial_similarity_photo_breakdown_face_comparison import FacialSimilarityPhotoBreakdownFaceComparison
Expand All @@ -142,7 +143,9 @@
from onfido.models.facial_similarity_photo_fully_auto_breakdown_image_integrity import FacialSimilarityPhotoFullyAutoBreakdownImageIntegrity
from onfido.models.facial_similarity_photo_fully_auto_breakdown_image_integrity_breakdown import FacialSimilarityPhotoFullyAutoBreakdownImageIntegrityBreakdown
from onfido.models.facial_similarity_photo_fully_auto_breakdown_image_integrity_breakdown_source_integrity import FacialSimilarityPhotoFullyAutoBreakdownImageIntegrityBreakdownSourceIntegrity
from onfido.models.facial_similarity_photo_fully_auto_properties import FacialSimilarityPhotoFullyAutoProperties
from onfido.models.facial_similarity_photo_fully_auto_report import FacialSimilarityPhotoFullyAutoReport
from onfido.models.facial_similarity_photo_properties import FacialSimilarityPhotoProperties
from onfido.models.facial_similarity_photo_report import FacialSimilarityPhotoReport
from onfido.models.facial_similarity_video_breakdown import FacialSimilarityVideoBreakdown
from onfido.models.facial_similarity_video_breakdown_face_comparison import FacialSimilarityVideoBreakdownFaceComparison
Expand All @@ -154,6 +157,7 @@
from onfido.models.facial_similarity_video_breakdown_visual_authenticity_breakdown import FacialSimilarityVideoBreakdownVisualAuthenticityBreakdown
from onfido.models.facial_similarity_video_breakdown_visual_authenticity_breakdown_liveness_detected import FacialSimilarityVideoBreakdownVisualAuthenticityBreakdownLivenessDetected
from onfido.models.facial_similarity_video_breakdown_visual_authenticity_breakdown_spoofing_detection import FacialSimilarityVideoBreakdownVisualAuthenticityBreakdownSpoofingDetection
from onfido.models.facial_similarity_video_properties import FacialSimilarityVideoProperties
from onfido.models.facial_similarity_video_report import FacialSimilarityVideoReport
from onfido.models.id_number import IdNumber
from onfido.models.id_photo import IdPhoto
Expand Down
100 changes: 100 additions & 0 deletions onfido/models/facial_similarity_motion_properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# 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, StrictFloat, StrictInt
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class FacialSimilarityMotionProperties(BaseModel):
"""
FacialSimilarityMotionProperties
""" # noqa: E501
score: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="A floating point number between 0 and 1. The closer the score is to 0, the more likely it is to be a spoof (i.e. videos of digital screens, masks or print-outs). Conversely, the closer it is to 1, the less likely it is to be a spoof. ")
additional_properties: Dict[str, Any] = {}
__properties: ClassVar[List[str]] = ["score"]

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 FacialSimilarityMotionProperties 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,
)
# 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 FacialSimilarityMotionProperties from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate({
"score": obj.get("score")
})
# 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


10 changes: 8 additions & 2 deletions onfido/models/facial_similarity_motion_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from onfido.models.facial_similarity_motion_breakdown import FacialSimilarityMotionBreakdown
from onfido.models.facial_similarity_motion_properties import FacialSimilarityMotionProperties
from onfido.models.report_document import ReportDocument
from onfido.models.report_name import ReportName
from onfido.models.report_result import ReportResult
Expand All @@ -43,8 +44,9 @@ class FacialSimilarityMotionReport(BaseModel):
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[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", "breakdown"]
__properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "sub_result", "check_id", "documents", "name", "breakdown", "properties"]

model_config = ConfigDict(
populate_by_name=True,
Expand Down Expand Up @@ -97,6 +99,9 @@ def to_dict(self) -> Dict[str, Any]:
# override the default output from pydantic by calling `to_dict()` of breakdown
if self.breakdown:
_dict['breakdown'] = self.breakdown.to_dict()
# override the default output from pydantic by calling `to_dict()` of properties
if self.properties:
_dict['properties'] = self.properties.to_dict()
# 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():
Expand All @@ -123,7 +128,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"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": FacialSimilarityMotionBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None
"breakdown": FacialSimilarityMotionBreakdown.from_dict(obj["breakdown"]) if obj.get("breakdown") is not None else None,
"properties": FacialSimilarityMotionProperties.from_dict(obj["properties"]) if obj.get("properties") is not None else None
})
# store additional fields in additional_properties
for _key in obj.keys():
Expand Down
Loading