diff --git a/cuenca/__init__.py b/cuenca/__init__.py index 32950045..fa506d51 100644 --- a/cuenca/__init__.py +++ b/cuenca/__init__.py @@ -20,7 +20,6 @@ 'Identity', 'IdentityEvent', 'KYCValidation', - 'KYCVerification', 'LimitedWallet', 'LoginToken', 'Otp', @@ -68,7 +67,6 @@ IdentityEvent, JwtToken, KYCValidation, - KYCVerification, LimitedWallet, LoginToken, Otp, diff --git a/cuenca/resources/__init__.py b/cuenca/resources/__init__.py index 8daf3c7d..e74f07f9 100644 --- a/cuenca/resources/__init__.py +++ b/cuenca/resources/__init__.py @@ -19,7 +19,6 @@ 'Identity', 'IdentityEvent', 'KYCValidation', - 'KYCVerification', 'LimitedWallet', 'LoginToken', 'Otp', @@ -62,7 +61,6 @@ from .identity_events import IdentityEvent from .jwt_tokens import JwtToken from .kyc_validations import KYCValidation -from .kyc_verifications import KYCVerification from .limited_wallets import LimitedWallet from .login_tokens import LoginToken from .otps import Otp @@ -106,7 +104,6 @@ Identity, IdentityEvent, KYCValidation, - KYCVerification, LimitedWallet, LoginToken, Questionnaires, diff --git a/cuenca/resources/kyc_validations.py b/cuenca/resources/kyc_validations.py index c9ad95ea..9784c304 100644 --- a/cuenca/resources/kyc_validations.py +++ b/cuenca/resources/kyc_validations.py @@ -1,6 +1,6 @@ from typing import ClassVar, Optional -from cuenca_validations.types import KYCFile, KYCValidationRequest +from cuenca_validations.types import KYCValidationRequest, KYCValidationSource from pydantic import ConfigDict from ..http import Session, session as global_session @@ -10,19 +10,25 @@ class KYCValidation(Creatable, Retrievable, Queryable): _resource: ClassVar = 'kyc_validations' platform_id: str - attemps: Optional[int] = None - verification_id: Optional[str] = None + user_id: str + source_type: KYCValidationSource + flow_id: str files_uri: Optional[list[str]] = None + verification_id: Optional[str] = None + identity_id: Optional[str] = None model_config = ConfigDict( json_schema_extra={ 'example': { 'id': 'KVNEUInh69SuKXXmK95sROwQ', - 'platform_id': 'PT8UEv02zBTcymd4Kd3MO6pg', 'created_at': '2020-05-24T14:15:22Z', - 'verification_id': 'string', + 'platform_id': 'PT-1234567890', + 'user_id': 'US-1234567890', + 'source_type': 'server', + 'flow_id': '123e4567-e89b-12d3-a456-426614174000', 'files_uri': ['cuenca.com/files/id', 'cuenca.com/files/id2'], - 'attemps': '1', + 'verification_id': 'metamap-verification-id', + 'identity_id': 'metamap-identity-id', } } ) @@ -31,13 +37,13 @@ class KYCValidation(Creatable, Retrievable, Queryable): def create( cls, user_id: str, + source_type: KYCValidationSource, force: bool = False, - documents: list[KYCFile] = [], session: Session = global_session, ) -> 'KYCValidation': req = KYCValidationRequest( user_id=user_id, force=force, - documents=documents, + source_type=source_type, ) return cls._create(**req.model_dump(), session=session) diff --git a/cuenca/resources/kyc_verifications.py b/cuenca/resources/kyc_verifications.py deleted file mode 100644 index 13694135..00000000 --- a/cuenca/resources/kyc_verifications.py +++ /dev/null @@ -1,53 +0,0 @@ -import datetime as dt -from typing import ClassVar, Optional - -from cuenca_validations.types import ( - Address, - Curp, - KYCVerificationUpdateRequest, - Rfc, -) -from pydantic import ConfigDict - -from ..http import Session, session as global_session -from .base import Creatable, Retrievable, Updateable - - -class KYCVerification(Creatable, Retrievable, Updateable): - _resource: ClassVar = 'kyc_verifications' - - platform_id: str - created_at: dt.datetime - deactivated_at: Optional[dt.datetime] = None - verification_id: Optional[str] = None - curp: Optional[Curp] = None - rfc: Optional[Rfc] = None - address: Optional[Address] = None - - model_config = ConfigDict( - json_schema_extra={ - 'example': { - 'id': 'KVNEUInh69SuKXXmK95sROwQ', - 'updated_at': '2020-05-24T14:15:22Z', - 'platform_id': 'PT8UEv02zBTcymd4Kd3MO6pg', - 'created_at': '2020-05-24T14:15:22Z', - 'verification_id': 'string', - 'curp': 'GOCG650418HVZNML08', - 'rfc': 'GOCG650418123', - 'address': Address.schema().get('example'), - } - } - ) - - @classmethod - def create(cls, session: Session = global_session) -> 'KYCVerification': - return cls._create(session=session) - - @classmethod - def update( - cls, - kyc_id: str, - curp: Optional[Curp] = None, - ) -> 'KYCVerification': - req = KYCVerificationUpdateRequest(curp=curp) - return cls._update(id=kyc_id, **req.model_dump()) diff --git a/cuenca/version.py b/cuenca/version.py index 063421fa..679045d5 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '2.1.2' +__version__ = '2.1.3' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' diff --git a/requirements.txt b/requirements.txt index 190cc68d..50818af8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ requests==2.32.3 -cuenca-validations==2.1.0 +cuenca-validations==2.1.5 pydantic-extra-types==2.10.2 diff --git a/setup.py b/setup.py index 4ba3904e..b0379330 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ python_requires='>=3.9', install_requires=[ 'requests>=2.32.0', - 'cuenca-validations>=2.1.0', + 'cuenca-validations>=2.1.5', 'pydantic-extra-types>=2.10.0', ], classifiers=[ diff --git a/tests/resources/cassettes/test_kyc_verification_create.yaml b/tests/resources/cassettes/test_kyc_verification_create.yaml deleted file mode 100644 index 7766b183..00000000 --- a/tests/resources/cassettes/test_kyc_verification_create.yaml +++ /dev/null @@ -1,50 +0,0 @@ -interactions: -- request: - body: '{}' - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Authorization: - - DUMMY - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - cuenca-python/0.9.2 - X-Cuenca-Api-Version: - - '2020-03-19' - method: POST - uri: https://sandbox.cuenca.com/kyc_verifications - response: - body: - string: '{"id":"KYCY01","identity_id":null,"platform_id":"PT01","created_at":"2022-05-04T21:49:28.696688","updated_at":"2022-05-04T21:49:28.697159","deactivated_at":null,"verification_id":null,"curp":null,"rfc":null,"address":null}' - headers: - Connection: - - keep-alive - Content-Length: - - '246' - Content-Type: - - application/json - Date: - - Wed, 04 May 2022 21:49:28 GMT - x-amz-apigw-id: - - Rns0XHhNCYcFwdg= - x-amzn-Remapped-Connection: - - keep-alive - x-amzn-Remapped-Content-Length: - - '246' - x-amzn-Remapped-Date: - - Wed, 04 May 2022 21:49:28 GMT - x-amzn-Remapped-Server: - - nginx/1.20.2 - x-amzn-RequestId: - - d2c3bb25-34c1-4858-9de2-d1b4e60d2c81 - status: - code: 201 - message: Created -version: 1 diff --git a/tests/resources/cassettes/test_kyc_verification_retrieve.yaml b/tests/resources/cassettes/test_kyc_verification_retrieve.yaml deleted file mode 100644 index 426db1a8..00000000 --- a/tests/resources/cassettes/test_kyc_verification_retrieve.yaml +++ /dev/null @@ -1,46 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Authorization: - - DUMMY - Connection: - - keep-alive - User-Agent: - - cuenca-python/0.9.2 - X-Cuenca-Api-Version: - - '2020-03-19' - method: GET - uri: https://sandbox.cuenca.com/kyc_verifications/KYC01 - response: - body: - string: '{"id":"KYC01","identity_id":null,"platform_id":"PT01","created_at":"2022-05-04T21:27:15.954000","updated_at":"2022-05-04T21:27:15.954000","deactivated_at":null,"verification_id":null,"curp":null,"rfc":null,"address":null}' - headers: - Connection: - - keep-alive - Content-Length: - - '246' - Content-Type: - - application/json - Date: - - Wed, 04 May 2022 21:49:29 GMT - x-amz-apigw-id: - - Rns0cHpJiYcF_OQ= - x-amzn-Remapped-Connection: - - keep-alive - x-amzn-Remapped-Content-Length: - - '246' - x-amzn-Remapped-Date: - - Wed, 04 May 2022 21:49:29 GMT - x-amzn-Remapped-Server: - - nginx/1.20.2 - x-amzn-RequestId: - - 071182a0-b23e-47f0-bb92-68fdc35ec070 - status: - code: 200 - message: OK -version: 1 diff --git a/tests/resources/cassettes/test_kyc_verification_update.yaml b/tests/resources/cassettes/test_kyc_verification_update.yaml deleted file mode 100644 index 90f8d411..00000000 --- a/tests/resources/cassettes/test_kyc_verification_update.yaml +++ /dev/null @@ -1,50 +0,0 @@ -interactions: -- request: - body: '{"curp": "HEMA921130HNERNN05"}' - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Authorization: - - DUMMY - Connection: - - keep-alive - Content-Length: - - '30' - Content-Type: - - application/json - User-Agent: - - cuenca-python/0.9.3 - X-Cuenca-Api-Version: - - '2020-03-19' - method: PATCH - uri: https://sandbox.cuenca.com/kyc_verifications/KYC01 - response: - body: - string: '{"id":"KYC01","identity_id":null,"platform_id":"PTSFitwBYWROu-dAziDnSr4Q","created_at":"2022-05-10T17:37:34.755000","updated_at":"2022-05-10T17:42:25.137555","deactivated_at":null,"verification_id":null,"curp":"HEMA921130HNERNN05","rfc":null,"address":null}' - headers: - Connection: - - keep-alive - Content-Length: - - '277' - Content-Type: - - application/json - Date: - - Tue, 10 May 2022 17:42:25 GMT - x-amz-apigw-id: - - R66QMF9FCYcFtlA= - x-amzn-Remapped-Connection: - - keep-alive - x-amzn-Remapped-Content-Length: - - '277' - x-amzn-Remapped-Date: - - Tue, 10 May 2022 17:42:25 GMT - x-amzn-Remapped-Server: - - nginx/1.20.2 - x-amzn-RequestId: - - 47ab8674-5cc2-478b-8a73-5815cda6e4f3 - status: - code: 200 - message: OK -version: 1 diff --git a/tests/resources/cassettes/test_validation_create.yaml b/tests/resources/cassettes/test_validation_create.yaml index ac329105..f8a7bbed 100644 --- a/tests/resources/cassettes/test_validation_create.yaml +++ b/tests/resources/cassettes/test_validation_create.yaml @@ -1,51 +1,46 @@ interactions: - request: - body: '{"user_id": "USFOOBAR"}' + body: '{"user_id": "USze_Bh1zhROKehtBOS7EHlw", "source_type": "server", "force": + false}' headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate Authorization: - DUMMY - Connection: - - keep-alive Content-Length: - - '39' + - '80' Content-Type: - application/json User-Agent: - - cuenca-python/0.14.7.dev6 + - cuenca-python/2.1.3.dev2 X-Cuenca-Api-Version: - '2020-03-19' method: POST uri: https://sandbox.cuenca.com/kyc_validations response: body: - string: '{"id":"KVWZUhh-t_RUOPvU3hOnhbsQ","created_at":"2022-09-26T23:14:28.686030","verification_id":"6332324ca3b3cd001c6bcbf9","platform_id":"PTS7Wx1-1KRCKHQRWXsqxbMQ","user_id":"USOiwY3bhaRO-Or9koIBaehg","files_uri":["''https://sandbox.cuenca.com/files/EFfX_JE_wES3KA5cuR075rVA","https://sandbox.cuenca.com/files/EFWUXd3zl6Q6Gmd1tD2S65fw","https://sandbox.cuenca.com/files/EF2_YXyrMLSba7wpz-DQGgsw"]}' + string: '{"id":"KVvwIQTxHdQvOq769mEnoJsQ","created_at":"2025-03-27T20:10:03.783000","platform_id":"PTk5BbZcExRq-1u2W3J9mZpw","files_uri":["https://stage.cuenca.com/files/EF5pRc5dO4Q8WE6_zGCYUX6A","https://stage.cuenca.com/files/EF-y7kGVwlRESVGZOT-twioQ","https://stage.cuenca.com/files/EFB-J1hALOTPuuETDY5dtJJA","https://stage.cuenca.com/files/EFTrtO44_7QRiuRB8uXQizaw"],"user_id":"USze_Bh1zhROKehtBOS7EHlw","verification_id":"67e5b09c05c3102617d622b0","identity_id":"67e5b09c05c3101df5d622ad","source_type":"server","flow_id":"63486ce1e94af4001c126ccf"}' headers: Connection: - keep-alive Content-Length: - - '393' + - '545' Content-Type: - application/json Date: - - Mon, 26 Sep 2022 23:14:28 GMT + - Thu, 27 Mar 2025 20:41:36 GMT X-Request-Time: - - 'value: 27.792' + - 'value: 0.544' x-amz-apigw-id: - - ZFzI7GHfoAMF4jQ= + - IGmwBF8BiYcEFLA= x-amzn-Remapped-Connection: - keep-alive x-amzn-Remapped-Content-Length: - - '393' + - '545' x-amzn-Remapped-Date: - - Mon, 26 Sep 2022 23:14:28 GMT + - Thu, 27 Mar 2025 20:41:36 GMT x-amzn-Remapped-Server: - - nginx/1.22.0 + - nginx/1.26.3 x-amzn-RequestId: - - 310039b7-a7dd-4980-bb0b-b5552c602d26 + - 4fd4b9c9-08cf-44bb-b191-b8f18f10004c status: code: 201 message: Created diff --git a/tests/resources/cassettes/test_validation_retrieve.yaml b/tests/resources/cassettes/test_validation_retrieve.yaml index 4860b738..a46c7a2f 100644 --- a/tests/resources/cassettes/test_validation_retrieve.yaml +++ b/tests/resources/cassettes/test_validation_retrieve.yaml @@ -2,46 +2,42 @@ interactions: - request: body: null headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate Authorization: - DUMMY Connection: - keep-alive User-Agent: - - cuenca-python/0.14.7.dev6 + - cuenca-python/2.1.3.dev2 X-Cuenca-Api-Version: - '2020-03-19' method: GET uri: https://sandbox.cuenca.com/kyc_validations/KVFOO response: body: - string: '{"id":"KVWZUhh-t_RUOPvU3hOnhbsQ","platform_id":"PTS7Wx1-1KRCKHQRWXsqxbMQ","created_at":"2022-09-26T23:14:28.686000","verification_id":"6332324ca3b3cd001c6bcbf9","govt_id":null,"proof_of_address":null,"proof_of_life":null}' + string: '{"id":"KVvwIQTxHdQvOq769mEnoJsQ","created_at":"2025-03-27T20:10:03.783000","platform_id":"PTk5BbZcExRq-1u2W3J9mZpw","files_uri":["https://stage.cuenca.com/files/EF5pRc5dO4Q8WE6_zGCYUX6A","https://stage.cuenca.com/files/EF-y7kGVwlRESVGZOT-twioQ","https://stage.cuenca.com/files/EFB-J1hALOTPuuETDY5dtJJA","https://stage.cuenca.com/files/EFTrtO44_7QRiuRB8uXQizaw"],"user_id":"USze_Bh1zhROKehtBOS7EHlw","verification_id":"67e5b09c05c3102617d622b0","identity_id":"67e5b09c05c3101df5d622ad","source_type":"server","flow_id":"63486ce1e94af4001c126ccf"}' headers: Connection: - keep-alive Content-Length: - - '221' + - '545' Content-Type: - application/json Date: - - Mon, 26 Sep 2022 23:15:11 GMT + - Thu, 27 Mar 2025 20:41:36 GMT X-Request-Time: - - 'value: 0.074' + - 'value: 0.544' x-amz-apigw-id: - - ZFzT4HnLIAMFe1w= + - IGmwBF8BiYcEFLA= x-amzn-Remapped-Connection: - keep-alive x-amzn-Remapped-Content-Length: - - '221' + - '545' x-amzn-Remapped-Date: - - Mon, 26 Sep 2022 23:15:11 GMT + - Thu, 27 Mar 2025 20:41:36 GMT x-amzn-Remapped-Server: - - nginx/1.22.0 + - nginx/1.26.3 x-amzn-RequestId: - - 54f8a828-94f3-4303-8c95-95e22472cbab + - 4fd4b9c9-08cf-44bb-b191-b8f18f10004c status: code: 200 message: OK diff --git a/tests/resources/test_kyc_validations.py b/tests/resources/test_kyc_validations.py index 00e9e660..d73b7432 100644 --- a/tests/resources/test_kyc_validations.py +++ b/tests/resources/test_kyc_validations.py @@ -1,11 +1,15 @@ import pytest +from cuenca_validations.types import KYCValidationSource from cuenca import KYCValidation @pytest.mark.vcr def test_validation_create(): - kyc_validation: KYCValidation = KYCValidation.create(user_id="USFOOBAR") + kyc_validation: KYCValidation = KYCValidation.create( + user_id="USFOOBAR", + source_type=KYCValidationSource.server, + ) assert kyc_validation.id assert kyc_validation.verification_id diff --git a/tests/resources/test_kyc_verifications.py b/tests/resources/test_kyc_verifications.py deleted file mode 100644 index 49961074..00000000 --- a/tests/resources/test_kyc_verifications.py +++ /dev/null @@ -1,25 +0,0 @@ -import pytest - -from cuenca import KYCVerification - - -@pytest.mark.vcr -def test_kyc_verification_create(): - kyc_verification: KYCVerification = KYCVerification.create() - assert kyc_verification.id - - -@pytest.mark.vcr -def test_kyc_verification_retrieve(): - kyc_verification = KYCVerification.retrieve('KYC01') - assert kyc_verification.id - - -@pytest.mark.vcr -def test_kyc_verification_update(): - kyc_id = 'KYC01' - changes = dict(curp='HEMA921130HNERNN05') - kyc_verification = KYCVerification.update(kyc_id, **changes) - assert all( - item in kyc_verification.to_dict().items() for item in changes.items() - )