diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 7dc6819..c31ffa1 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -16,6 +16,8 @@ on: release: types: - published + schedule: + - cron: "0 14 * * 0" # Every Sunday, 2 hours after midday jobs: integration-tests: diff --git a/.release.json b/.release.json index 174b6be..3064432 100644 --- a/.release.json +++ b/.release.json @@ -1,9 +1,9 @@ { "source": { "repo_url": "https://github.com/onfido/onfido-openapi-spec", - "short_sha": "08508b9", - "long_sha": "08508b9517238b3becb4265130633a418a8ee319", - "version": "v3.5.0" + "short_sha": "10f8380", + "long_sha": "10f83806efa080edbf022ac48d5eeac90fbceb0c", + "version": "" }, "release": "v3.5.0" } diff --git a/onfido/__init__.py b/onfido/__init__.py index 771d4ab..4e07888 100644 --- a/onfido/__init__.py +++ b/onfido/__init__.py @@ -37,6 +37,8 @@ from onfido.models.addresses_list import AddressesList from onfido.models.applicant import Applicant from onfido.models.applicant_builder import ApplicantBuilder +from onfido.models.applicant_consent_builder import ApplicantConsentBuilder +from onfido.models.applicant_consent_name import ApplicantConsentName from onfido.models.applicant_create import ApplicantCreate from onfido.models.applicant_request import ApplicantRequest from onfido.models.applicant_response import ApplicantResponse @@ -49,11 +51,10 @@ from onfido.models.check_request import CheckRequest from onfido.models.check_response import CheckResponse from onfido.models.check_shared import CheckShared +from onfido.models.check_status import CheckStatus from onfido.models.checks_list import ChecksList from onfido.models.complete_task_builder import CompleteTaskBuilder from onfido.models.complete_task_data_builder import CompleteTaskDataBuilder -from onfido.models.consent_item import ConsentItem -from onfido.models.consents_builder import ConsentsBuilder from onfido.models.country_codes import CountryCodes from onfido.models.device_intelligence_breakdown import DeviceIntelligenceBreakdown from onfido.models.device_intelligence_breakdown_breakdown import DeviceIntelligenceBreakdownBreakdown @@ -297,8 +298,11 @@ from onfido.models.webhook_builder import WebhookBuilder from onfido.models.webhook_create import WebhookCreate from onfido.models.webhook_event import WebhookEvent +from onfido.models.webhook_event_object_status import WebhookEventObjectStatus from onfido.models.webhook_event_payload import WebhookEventPayload from onfido.models.webhook_event_payload_object import WebhookEventPayloadObject +from onfido.models.webhook_event_payload_resource import WebhookEventPayloadResource +from onfido.models.webhook_event_resource_type import WebhookEventResourceType from onfido.models.webhook_event_type import WebhookEventType from onfido.models.webhook_resend import WebhookResend from onfido.models.webhook_response import WebhookResponse @@ -309,11 +313,12 @@ from onfido.models.webhooks_resend_item import WebhooksResendItem from onfido.models.workflow_run import WorkflowRun from onfido.models.workflow_run_builder import WorkflowRunBuilder +from onfido.models.workflow_run_error import WorkflowRunError +from onfido.models.workflow_run_link import WorkflowRunLink from onfido.models.workflow_run_request import WorkflowRunRequest from onfido.models.workflow_run_response import WorkflowRunResponse -from onfido.models.workflow_run_response_error import WorkflowRunResponseError from onfido.models.workflow_run_shared import WorkflowRunShared -from onfido.models.workflow_run_shared_link import WorkflowRunSharedLink +from onfido.models.workflow_run_status import WorkflowRunStatus from onfido.webhook_event_verifier import OnfidoInvalidSignatureError from onfido.webhook_event_verifier import WebhookEventVerifier diff --git a/onfido/api/default_api.py b/onfido/api/default_api.py index 8f0bb4a..92e5839 100644 --- a/onfido/api/default_api.py +++ b/onfido/api/default_api.py @@ -16554,7 +16554,7 @@ def upload_document( Documents are uploaded using this endpoint. Along with the file upload the relevant document type must be specified. Documents must be uploaded as a multipart form. The valid file types are: jpg, png and pdf. The file size must be between 2KB and 3MB. :param type: The type of document (required) - :type type: str + :type type: DocumentTypes :param applicant_id: The ID of the applicant whose document is being uploaded. (required) :type applicant_id: str :param file: The file to be uploaded. (required) @@ -16649,7 +16649,7 @@ def upload_document_with_http_info( Documents are uploaded using this endpoint. Along with the file upload the relevant document type must be specified. Documents must be uploaded as a multipart form. The valid file types are: jpg, png and pdf. The file size must be between 2KB and 3MB. :param type: The type of document (required) - :type type: str + :type type: DocumentTypes :param applicant_id: The ID of the applicant whose document is being uploaded. (required) :type applicant_id: str :param file: The file to be uploaded. (required) @@ -16744,7 +16744,7 @@ def upload_document_without_preload_content( Documents are uploaded using this endpoint. Along with the file upload the relevant document type must be specified. Documents must be uploaded as a multipart form. The valid file types are: jpg, png and pdf. The file size must be between 2KB and 3MB. :param type: The type of document (required) - :type type: str + :type type: DocumentTypes :param applicant_id: The ID of the applicant whose document is being uploaded. (required) :type applicant_id: str :param file: The file to be uploaded. (required) diff --git a/onfido/models/__init__.py b/onfido/models/__init__.py index bfcf386..2ab973a 100644 --- a/onfido/models/__init__.py +++ b/onfido/models/__init__.py @@ -20,6 +20,8 @@ from onfido.models.addresses_list import AddressesList from onfido.models.applicant import Applicant from onfido.models.applicant_builder import ApplicantBuilder +from onfido.models.applicant_consent_builder import ApplicantConsentBuilder +from onfido.models.applicant_consent_name import ApplicantConsentName from onfido.models.applicant_create import ApplicantCreate from onfido.models.applicant_request import ApplicantRequest from onfido.models.applicant_response import ApplicantResponse @@ -32,11 +34,10 @@ from onfido.models.check_request import CheckRequest from onfido.models.check_response import CheckResponse from onfido.models.check_shared import CheckShared +from onfido.models.check_status import CheckStatus from onfido.models.checks_list import ChecksList from onfido.models.complete_task_builder import CompleteTaskBuilder from onfido.models.complete_task_data_builder import CompleteTaskDataBuilder -from onfido.models.consent_item import ConsentItem -from onfido.models.consents_builder import ConsentsBuilder from onfido.models.country_codes import CountryCodes from onfido.models.device_intelligence_breakdown import DeviceIntelligenceBreakdown from onfido.models.device_intelligence_breakdown_breakdown import DeviceIntelligenceBreakdownBreakdown @@ -280,8 +281,11 @@ from onfido.models.webhook_builder import WebhookBuilder from onfido.models.webhook_create import WebhookCreate from onfido.models.webhook_event import WebhookEvent +from onfido.models.webhook_event_object_status import WebhookEventObjectStatus from onfido.models.webhook_event_payload import WebhookEventPayload from onfido.models.webhook_event_payload_object import WebhookEventPayloadObject +from onfido.models.webhook_event_payload_resource import WebhookEventPayloadResource +from onfido.models.webhook_event_resource_type import WebhookEventResourceType from onfido.models.webhook_event_type import WebhookEventType from onfido.models.webhook_resend import WebhookResend from onfido.models.webhook_response import WebhookResponse @@ -292,8 +296,9 @@ from onfido.models.webhooks_resend_item import WebhooksResendItem from onfido.models.workflow_run import WorkflowRun from onfido.models.workflow_run_builder import WorkflowRunBuilder +from onfido.models.workflow_run_error import WorkflowRunError +from onfido.models.workflow_run_link import WorkflowRunLink from onfido.models.workflow_run_request import WorkflowRunRequest from onfido.models.workflow_run_response import WorkflowRunResponse -from onfido.models.workflow_run_response_error import WorkflowRunResponseError from onfido.models.workflow_run_shared import WorkflowRunShared -from onfido.models.workflow_run_shared_link import WorkflowRunSharedLink +from onfido.models.workflow_run_status import WorkflowRunStatus diff --git a/onfido/models/applicant_builder.py b/onfido/models/applicant_builder.py index 96adc02..907dced 100644 --- a/onfido/models/applicant_builder.py +++ b/onfido/models/applicant_builder.py @@ -22,7 +22,7 @@ from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated from onfido.models.address_builder import AddressBuilder -from onfido.models.consents_builder import ConsentsBuilder +from onfido.models.applicant_consent_builder import ApplicantConsentBuilder from onfido.models.id_number import IdNumber from onfido.models.location_builder import LocationBuilder from typing import Optional, Set @@ -36,7 +36,7 @@ class ApplicantBuilder(BaseModel): dob: Optional[date] = Field(default=None, description="The applicant's date of birth") id_numbers: Optional[List[IdNumber]] = None phone_number: Optional[StrictStr] = Field(default=None, description="The applicant's phone number") - consents: Optional[ConsentsBuilder] = None + consents: Optional[List[ApplicantConsentBuilder]] = Field(default=None, description="The applicant's consents") address: Optional[AddressBuilder] = None location: Optional[LocationBuilder] = None first_name: Annotated[str, Field(strict=True)] = Field(description="The applicant's first name") @@ -106,9 +106,13 @@ def to_dict(self) -> Dict[str, Any]: if _item: _items.append(_item.to_dict()) _dict['id_numbers'] = _items - # override the default output from pydantic by calling `to_dict()` of consents + # override the default output from pydantic by calling `to_dict()` of each item in consents (list) + _items = [] if self.consents: - _dict['consents'] = self.consents.to_dict() + for _item in self.consents: + if _item: + _items.append(_item.to_dict()) + _dict['consents'] = _items # override the default output from pydantic by calling `to_dict()` of address if self.address: _dict['address'] = self.address.to_dict() @@ -136,7 +140,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "dob": obj.get("dob"), "id_numbers": [IdNumber.from_dict(_item) for _item in obj["id_numbers"]] if obj.get("id_numbers") is not None else None, "phone_number": obj.get("phone_number"), - "consents": ConsentsBuilder.from_dict(obj["consents"]) if obj.get("consents") is not None else None, + "consents": [ApplicantConsentBuilder.from_dict(_item) for _item in obj["consents"]] if obj.get("consents") is not None else None, "address": AddressBuilder.from_dict(obj["address"]) if obj.get("address") is not None else None, "location": LocationBuilder.from_dict(obj["location"]) if obj.get("location") is not None else None, "first_name": obj.get("first_name"), diff --git a/onfido/models/consents_builder.py b/onfido/models/applicant_consent_builder.py similarity index 83% rename from onfido/models/consents_builder.py rename to onfido/models/applicant_consent_builder.py index 72a659d..46d8cf5 100644 --- a/onfido/models/consents_builder.py +++ b/onfido/models/applicant_consent_builder.py @@ -17,17 +17,20 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict +from pydantic import BaseModel, ConfigDict, StrictBool from typing import Any, ClassVar, Dict, List +from onfido.models.applicant_consent_name import ApplicantConsentName from typing import Optional, Set from typing_extensions import Self -class ConsentsBuilder(BaseModel): +class ApplicantConsentBuilder(BaseModel): """ - ConsentsBuilder + ApplicantConsentBuilder """ # noqa: E501 + name: ApplicantConsentName + granted: StrictBool additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = [] + __properties: ClassVar[List[str]] = ["name", "granted"] model_config = ConfigDict( populate_by_name=True, @@ -47,7 +50,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ConsentsBuilder from a JSON string""" + """Create an instance of ApplicantConsentBuilder from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -79,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ConsentsBuilder from a dict""" + """Create an instance of ApplicantConsentBuilder from a dict""" if obj is None: return None @@ -87,6 +90,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) _obj = cls.model_validate({ + "name": obj.get("name"), + "granted": obj.get("granted") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/onfido/models/applicant_consent_name.py b/onfido/models/applicant_consent_name.py new file mode 100644 index 0000000..34e8a63 --- /dev/null +++ b/onfido/models/applicant_consent_name.py @@ -0,0 +1,38 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class ApplicantConsentName(str, Enum): + """ + ApplicantConsentName + """ + + """ + allowed enum values + """ + PRIVACY_NOTICES_READ = 'privacy_notices_read' + SSN_VERIFICATION = 'ssn_verification' + PHONE_NUMBER_VERIFICATION = 'phone_number_verification' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of ApplicantConsentName from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/onfido/models/applicant_request.py b/onfido/models/applicant_request.py index 00e0e8b..e68abff 100644 --- a/onfido/models/applicant_request.py +++ b/onfido/models/applicant_request.py @@ -17,10 +17,10 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict +from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from onfido.models.address_builder import AddressBuilder -from onfido.models.consents_builder import ConsentsBuilder +from onfido.models.applicant_consent_builder import ApplicantConsentBuilder from onfido.models.location_builder import LocationBuilder from typing import Optional, Set from typing_extensions import Self @@ -29,7 +29,7 @@ class ApplicantRequest(BaseModel): """ ApplicantRequest """ # noqa: E501 - consents: Optional[ConsentsBuilder] = None + consents: Optional[List[ApplicantConsentBuilder]] = Field(default=None, description="The applicant's consents") address: Optional[AddressBuilder] = None location: Optional[LocationBuilder] = None additional_properties: Dict[str, Any] = {} @@ -76,9 +76,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 consents + # override the default output from pydantic by calling `to_dict()` of each item in consents (list) + _items = [] if self.consents: - _dict['consents'] = self.consents.to_dict() + for _item in self.consents: + if _item: + _items.append(_item.to_dict()) + _dict['consents'] = _items # override the default output from pydantic by calling `to_dict()` of address if self.address: _dict['address'] = self.address.to_dict() @@ -102,7 +106,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) _obj = cls.model_validate({ - "consents": ConsentsBuilder.from_dict(obj["consents"]) if obj.get("consents") is not None else None, + "consents": [ApplicantConsentBuilder.from_dict(_item) for _item in obj["consents"]] if obj.get("consents") is not None else None, "address": AddressBuilder.from_dict(obj["address"]) if obj.get("address") is not None else None, "location": LocationBuilder.from_dict(obj["location"]) if obj.get("location") is not None else None }) diff --git a/onfido/models/applicant_updater.py b/onfido/models/applicant_updater.py index 96818f6..da8913f 100644 --- a/onfido/models/applicant_updater.py +++ b/onfido/models/applicant_updater.py @@ -22,7 +22,7 @@ from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated from onfido.models.address_builder import AddressBuilder -from onfido.models.consents_builder import ConsentsBuilder +from onfido.models.applicant_consent_builder import ApplicantConsentBuilder from onfido.models.id_number import IdNumber from onfido.models.location_builder import LocationBuilder from typing import Optional, Set @@ -36,7 +36,7 @@ class ApplicantUpdater(BaseModel): dob: Optional[date] = Field(default=None, description="The applicant's date of birth") id_numbers: Optional[List[IdNumber]] = None phone_number: Optional[StrictStr] = Field(default=None, description="The applicant's phone number") - consents: Optional[ConsentsBuilder] = None + consents: Optional[List[ApplicantConsentBuilder]] = Field(default=None, description="The applicant's consents") address: Optional[AddressBuilder] = None location: Optional[LocationBuilder] = None first_name: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="The applicant's first name") @@ -112,9 +112,13 @@ def to_dict(self) -> Dict[str, Any]: if _item: _items.append(_item.to_dict()) _dict['id_numbers'] = _items - # override the default output from pydantic by calling `to_dict()` of consents + # override the default output from pydantic by calling `to_dict()` of each item in consents (list) + _items = [] if self.consents: - _dict['consents'] = self.consents.to_dict() + for _item in self.consents: + if _item: + _items.append(_item.to_dict()) + _dict['consents'] = _items # override the default output from pydantic by calling `to_dict()` of address if self.address: _dict['address'] = self.address.to_dict() @@ -142,7 +146,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "dob": obj.get("dob"), "id_numbers": [IdNumber.from_dict(_item) for _item in obj["id_numbers"]] if obj.get("id_numbers") is not None else None, "phone_number": obj.get("phone_number"), - "consents": ConsentsBuilder.from_dict(obj["consents"]) if obj.get("consents") is not None else None, + "consents": [ApplicantConsentBuilder.from_dict(_item) for _item in obj["consents"]] if obj.get("consents") is not None else None, "address": AddressBuilder.from_dict(obj["address"]) if obj.get("address") is not None else None, "location": LocationBuilder.from_dict(obj["location"]) if obj.get("location") is not None else None, "first_name": obj.get("first_name"), diff --git a/onfido/models/check.py b/onfido/models/check.py index 58eb4c3..d8d763f 100644 --- a/onfido/models/check.py +++ b/onfido/models/check.py @@ -20,6 +20,7 @@ from datetime import datetime from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional +from onfido.models.check_status import CheckStatus from typing import Optional, Set from typing_extensions import Self @@ -32,27 +33,20 @@ class Check(BaseModel): applicant_provides_data: Optional[StrictBool] = Field(default=None, description="Send an applicant form to applicant to complete to proceed with check. Defaults to false. ") tags: Optional[List[StrictStr]] = Field(default=None, description="Array of tags being assigned to this check.") redirect_uri: Optional[StrictStr] = Field(default=None, description="For checks where `applicant_provides_data` is `true`, redirect to this URI when the applicant has submitted their data.") + privacy_notices_read_consent_given: Optional[StrictBool] = None id: StrictStr = Field(description="The unique identifier for the check.") created_at: Optional[datetime] = Field(default=None, description="The date and time when this check was created.") href: Optional[StrictStr] = Field(default=None, description="The uri of this resource.") - status: Optional[StrictStr] = Field(default=None, description="The current state of the check in the checking process.") + status: Optional[StrictStr] = None result: Optional[StrictStr] = Field(default=None, description="The overall result of the check, based on the results of the constituent reports.") form_uri: Optional[StrictStr] = Field(default=None, description="A link to the applicant form, if `applicant_provides_data` is `true`.") results_uri: Optional[StrictStr] = Field(default=None, description="A link to the corresponding results page on the Onfido dashboard.") report_ids: Optional[List[StrictStr]] = Field(default=None, description="An array of report ids.") sandbox: Optional[StrictBool] = Field(default=None, description="Indicates whether the object was created in the sandbox or not.") + paused: Optional[StrictBool] = None + version: Optional[StrictStr] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["webhook_ids", "applicant_id", "applicant_provides_data", "tags", "redirect_uri", "id", "created_at", "href", "status", "result", "form_uri", "results_uri", "report_ids", "sandbox"] - - @field_validator('status') - def status_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['in_progress', 'awaiting_applicant', 'complete', 'withdrawn', 'paused', 'reopened']): - raise ValueError("must be one of enum values ('in_progress', 'awaiting_applicant', 'complete', 'withdrawn', 'paused', 'reopened')") - return value + __properties: ClassVar[List[str]] = ["webhook_ids", "applicant_id", "applicant_provides_data", "tags", "redirect_uri", "privacy_notices_read_consent_given", "id", "created_at", "href", "status", "result", "form_uri", "results_uri", "report_ids", "sandbox", "paused", "version"] @field_validator('result') def result_validate_enum(cls, value): @@ -127,6 +121,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "applicant_provides_data": obj.get("applicant_provides_data"), "tags": obj.get("tags"), "redirect_uri": obj.get("redirect_uri"), + "privacy_notices_read_consent_given": obj.get("privacy_notices_read_consent_given"), "id": obj.get("id"), "created_at": obj.get("created_at"), "href": obj.get("href"), @@ -135,7 +130,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "form_uri": obj.get("form_uri"), "results_uri": obj.get("results_uri"), "report_ids": obj.get("report_ids"), - "sandbox": obj.get("sandbox") + "sandbox": obj.get("sandbox"), + "paused": obj.get("paused"), + "version": obj.get("version") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/onfido/models/check_builder.py b/onfido/models/check_builder.py index e6b4104..53ef38b 100644 --- a/onfido/models/check_builder.py +++ b/onfido/models/check_builder.py @@ -33,6 +33,7 @@ class CheckBuilder(BaseModel): applicant_provides_data: Optional[StrictBool] = Field(default=False, description="Send an applicant form to applicant to complete to proceed with check. Defaults to false.") tags: Optional[List[StrictStr]] = Field(default=None, description="Array of tags being assigned to this check.") redirect_uri: Optional[StrictStr] = Field(default=None, description="For checks where `applicant_provides_data` is `true`, redirect to this URI when the applicant has submitted their data.") + privacy_notices_read_consent_given: Optional[StrictBool] = None report_names: List[ReportName] = Field(description="An array of report names (strings).") document_ids: Optional[List[StrictStr]] = Field(default=None, description="Optional. An array of document ids, for use with Document reports only. If omitted, the Document report will use the most recently uploaded document by default.") asynchronous: Optional[StrictBool] = Field(default=True, description="Defaults to `true`. If set to `false`, you will only receive a response when all reports in your check have completed. ") @@ -41,7 +42,7 @@ class CheckBuilder(BaseModel): consider: Optional[List[ReportName]] = Field(default=None, description="Array of names of particular reports to return consider as their results. This is a feature available in sandbox testing") us_driving_licence: Optional[UsDrivingLicenceBuilder] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["webhook_ids", "applicant_id", "applicant_provides_data", "tags", "redirect_uri", "report_names", "document_ids", "asynchronous", "suppress_form_emails", "sub_result", "consider", "us_driving_licence"] + __properties: ClassVar[List[str]] = ["webhook_ids", "applicant_id", "applicant_provides_data", "tags", "redirect_uri", "privacy_notices_read_consent_given", "report_names", "document_ids", "asynchronous", "suppress_form_emails", "sub_result", "consider", "us_driving_licence"] model_config = ConfigDict( populate_by_name=True, @@ -109,6 +110,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "applicant_provides_data": obj.get("applicant_provides_data") if obj.get("applicant_provides_data") is not None else False, "tags": obj.get("tags"), "redirect_uri": obj.get("redirect_uri"), + "privacy_notices_read_consent_given": obj.get("privacy_notices_read_consent_given"), "report_names": obj.get("report_names"), "document_ids": obj.get("document_ids"), "asynchronous": obj.get("asynchronous") if obj.get("asynchronous") is not None else True, diff --git a/onfido/models/check_response.py b/onfido/models/check_response.py index e142bc8..6c985e8 100644 --- a/onfido/models/check_response.py +++ b/onfido/models/check_response.py @@ -30,24 +30,16 @@ class CheckResponse(BaseModel): id: StrictStr = Field(description="The unique identifier for the check.") created_at: Optional[datetime] = Field(default=None, description="The date and time when this check was created.") href: Optional[StrictStr] = Field(default=None, description="The uri of this resource.") - status: Optional[StrictStr] = Field(default=None, description="The current state of the check in the checking process.") + status: Optional[StrictStr] = None result: Optional[StrictStr] = Field(default=None, description="The overall result of the check, based on the results of the constituent reports.") form_uri: Optional[StrictStr] = Field(default=None, description="A link to the applicant form, if `applicant_provides_data` is `true`.") results_uri: Optional[StrictStr] = Field(default=None, description="A link to the corresponding results page on the Onfido dashboard.") report_ids: Optional[List[StrictStr]] = Field(default=None, description="An array of report ids.") sandbox: Optional[StrictBool] = Field(default=None, description="Indicates whether the object was created in the sandbox or not.") + paused: Optional[StrictBool] = None + version: Optional[StrictStr] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "form_uri", "results_uri", "report_ids", "sandbox"] - - @field_validator('status') - def status_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['in_progress', 'awaiting_applicant', 'complete', 'withdrawn', 'paused', 'reopened']): - raise ValueError("must be one of enum values ('in_progress', 'awaiting_applicant', 'complete', 'withdrawn', 'paused', 'reopened')") - return value + __properties: ClassVar[List[str]] = ["id", "created_at", "href", "status", "result", "form_uri", "results_uri", "report_ids", "sandbox", "paused", "version"] @field_validator('result') def result_validate_enum(cls, value): @@ -125,7 +117,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "form_uri": obj.get("form_uri"), "results_uri": obj.get("results_uri"), "report_ids": obj.get("report_ids"), - "sandbox": obj.get("sandbox") + "sandbox": obj.get("sandbox"), + "paused": obj.get("paused"), + "version": obj.get("version") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/onfido/models/check_shared.py b/onfido/models/check_shared.py index 535faa8..eb52b39 100644 --- a/onfido/models/check_shared.py +++ b/onfido/models/check_shared.py @@ -31,8 +31,9 @@ class CheckShared(BaseModel): applicant_provides_data: Optional[StrictBool] = Field(default=None, description="Send an applicant form to applicant to complete to proceed with check. Defaults to false. ") tags: Optional[List[StrictStr]] = Field(default=None, description="Array of tags being assigned to this check.") redirect_uri: Optional[StrictStr] = Field(default=None, description="For checks where `applicant_provides_data` is `true`, redirect to this URI when the applicant has submitted their data.") + privacy_notices_read_consent_given: Optional[StrictBool] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["webhook_ids", "applicant_id", "applicant_provides_data", "tags", "redirect_uri"] + __properties: ClassVar[List[str]] = ["webhook_ids", "applicant_id", "applicant_provides_data", "tags", "redirect_uri", "privacy_notices_read_consent_given"] model_config = ConfigDict( populate_by_name=True, @@ -96,7 +97,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "applicant_id": obj.get("applicant_id"), "applicant_provides_data": obj.get("applicant_provides_data"), "tags": obj.get("tags"), - "redirect_uri": obj.get("redirect_uri") + "redirect_uri": obj.get("redirect_uri"), + "privacy_notices_read_consent_given": obj.get("privacy_notices_read_consent_given") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/onfido/models/check_status.py b/onfido/models/check_status.py new file mode 100644 index 0000000..72b2f7f --- /dev/null +++ b/onfido/models/check_status.py @@ -0,0 +1,41 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class CheckStatus(str, Enum): + """ + The current state of the check in the checking process. + """ + + """ + allowed enum values + """ + IN_PROGRESS = 'in_progress' + AWAITING_APPLICANT = 'awaiting_applicant' + COMPLETE = 'complete' + WITHDRAWN = 'withdrawn' + PAUSED = 'paused' + REOPENED = 'reopened' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of CheckStatus from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/onfido/models/consent_item.py b/onfido/models/consent_item.py deleted file mode 100644 index 8ca4825..0000000 --- a/onfido/models/consent_item.py +++ /dev/null @@ -1,109 +0,0 @@ -# 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, StrictBool, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ConsentItem(BaseModel): - """ - The applicant's consents - """ # noqa: E501 - name: StrictStr - granted: StrictBool - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["name", "granted"] - - @field_validator('name') - def name_validate_enum(cls, value): - """Validates the enum""" - if value not in set(['privacy_notices_read', 'ssn_verification', 'phone_number_verification']): - raise ValueError("must be one of enum values ('privacy_notices_read', 'ssn_verification', 'phone_number_verification')") - return value - - 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 ConsentItem 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 ConsentItem from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "granted": obj.get("granted") - }) - # 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/device_intelligence_breakdown_properties_device.py b/onfido/models/device_intelligence_breakdown_properties_device.py index 53ef419..4925285 100644 --- a/onfido/models/device_intelligence_breakdown_properties_device.py +++ b/onfido/models/device_intelligence_breakdown_properties_device.py @@ -35,17 +35,13 @@ class DeviceIntelligenceBreakdownPropertiesDevice(BaseModel): emulator: Optional[StrictBool] = Field(default=None, description="Whether the device is an emulator.") randomized_device: Optional[StrictBool] = Field(default=None, description="Whether the device is providing false randomized device and network information.") fake_network_request: Optional[StrictBool] = Field(default=None, description="Whether device is using stolen security tokens to send the network information.") - true_os: Optional[StrictStr] = Field(default=None, description="The true operating system of the device.") - os_anomaly: Optional[StrictStr] = Field(default=None, description="The likelihood of an operating system anomaly between the true OS and the OS sent by the device.") - rooted: Optional[StrictBool] = Field(default=None, description="Whether the device is rooted.") - remote_software: Optional[StrictBool] = Field(default=None, description="Whether the device is controlled via remote software.") ip_reputation: Optional[StrictStr] = Field(default=None, description="Whether there is highly suspicious traffic related to the IP address. The risk depends on the overall ratio of clear checks on a given IP.") device_fingerprint_reuse: Optional[StrictInt] = Field(default=None, description="The number of times the device was used to create a report for a new applicant. A value greater than 1 indicates potential device reuse.") single_device_used: Optional[StrictBool] = Field(default=None, description="Whether the document or biometric media were uploaded from a single device.") document_capture: Optional[StrictStr] = Field(default=None, description="Whether the document media were live captured from the device camera.") biometric_capture: Optional[StrictStr] = Field(default=None, description="Whether the biometric media were live captured from the device camera.") additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["sdk_version", "sdk_source", "authentication_type", "raw_model", "os", "browser", "emulator", "randomized_device", "fake_network_request", "true_os", "os_anomaly", "rooted", "remote_software", "ip_reputation", "device_fingerprint_reuse", "single_device_used", "document_capture", "biometric_capture"] + __properties: ClassVar[List[str]] = ["sdk_version", "sdk_source", "authentication_type", "raw_model", "os", "browser", "emulator", "randomized_device", "fake_network_request", "ip_reputation", "device_fingerprint_reuse", "single_device_used", "document_capture", "biometric_capture"] @field_validator('sdk_source') def sdk_source_validate_enum(cls, value): @@ -169,10 +165,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "emulator": obj.get("emulator"), "randomized_device": obj.get("randomized_device"), "fake_network_request": obj.get("fake_network_request"), - "true_os": obj.get("true_os"), - "os_anomaly": obj.get("os_anomaly"), - "rooted": obj.get("rooted"), - "remote_software": obj.get("remote_software"), "ip_reputation": obj.get("ip_reputation"), "device_fingerprint_reuse": obj.get("device_fingerprint_reuse"), "single_device_used": obj.get("single_device_used"), diff --git a/onfido/models/device_intelligence_breakdown_properties_ip.py b/onfido/models/device_intelligence_breakdown_properties_ip.py index 2d54e48..b28c7e1 100644 --- a/onfido/models/device_intelligence_breakdown_properties_ip.py +++ b/onfido/models/device_intelligence_breakdown_properties_ip.py @@ -27,11 +27,8 @@ class DeviceIntelligenceBreakdownPropertiesIp(BaseModel): DeviceIntelligenceBreakdownPropertiesIp """ # noqa: E501 address: Optional[StrictStr] = Field(default=None, description="The IP address that uploaded the media.") - vpn_detection: Optional[StrictStr] = Field(default=None, description="The likelihood of the network connection being a VPN.") - proxy_detection: Optional[StrictStr] = Field(default=None, description="The likelihood of the network connection being a Proxy.") - type: Optional[StrictStr] = Field(default=None, description="The type of organization that owns this IP address.") additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["address", "vpn_detection", "proxy_detection", "type"] + __properties: ClassVar[List[str]] = ["address"] model_config = ConfigDict( populate_by_name=True, @@ -91,10 +88,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) _obj = cls.model_validate({ - "address": obj.get("address"), - "vpn_detection": obj.get("vpn_detection"), - "proxy_detection": obj.get("proxy_detection"), - "type": obj.get("type") + "address": obj.get("address") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/onfido/models/document.py b/onfido/models/document.py index 7e4e388..5672e5f 100644 --- a/onfido/models/document.py +++ b/onfido/models/document.py @@ -21,6 +21,7 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from onfido.models.country_codes import CountryCodes +from onfido.models.document_types import DocumentTypes from typing import Optional, Set from typing_extensions import Self @@ -29,7 +30,7 @@ class Document(BaseModel): Document """ # noqa: E501 file_type: Optional[StrictStr] = Field(default=None, description="The file type of the uploaded file") - type: Optional[StrictStr] = Field(default=None, description="The type of document") + type: Optional[DocumentTypes] = Field(default=None, description="The type of document") side: Optional[StrictStr] = Field(default=None, description="The side of the document, if applicable. The possible values are front and back") issuing_country: Optional[CountryCodes] = Field(default=None, description="The issuing country of the document, a 3-letter ISO code.") applicant_id: Optional[StrictStr] = Field(default=None, description="The ID of the applicant whose document is being uploaded.") diff --git a/onfido/models/document_shared.py b/onfido/models/document_shared.py index b992784..f7e1051 100644 --- a/onfido/models/document_shared.py +++ b/onfido/models/document_shared.py @@ -20,6 +20,7 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from onfido.models.country_codes import CountryCodes +from onfido.models.document_types import DocumentTypes from typing import Optional, Set from typing_extensions import Self @@ -28,7 +29,7 @@ class DocumentShared(BaseModel): DocumentShared """ # noqa: E501 file_type: Optional[StrictStr] = Field(default=None, description="The file type of the uploaded file") - type: Optional[StrictStr] = Field(default=None, description="The type of document") + type: Optional[DocumentTypes] = Field(default=None, description="The type of document") side: Optional[StrictStr] = Field(default=None, description="The side of the document, if applicable. The possible values are front and back") issuing_country: Optional[CountryCodes] = Field(default=None, description="The issuing country of the document, a 3-letter ISO code.") applicant_id: Optional[StrictStr] = Field(default=None, description="The ID of the applicant whose document is being uploaded.") diff --git a/onfido/models/document_types.py b/onfido/models/document_types.py index d439311..5cf6ddf 100644 --- a/onfido/models/document_types.py +++ b/onfido/models/document_types.py @@ -51,6 +51,11 @@ class DocumentTypes(str, Enum): PROFESSIONAL_QUALIFICATION_CARD = 'professional_qualification_card' CONSULAR_ID = 'consular_id' INTERNATIONAL_DRIVING_LICENCE = 'international_driving_licence' + HOME_OFFICE_LETTER = 'home_office_letter' + BIRTH_CERTIFICATE = 'birth_certificate' + VEHICLE_REGISTRATION_CERTIFICATE = 'vehicle_registration_certificate' + FORM_FOR_AFFIXING_THE_VISA = 'form_for_affixing_the_visa' + IDENTIFICATION_NUMBER_DOCUMENT = 'identification_number_document' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/onfido/models/task_item.py b/onfido/models/task_item.py index c6503bd..fb7e9d7 100644 --- a/onfido/models/task_item.py +++ b/onfido/models/task_item.py @@ -18,7 +18,7 @@ import json from datetime import datetime -from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated from typing import Optional, Set @@ -29,11 +29,13 @@ class TaskItem(BaseModel): TaskItem """ # noqa: E501 id: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="The identifier for the Task.") + workflow_run_id: Optional[StrictStr] = Field(default=None, description="The workflow run id the task belongs to.") task_def_id: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="The identifier for the Task Definition.") + task_def_version: Optional[StrictStr] = Field(default=None, description="The task definition version.") created_at: Optional[datetime] = Field(default=None, description="The date and time when the Task was created.") updated_at: Optional[datetime] = Field(default=None, description="The date and time when the Task was last updated.") additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "task_def_id", "created_at", "updated_at"] + __properties: ClassVar[List[str]] = ["id", "workflow_run_id", "task_def_id", "task_def_version", "created_at", "updated_at"] @field_validator('id') def id_validate_regular_expression(cls, value): @@ -101,6 +103,11 @@ def to_dict(self) -> Dict[str, Any]: for _key, _value in self.additional_properties.items(): _dict[_key] = _value + # set to None if task_def_version (nullable) is None + # and model_fields_set contains the field + if self.task_def_version is None and "task_def_version" in self.model_fields_set: + _dict['task_def_version'] = None + return _dict @classmethod @@ -114,7 +121,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "id": obj.get("id"), + "workflow_run_id": obj.get("workflow_run_id"), "task_def_id": obj.get("task_def_id"), + "task_def_version": obj.get("task_def_version"), "created_at": obj.get("created_at"), "updated_at": obj.get("updated_at") }) diff --git a/onfido/models/webhook_event_object_status.py b/onfido/models/webhook_event_object_status.py new file mode 100644 index 0000000..31f52c0 --- /dev/null +++ b/onfido/models/webhook_event_object_status.py @@ -0,0 +1,54 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class WebhookEventObjectStatus(str, Enum): + """ + The current state of the object, if available. + """ + + """ + allowed enum values + """ + PROCESSING = 'processing' + AWAITING_INPUT = 'awaiting_input' + AWAITING_CLIENT_INPUT = 'awaiting_client_input' + APPROVED = 'approved' + DECLINED = 'declined' + REVIEW = 'review' + ABANDONED = 'abandoned' + ERROR = 'error' + STARTED = 'started' + CANCELLED = 'cancelled' + COMPLETED = 'completed' + AWAITING_DATA = 'awaiting_data' + AWAITING_APPROVAL = 'awaiting_approval' + COMPLETE = 'complete' + WITHDRAWN = 'withdrawn' + IN_PROGRESS = 'in_progress' + AWAITING_APPLICANT = 'awaiting_applicant' + PAUSED = 'paused' + REOPENED = 'reopened' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of WebhookEventObjectStatus from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/onfido/models/webhook_event_payload.py b/onfido/models/webhook_event_payload.py index 74eb6d1..036fe16 100644 --- a/onfido/models/webhook_event_payload.py +++ b/onfido/models/webhook_event_payload.py @@ -17,9 +17,11 @@ 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 onfido.models.webhook_event_payload_object import WebhookEventPayloadObject +from onfido.models.webhook_event_payload_resource import WebhookEventPayloadResource +from onfido.models.webhook_event_resource_type import WebhookEventResourceType from onfido.models.webhook_event_type import WebhookEventType from typing import Optional, Set from typing_extensions import Self @@ -28,10 +30,10 @@ class WebhookEventPayload(BaseModel): """ WebhookEventPayload """ # noqa: E501 - resource_type: StrictStr = Field(description="Indicates the resource affected by this event.") + resource_type: WebhookEventResourceType = Field(description="Indicates the resource affected by this event.") action: Optional[WebhookEventType] = Field(default=None, description="The event that triggered this webhook.") object: Optional[WebhookEventPayloadObject] = None - resource: Optional[Dict[str, Any]] = Field(default=None, description="The resource affected by this event.") + resource: Optional[WebhookEventPayloadResource] = None additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["resource_type", "action", "object", "resource"] @@ -79,6 +81,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of object if self.object: _dict['object'] = self.object.to_dict() + # override the default output from pydantic by calling `to_dict()` of resource + if self.resource: + _dict['resource'] = self.resource.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(): @@ -99,7 +104,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "resource_type": obj.get("resource_type"), "action": obj.get("action"), "object": WebhookEventPayloadObject.from_dict(obj["object"]) if obj.get("object") is not None else None, - "resource": obj.get("resource") + "resource": WebhookEventPayloadResource.from_dict(obj["resource"]) if obj.get("resource") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/onfido/models/webhook_event_payload_object.py b/onfido/models/webhook_event_payload_object.py index b7b8bcd..570a7d2 100644 --- a/onfido/models/webhook_event_payload_object.py +++ b/onfido/models/webhook_event_payload_object.py @@ -20,6 +20,7 @@ from datetime import datetime from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional +from onfido.models.webhook_event_object_status import WebhookEventObjectStatus from typing import Optional, Set from typing_extensions import Self @@ -28,7 +29,7 @@ class WebhookEventPayloadObject(BaseModel): The object affected by this event. """ # noqa: E501 id: StrictStr = Field(description="The unique identifier of the resource.") - status: Optional[StrictStr] = Field(default=None, description="The current state of the object, if available.") + 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.") diff --git a/onfido/models/webhook_event_payload_resource.py b/onfido/models/webhook_event_payload_resource.py new file mode 100644 index 0000000..001710d --- /dev/null +++ b/onfido/models/webhook_event_payload_resource.py @@ -0,0 +1,158 @@ +# 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 datetime import datetime +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from onfido.models.workflow_run_error import WorkflowRunError +from onfido.models.workflow_run_link import WorkflowRunLink +from typing import Optional, Set +from typing_extensions import Self + +class WebhookEventPayloadResource(BaseModel): + """ + The resource affected by this event. + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="The identifier of the resource.") + applicant_id: Optional[StrictStr] = Field(default=None, description="The unique identifier for the Applicant.") + created_at: Optional[datetime] = Field(default=None, description="The date and time when the resource was created.") + updated_at: Optional[datetime] = Field(default=None, description="The date and time when the resource was last updated.") + dashboard_url: Optional[StrictStr] = Field(default=None, description="The URL for viewing the resource on Onfido Dashboard.") + workflow_id: Optional[StrictStr] = Field(default=None, description="The unique identifier for the Workflow.") + workflow_run_id: Optional[StrictStr] = None + workflow_version_id: Optional[StrictInt] = Field(default=None, description="The identifier for the Workflow version.") + task_def_id: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="The identifier for the Task Definition.") + task_def_version: Optional[StrictStr] = Field(default=None, description="The task definition version.") + input: Optional[Dict[str, Any]] = Field(default=None, description="Input object with the fields used by the Task execution.") + output: Optional[Dict[str, Any]] = Field(default=None, description="Output object with the fields produced by the Task execution.") + reasons: Optional[List[StrictStr]] = Field(default=None, description="The reasons the Workflow Run outcome was reached. Configurable when creating the Workflow Version.") + link: Optional[WorkflowRunLink] = Field(default=None, description="Object for the configuration of the Workflow Run link.") + error: Optional[WorkflowRunError] = Field(default=None, description="Error object that details why a Workflow Run is in Error status.") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "applicant_id", "created_at", "updated_at", "dashboard_url", "workflow_id", "workflow_run_id", "workflow_version_id", "task_def_id", "task_def_version", "input", "output", "reasons", "link", "error"] + + @field_validator('task_def_id') + def task_def_id_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^[0-9a-z_-]+$", value): + raise ValueError(r"must validate the regular expression /^[0-9a-z_-]+$/") + return value + + 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 WebhookEventPayloadResource 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 link + if self.link: + _dict['link'] = self.link.to_dict() + # override the default output from pydantic by calling `to_dict()` of error + if self.error: + _dict['error'] = self.error.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(): + _dict[_key] = _value + + # set to None if task_def_version (nullable) is None + # and model_fields_set contains the field + if self.task_def_version is None and "task_def_version" in self.model_fields_set: + _dict['task_def_version'] = None + + # set to None if output (nullable) is None + # and model_fields_set contains the field + if self.output is None and "output" in self.model_fields_set: + _dict['output'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WebhookEventPayloadResource from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "applicant_id": obj.get("applicant_id"), + "created_at": obj.get("created_at"), + "updated_at": obj.get("updated_at"), + "dashboard_url": obj.get("dashboard_url"), + "workflow_id": obj.get("workflow_id"), + "workflow_run_id": obj.get("workflow_run_id"), + "workflow_version_id": obj.get("workflow_version_id"), + "task_def_id": obj.get("task_def_id"), + "task_def_version": obj.get("task_def_version"), + "input": obj.get("input"), + "output": obj.get("output"), + "reasons": obj.get("reasons"), + "link": WorkflowRunLink.from_dict(obj["link"]) if obj.get("link") is not None else None, + "error": WorkflowRunError.from_dict(obj["error"]) if obj.get("error") 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/webhook_event_resource_type.py b/onfido/models/webhook_event_resource_type.py new file mode 100644 index 0000000..c3ef342 --- /dev/null +++ b/onfido/models/webhook_event_resource_type.py @@ -0,0 +1,41 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class WebhookEventResourceType(str, Enum): + """ + WebhookEventResourceType + """ + + """ + allowed enum values + """ + CHECK = 'check' + REPORT = 'report' + AUDIT_LOG = 'audit_log' + WORKFLOW_RUN = 'workflow_run' + WORKFLOW_TASK = 'workflow_task' + WATCHLIST_MONITOR = 'watchlist_monitor' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of WebhookEventResourceType from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/onfido/models/workflow_run.py b/onfido/models/workflow_run.py index 5ee1df3..e96acbd 100644 --- a/onfido/models/workflow_run.py +++ b/onfido/models/workflow_run.py @@ -18,11 +18,12 @@ import json from datetime import datetime -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated -from onfido.models.workflow_run_response_error import WorkflowRunResponseError -from onfido.models.workflow_run_shared_link import WorkflowRunSharedLink +from onfido.models.workflow_run_error import WorkflowRunError +from onfido.models.workflow_run_link import WorkflowRunLink +from onfido.models.workflow_run_status import WorkflowRunStatus from typing import Optional, Set from typing_extensions import Self @@ -34,30 +35,20 @@ class WorkflowRun(BaseModel): workflow_id: StrictStr = Field(description="The unique identifier for the Workflow.") tags: Optional[Annotated[List[Annotated[str, Field(min_length=1, strict=True, max_length=128)]], Field(max_length=30)]] = Field(default=None, description="Tags or labels assigned to the workflow run.") customer_user_id: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field(default=None, description="Customer-provided user identifier.") - link: Optional[WorkflowRunSharedLink] = None + link: Optional[WorkflowRunLink] = Field(default=None, description="Object for the configuration of the Workflow Run link.") created_at: Optional[datetime] = Field(default=None, description="The date and time when the Workflow Run was created.") updated_at: Optional[datetime] = Field(default=None, description="The date and time when the Workflow Run was last updated.") id: StrictStr = Field(description="The unique identifier for the Workflow Run.") workflow_version_id: Optional[StrictInt] = Field(default=None, description="The identifier for the Workflow version.") dashboard_url: Optional[StrictStr] = Field(default=None, description="The URL for viewing the Workflow Run results on your Onfido Dashboard.") - status: Optional[StrictStr] = Field(default=None, description="The status of the Workflow Run.") + status: Optional[WorkflowRunStatus] = Field(default=None, description="The status of the Workflow Run.") output: Optional[Dict[str, Any]] = Field(default=None, description="Output object contains all of the properties configured on the Workflow version.") reasons: Optional[List[StrictStr]] = Field(default=None, description="The reasons the Workflow Run outcome was reached. Configurable when creating the Workflow version.") - error: Optional[WorkflowRunResponseError] = None + error: Optional[WorkflowRunError] = Field(default=None, description="Error object. Only set when the Workflow Run status is 'error'.") sdk_token: Optional[StrictStr] = Field(default=None, description="Client token to use when loading this workflow run in the Onfido SDK.") additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["applicant_id", "workflow_id", "tags", "customer_user_id", "link", "created_at", "updated_at", "id", "workflow_version_id", "dashboard_url", "status", "output", "reasons", "error", "sdk_token"] - @field_validator('status') - def status_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['awaiting_input', 'processing', 'abandoned', 'error', 'approved', 'review', 'declined']): - raise ValueError("must be one of enum values ('awaiting_input', 'processing', 'abandoned', 'error', 'approved', 'review', 'declined')") - return value - model_config = ConfigDict( populate_by_name=True, validate_assignment=True, @@ -136,7 +127,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "workflow_id": obj.get("workflow_id"), "tags": obj.get("tags"), "customer_user_id": obj.get("customer_user_id"), - "link": WorkflowRunSharedLink.from_dict(obj["link"]) if obj.get("link") is not None else None, + "link": WorkflowRunLink.from_dict(obj["link"]) if obj.get("link") is not None else None, "created_at": obj.get("created_at"), "updated_at": obj.get("updated_at"), "id": obj.get("id"), @@ -145,7 +136,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "status": obj.get("status"), "output": obj.get("output"), "reasons": obj.get("reasons"), - "error": WorkflowRunResponseError.from_dict(obj["error"]) if obj.get("error") is not None else None, + "error": WorkflowRunError.from_dict(obj["error"]) if obj.get("error") is not None else None, "sdk_token": obj.get("sdk_token") }) # store additional fields in additional_properties diff --git a/onfido/models/workflow_run_builder.py b/onfido/models/workflow_run_builder.py index 0a1a3f4..b0f71e1 100644 --- a/onfido/models/workflow_run_builder.py +++ b/onfido/models/workflow_run_builder.py @@ -21,7 +21,7 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated -from onfido.models.workflow_run_shared_link import WorkflowRunSharedLink +from onfido.models.workflow_run_link import WorkflowRunLink from typing import Optional, Set from typing_extensions import Self @@ -33,7 +33,7 @@ class WorkflowRunBuilder(BaseModel): workflow_id: StrictStr = Field(description="The unique identifier for the Workflow.") tags: Optional[Annotated[List[Annotated[str, Field(min_length=1, strict=True, max_length=128)]], Field(max_length=30)]] = Field(default=None, description="Tags or labels assigned to the workflow run.") customer_user_id: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field(default=None, description="Customer-provided user identifier.") - link: Optional[WorkflowRunSharedLink] = None + link: Optional[WorkflowRunLink] = Field(default=None, description="Object for the configuration of the Workflow Run link.") created_at: Optional[datetime] = Field(default=None, description="The date and time when the Workflow Run was created.") updated_at: Optional[datetime] = Field(default=None, description="The date and time when the Workflow Run was last updated.") custom_data: Optional[Dict[str, Any]] = Field(default=None, description="Object with Custom Input Data to be used in the Workflow Run.") @@ -110,7 +110,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "workflow_id": obj.get("workflow_id"), "tags": obj.get("tags"), "customer_user_id": obj.get("customer_user_id"), - "link": WorkflowRunSharedLink.from_dict(obj["link"]) if obj.get("link") is not None else None, + "link": WorkflowRunLink.from_dict(obj["link"]) if obj.get("link") is not None else None, "created_at": obj.get("created_at"), "updated_at": obj.get("updated_at"), "custom_data": obj.get("custom_data") diff --git a/onfido/models/workflow_run_response_error.py b/onfido/models/workflow_run_error.py similarity index 92% rename from onfido/models/workflow_run_response_error.py rename to onfido/models/workflow_run_error.py index bcedca0..62e9320 100644 --- a/onfido/models/workflow_run_response_error.py +++ b/onfido/models/workflow_run_error.py @@ -22,9 +22,9 @@ from typing import Optional, Set from typing_extensions import Self -class WorkflowRunResponseError(BaseModel): +class WorkflowRunError(BaseModel): """ - Error object. Only set when the Workflow Run status is 'error'. + WorkflowRunError """ # noqa: E501 type: Optional[StrictStr] = Field(default=None, description="The type of error.") message: Optional[StrictStr] = Field(default=None, description="A textual description of the error.") @@ -49,7 +49,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of WorkflowRunResponseError from a JSON string""" + """Create an instance of WorkflowRunError from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of WorkflowRunResponseError from a dict""" + """Create an instance of WorkflowRunError from a dict""" if obj is None: return None diff --git a/onfido/models/workflow_run_shared_link.py b/onfido/models/workflow_run_link.py similarity index 79% rename from onfido/models/workflow_run_shared_link.py rename to onfido/models/workflow_run_link.py index 4edcfd1..c7449a2 100644 --- a/onfido/models/workflow_run_shared_link.py +++ b/onfido/models/workflow_run_link.py @@ -23,9 +23,9 @@ from typing import Optional, Set from typing_extensions import Self -class WorkflowRunSharedLink(BaseModel): +class WorkflowRunLink(BaseModel): """ - Object for the configuration of the Workflow Run link. + WorkflowRunLink """ # noqa: E501 url: Optional[StrictStr] = Field(default=None, description="Link to access the Workflow Run without the need to integrate with Onfido's SDKs.") completed_redirect_url: Optional[StrictStr] = Field(default=None, description="When the interactive section of the Workflow Run has completed successfully, the user will be redirected to this URL instead of seeing the default Onfido 'thank you' page.") @@ -63,7 +63,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of WorkflowRunSharedLink from a JSON string""" + """Create an instance of WorkflowRunLink from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -91,11 +91,31 @@ def to_dict(self) -> Dict[str, Any]: for _key, _value in self.additional_properties.items(): _dict[_key] = _value + # set to None if completed_redirect_url (nullable) is None + # and model_fields_set contains the field + if self.completed_redirect_url is None and "completed_redirect_url" in self.model_fields_set: + _dict['completed_redirect_url'] = None + + # set to None if expired_redirect_url (nullable) is None + # and model_fields_set contains the field + if self.expired_redirect_url is None and "expired_redirect_url" in self.model_fields_set: + _dict['expired_redirect_url'] = None + + # set to None if expires_at (nullable) is None + # and model_fields_set contains the field + if self.expires_at is None and "expires_at" in self.model_fields_set: + _dict['expires_at'] = None + + # set to None if language (nullable) is None + # and model_fields_set contains the field + if self.language is None and "language" in self.model_fields_set: + _dict['language'] = None + return _dict @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of WorkflowRunSharedLink from a dict""" + """Create an instance of WorkflowRunLink from a dict""" if obj is None: return None diff --git a/onfido/models/workflow_run_response.py b/onfido/models/workflow_run_response.py index e31caa9..d4b571e 100644 --- a/onfido/models/workflow_run_response.py +++ b/onfido/models/workflow_run_response.py @@ -17,9 +17,10 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -from onfido.models.workflow_run_response_error import WorkflowRunResponseError +from onfido.models.workflow_run_error import WorkflowRunError +from onfido.models.workflow_run_status import WorkflowRunStatus from typing import Optional, Set from typing_extensions import Self @@ -30,24 +31,14 @@ class WorkflowRunResponse(BaseModel): id: StrictStr = Field(description="The unique identifier for the Workflow Run.") workflow_version_id: Optional[StrictInt] = Field(default=None, description="The identifier for the Workflow version.") dashboard_url: Optional[StrictStr] = Field(default=None, description="The URL for viewing the Workflow Run results on your Onfido Dashboard.") - status: Optional[StrictStr] = Field(default=None, description="The status of the Workflow Run.") + status: Optional[WorkflowRunStatus] = Field(default=None, description="The status of the Workflow Run.") output: Optional[Dict[str, Any]] = Field(default=None, description="Output object contains all of the properties configured on the Workflow version.") reasons: Optional[List[StrictStr]] = Field(default=None, description="The reasons the Workflow Run outcome was reached. Configurable when creating the Workflow version.") - error: Optional[WorkflowRunResponseError] = None + error: Optional[WorkflowRunError] = Field(default=None, description="Error object. Only set when the Workflow Run status is 'error'.") sdk_token: Optional[StrictStr] = Field(default=None, description="Client token to use when loading this workflow run in the Onfido SDK.") additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["id", "workflow_version_id", "dashboard_url", "status", "output", "reasons", "error", "sdk_token"] - @field_validator('status') - def status_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['awaiting_input', 'processing', 'abandoned', 'error', 'approved', 'review', 'declined']): - raise ValueError("must be one of enum values ('awaiting_input', 'processing', 'abandoned', 'error', 'approved', 'review', 'declined')") - return value - model_config = ConfigDict( populate_by_name=True, validate_assignment=True, @@ -120,7 +111,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "status": obj.get("status"), "output": obj.get("output"), "reasons": obj.get("reasons"), - "error": WorkflowRunResponseError.from_dict(obj["error"]) if obj.get("error") is not None else None, + "error": WorkflowRunError.from_dict(obj["error"]) if obj.get("error") is not None else None, "sdk_token": obj.get("sdk_token") }) # store additional fields in additional_properties diff --git a/onfido/models/workflow_run_shared.py b/onfido/models/workflow_run_shared.py index 36286cb..9f13895 100644 --- a/onfido/models/workflow_run_shared.py +++ b/onfido/models/workflow_run_shared.py @@ -21,7 +21,7 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated -from onfido.models.workflow_run_shared_link import WorkflowRunSharedLink +from onfido.models.workflow_run_link import WorkflowRunLink from typing import Optional, Set from typing_extensions import Self @@ -33,7 +33,7 @@ class WorkflowRunShared(BaseModel): workflow_id: StrictStr = Field(description="The unique identifier for the Workflow.") tags: Optional[Annotated[List[Annotated[str, Field(min_length=1, strict=True, max_length=128)]], Field(max_length=30)]] = Field(default=None, description="Tags or labels assigned to the workflow run.") customer_user_id: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field(default=None, description="Customer-provided user identifier.") - link: Optional[WorkflowRunSharedLink] = None + link: Optional[WorkflowRunLink] = Field(default=None, description="Object for the configuration of the Workflow Run link.") created_at: Optional[datetime] = Field(default=None, description="The date and time when the Workflow Run was created.") updated_at: Optional[datetime] = Field(default=None, description="The date and time when the Workflow Run was last updated.") additional_properties: Dict[str, Any] = {} @@ -109,7 +109,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "workflow_id": obj.get("workflow_id"), "tags": obj.get("tags"), "customer_user_id": obj.get("customer_user_id"), - "link": WorkflowRunSharedLink.from_dict(obj["link"]) if obj.get("link") is not None else None, + "link": WorkflowRunLink.from_dict(obj["link"]) if obj.get("link") is not None else None, "created_at": obj.get("created_at"), "updated_at": obj.get("updated_at") }) diff --git a/onfido/models/workflow_run_status.py b/onfido/models/workflow_run_status.py new file mode 100644 index 0000000..790ddd2 --- /dev/null +++ b/onfido/models/workflow_run_status.py @@ -0,0 +1,43 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class WorkflowRunStatus(str, Enum): + """ + WorkflowRunStatus + """ + + """ + allowed enum values + """ + PROCESSING = 'processing' + AWAITING_INPUT = 'awaiting_input' + AWAITING_CLIENT_INPUT = 'awaiting_client_input' + APPROVED = 'approved' + DECLINED = 'declined' + REVIEW = 'review' + ABANDONED = 'abandoned' + ERROR = 'error' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of WorkflowRunStatus from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/poetry.lock b/poetry.lock index c1e9677..5a6693a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -27,13 +27,13 @@ files = [ [[package]] name = "distlib" -version = "0.3.8" +version = "0.3.9" description = "Distribution utilities" optional = false python-versions = "*" files = [ - {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, - {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, + {file = "distlib-0.3.9-py2.py3-none-any.whl", hash = "sha256:47f8c22fd27c27e25a65601af709b38e4f0a45ea4fc2e710f65755fa8caaaf87"}, + {file = "distlib-0.3.9.tar.gz", hash = "sha256:a60f20dea646b8a33f3e7772f74dc0b2d0772d2837ee1342a00645c81edf9403"}, ] [[package]] diff --git a/tests/conftest.py b/tests/conftest.py index e1a34ee..ee04ef7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -60,7 +60,7 @@ def create_applicant(onfido_api, applicant_builder=None): def upload_document(onfido_api, applicant_id): return onfido_api.upload_document( applicant_id=applicant_id, - type="passport", + type=onfido.DocumentTypes.PASSPORT, side="front", file="tests/media/sample_driving_licence.png", ) @@ -93,6 +93,7 @@ def create_check( applicant_id=applicant_id, document_ids=document_ids, report_names=report_names, + privacy_notices_read_consent_given=True, ) ) @@ -142,13 +143,13 @@ def repeat_request_until_task_output_changes( instance = function(*params) iteration = 0 - while instance.output == None: + while instance.output is None: if iteration > max_retries: pytest.fail("Task output did not change in time") iteration += 1 sleep(sleep_time) - + instance = function(*params) return instance diff --git a/tests/test_applicants.py b/tests/test_applicants.py index 7c07610..d76b00d 100644 --- a/tests/test_applicants.py +++ b/tests/test_applicants.py @@ -26,6 +26,12 @@ def test_create_applicant(onfido_api): country=onfido.CountryCodes.FRA, line1="My wonderful address", ), + consents=[ + onfido.ApplicantConsentBuilder( + name=onfido.ApplicantConsentName.PRIVACY_NOTICES_READ, + granted=True + ) + ] ) applicant = create_applicant(onfido_api, applicant_builder) diff --git a/tests/test_checks.py b/tests/test_checks.py index 55553d9..d264cb6 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -1,5 +1,6 @@ import pytest -from onfido import Check, ChecksList, ReportName, CheckBuilder, UsDrivingLicenceBuilder +from onfido import (Check, ChecksList, ReportName, CheckBuilder, + UsDrivingLicenceBuilder, CheckStatus) from tests.conftest import create_applicant, create_check, upload_document @@ -28,7 +29,7 @@ def test_create_check(check, applicant_id): assert isinstance(check, Check) assert check.applicant_id == applicant_id assert len(check.report_ids) == 2 - assert check.status == "in_progress" + assert check.status == CheckStatus.IN_PROGRESS def test_create_consider_check(onfido_api, applicant_id, document_id): diff --git a/tests/test_webhook_verification.py b/tests/test_classic_webhook_event_verification.py similarity index 80% rename from tests/test_webhook_verification.py rename to tests/test_classic_webhook_event_verification.py index d11f5fc..b4d538a 100644 --- a/tests/test_webhook_verification.py +++ b/tests/test_classic_webhook_event_verification.py @@ -1,5 +1,8 @@ from onfido.webhook_event_verifier import WebhookEventVerifier, OnfidoInvalidSignatureError -from onfido import WebhookEvent, WebhookEventPayload, WebhookEventPayloadObject +from onfido import ( + WebhookEvent, WebhookEventPayload, WebhookEventPayloadObject, + WebhookEventResourceType, WebhookEventType, WebhookEventObjectStatus +) import pytest @@ -12,12 +15,12 @@ expected_event = WebhookEvent( payload=WebhookEventPayload( - action="check.completed", - resource_type="check", + action=WebhookEventType.CHECK_DOT_COMPLETED, + resource_type=WebhookEventResourceType.CHECK, object=WebhookEventPayloadObject( id='f2302f45-227d-413d-ad61-09ec077a086a', href='https://api.onfido.com/v3.6/checks/f2302f45-227d-413d-ad61-09ec077a086a', - status="complete", + status=WebhookEventObjectStatus.COMPLETE, completed_at_iso8601='2024-04-04T09:21:21Z' ) ) diff --git a/tests/test_documents.py b/tests/test_documents.py index 934102b..1696f87 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -1,6 +1,6 @@ import pytest -from onfido import ApiException, Document, DocumentsList +from onfido import ApiException, Document, DocumentsList, DocumentTypes from tests.conftest import create_applicant, upload_document @@ -17,7 +17,7 @@ def document(onfido_api, applicant_id): def test_create_document(applicant_id, document): assert document is not None assert document.applicant_id == applicant_id - assert document.type == "passport" + assert document.type == DocumentTypes.PASSPORT assert document.side == "front" assert isinstance(document, Document) diff --git a/tests/test_qualified_electronic_signatures.py b/tests/test_qualified_electronic_signatures.py index 44d9c85..5fad1fc 100644 --- a/tests/test_qualified_electronic_signatures.py +++ b/tests/test_qualified_electronic_signatures.py @@ -41,8 +41,7 @@ def workflow_run(onfido_api, applicant_id, workflow_id): @pytest.fixture(scope="function") def file_id(onfido_api, workflow_run): - - task = onfido_api.list_tasks(workflow_run.id)[0] + task = onfido_api.list_tasks(workflow_run.id)[1] output = repeat_request_until_task_output_changes( onfido_api.find_task, [workflow_run.id, task.id], max_retries=10, sleep_time=3 diff --git a/tests/test_studio_webhook_event_verification.py b/tests/test_studio_webhook_event_verification.py new file mode 100644 index 0000000..241e6da --- /dev/null +++ b/tests/test_studio_webhook_event_verification.py @@ -0,0 +1,63 @@ +from onfido.webhook_event_verifier import WebhookEventVerifier, OnfidoInvalidSignatureError +from onfido import ( + WebhookEvent, WebhookEventPayload, WebhookEventPayloadObject, + WebhookEventResourceType, WebhookEventType, WebhookEventObjectStatus, + WebhookEventPayloadResource +) + +import pytest + +raw_event = ("{\"payload\":{\"resource_type\":\"workflow_task\",\"action\":\"workflow_task.started\"," + "\"object\":{\"id\":\"profile_1eb92\",\"task_spec_id\":\"profile_1eb92\"," + "\"task_def_id\":\"profile_data\",\"workflow_run_id\":\"bc77c6e5-753a-4580-96a6-aaed3e5a8d19\"" + ",\"status\":\"started\",\"started_at_iso8601\":\"2024-07-10T12:49:09Z\"," + "\"href\":\"https://api.eu.onfido.com/v3.6/workflow_runs/" + "bc77c6e5-753a-4580-96a6-aaed3e5a8d19/tasks/profile_1eb92\"}," + "\"resource\":{\"created_at\":\"2024-07-10T12:49:09Z\",\"id\":""\"profile_1eb92\"," + "\"workflow_run_id\":\"bc77c6e5-753a-4580-96a6-aaed3e5a8d19\",\"updated_at\":\"2024-07-10T12:49:09Z\"" + ",\"input\":{},\"task_def_version\":null,\"task_def_id\":\"profile_data\",\"output\":null}}}") + +secret_token = "YKOC6mkBxi6yK2zlUIrLMvsJMFEZObP5" + +expected_event = WebhookEvent( + payload=WebhookEventPayload( + action=WebhookEventType.WORKFLOW_TASK_DOT_STARTED, + resource_type=WebhookEventResourceType.WORKFLOW_TASK, + object=WebhookEventPayloadObject( + id='profile_1eb92', + href='https://api.eu.onfido.com/v3.6/workflow_runs/bc77c6e5-753a-4580-96a6-aaed3e5a8d19/tasks/profile_1eb92', + status=WebhookEventObjectStatus.STARTED, + started_at_iso8601='2024-07-10T12:49:09Z', + task_def_id='profile_data', + task_spec_id='profile_1eb92', + workflow_run_id='bc77c6e5-753a-4580-96a6-aaed3e5a8d19' + ), + resource=WebhookEventPayloadResource( + created_at='2024-07-10T12:49:09Z', + id='profile_1eb92', + input={}, + output=None, + task_def_id='profile_data', + task_def_version=None, + updated_at='2024-07-10T12:49:09Z', + workflow_run_id='bc77c6e5-753a-4580-96a6-aaed3e5a8d19' + ) + ) +) + +verifier = WebhookEventVerifier(secret_token) + + +def test_webhook_verification(): + signature = "c95a5b785484f6fa1bc25f381b5595d66bf85cb442eefb06aa007802ee6a4dfa" + + event = verifier.read_payload(raw_event, signature) + event.payload.object.additional_properties = {} # Suppress any additional property in object + assert event == expected_event + + +def test_webhook_verification_invalid_signature(): + signature = "c95a5b785484f6fa1bc25f381b5595d66bf85cb442eefb06aa007802ee6a4dfb" + + with pytest.raises(OnfidoInvalidSignatureError): + verifier.read_payload(raw_event, signature) diff --git a/tests/test_workflow_runs.py b/tests/test_workflow_runs.py index d18334a..29403f5 100644 --- a/tests/test_workflow_runs.py +++ b/tests/test_workflow_runs.py @@ -1,6 +1,6 @@ import pytest -from onfido import TimelineFileReference, WorkflowRun, WorkflowRunBuilder +from onfido import TimelineFileReference, WorkflowRun, WorkflowRunBuilder, WorkflowRunStatus from tests.conftest import ( create_applicant, create_workflow_run, @@ -30,7 +30,7 @@ def test_create_workflow_run(workflow_run, workflow_id): assert workflow_run is not None assert isinstance(workflow_run, WorkflowRun) assert workflow_run.workflow_id == workflow_id - assert workflow_run.status == "awaiting_input" + assert workflow_run.status == WorkflowRunStatus.AWAITING_INPUT def test_create_workflow_run_with_custom_inputs(onfido_api, applicant_id): @@ -46,7 +46,7 @@ def test_create_workflow_run_with_custom_inputs(onfido_api, applicant_id): ) assert isinstance(workflow_run, WorkflowRun) assert workflow_run.workflow_id == workflow_id - assert workflow_run.status == "approved" + assert workflow_run.status == WorkflowRunStatus.APPROVED def test_list_workflow_runs(onfido_api): @@ -76,7 +76,7 @@ def test_generate_timeline_file(onfido_api, applicant_id): onfido_api, applicant_id=applicant_id, workflow_id=workflow_id ).id repeat_request_until_status_changes( - onfido_api.find_workflow_run, [workflow_run_id], "approved" + onfido_api.find_workflow_run, [workflow_run_id], WorkflowRunStatus.APPROVED ) workflow_timeline_file_data = onfido_api.create_timeline_file(workflow_run_id) @@ -92,7 +92,7 @@ def test_find_timeline_file(onfido_api, applicant_id): onfido_api, applicant_id=applicant_id, workflow_id=workflow_id ).id repeat_request_until_status_changes( - onfido_api.find_workflow_run, [workflow_run_id], "approved" + onfido_api.find_workflow_run, [workflow_run_id], WorkflowRunStatus.APPROVED ) timeline_file_id = onfido_api.create_timeline_file(