From 0c3116692d0577921a44867c303467429eda93cd Mon Sep 17 00:00:00 2001 From: gabino Date: Tue, 15 Jul 2025 16:33:41 -0600 Subject: [PATCH 1/9] Refactor Verification class to remove platform_id parameter --- cuenca/resources/verifications.py | 5 +--- cuenca/version.py | 2 +- requirements.txt | 2 +- .../test_verification_email_create.yaml | 29 ++++++------------- .../test_verification_phone_create.yaml | 29 ++++++------------- tests/resources/test_users.py | 1 - tests/resources/test_verifications.py | 2 -- 7 files changed, 21 insertions(+), 49 deletions(-) diff --git a/cuenca/resources/verifications.py b/cuenca/resources/verifications.py index ca34707d..cf7a0214 100644 --- a/cuenca/resources/verifications.py +++ b/cuenca/resources/verifications.py @@ -39,12 +39,9 @@ def create( cls, recipient: str, type: VerificationType, - platform_id: str, session: Session = global_session, ) -> 'Verification': - req = VerificationRequest( - recipient=recipient, type=type, platform_id=platform_id - ) + req = VerificationRequest(recipient=recipient, type=type) return cls._create(**req.model_dump(), session=session) @classmethod diff --git a/cuenca/version.py b/cuenca/version.py index 8c121fec..2a9e8176 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '2.1.5' +__version__ = '2.1.6.dev1' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' diff --git a/requirements.txt b/requirements.txt index b2c46c75..a34ae772 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ requests==2.32.3 -cuenca-validations==2.1.8 +cuenca-validations==2.1.10 pydantic-extra-types==2.10.2 diff --git a/tests/resources/cassettes/test_verification_email_create.yaml b/tests/resources/cassettes/test_verification_email_create.yaml index 0eb28d21..17b75e93 100644 --- a/tests/resources/cassettes/test_verification_email_create.yaml +++ b/tests/resources/cassettes/test_verification_email_create.yaml @@ -1,29 +1,20 @@ interactions: - request: - body: '{"type": "email", "sender": "mail@cuenca.com", "platform_id": - "PL01"}' + body: '{"type": "email", "recipient": "mail@cuenca.com"}' headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Authorization: - - DUMMY - Connection: - - keep-alive Content-Length: - - '82' + - '49' Content-Type: - application/json User-Agent: - - cuenca-python/0.8.0.dev0 + - cuenca-python/2.1.5 X-Cuenca-Api-Version: - '2020-03-19' method: POST uri: https://sandbox.cuenca.com/verifications response: body: - string: '{"id":"VE01","recipient":"mail@cuenca.com","platform_id":"PL01","api_key":null,"type":"email","created_at":"2022-03-16T22:33:21.930707","updated_at":"2022-03-16T22:33:21.931013","deactivated_at":null}' + string: '{"id":"VEG30ywu-KQnWdel9gpz1a-Q","identity_id":null,"platform_id":"PTZbBlk__kQt-wfwzP5nwA9A","created_at":"2025-07-15T22:28:11.987007","updated_at":"2025-07-15T22:28:11.987284","deactivated_at":null,"recipient":"mail@cuenca.com","language":"en","type":"email"}' headers: Connection: - keep-alive @@ -32,21 +23,19 @@ interactions: Content-Type: - application/json Date: - - Wed, 16 Mar 2022 22:33:22 GMT - X-Request-Time: - - 'value: 0.323' + - Tue, 15 Jul 2025 22:28:12 GMT x-amz-apigw-id: - - PGTTzHY-iYcF1zQ= + - NxZfaEnciYcEr9g= x-amzn-Remapped-Connection: - keep-alive x-amzn-Remapped-Content-Length: - '260' x-amzn-Remapped-Date: - - Wed, 16 Mar 2022 22:33:22 GMT + - Tue, 15 Jul 2025 22:28:12 GMT x-amzn-Remapped-Server: - - nginx/1.20.2 + - nginx/1.28.0 x-amzn-RequestId: - - 1403b526-7466-4985-bf8a-b8e6c156e527 + - 2fe363d1-fc8d-4fd5-ba59-e41a88c08711 status: code: 201 message: Created diff --git a/tests/resources/cassettes/test_verification_phone_create.yaml b/tests/resources/cassettes/test_verification_phone_create.yaml index 56849b98..5e5cdd37 100644 --- a/tests/resources/cassettes/test_verification_phone_create.yaml +++ b/tests/resources/cassettes/test_verification_phone_create.yaml @@ -1,29 +1,20 @@ interactions: - request: - body: '{"type": "phone", "sender": "+525555555555", "platform_id": - "PL01"}' + body: '{"type": "phone", "recipient": "+525555555555"}' headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Authorization: - - DUMMY - Connection: - - keep-alive Content-Length: - - '80' + - '47' Content-Type: - application/json User-Agent: - - cuenca-python/0.8.0.dev0 + - cuenca-python/2.1.5 X-Cuenca-Api-Version: - '2020-03-19' method: POST uri: https://sandbox.cuenca.com/verifications response: body: - string: '{"id":"VE02","recipient":"+525555555555","platform_id":"PL01","api_key":null,"type":"phone","created_at":"2022-03-16T22:33:22.657205","updated_at":"2022-03-16T22:33:22.657613","deactivated_at":null}' + string: '{"id":"VEPsf1IUMGT-C0bSFIvPZ17Q","identity_id":null,"platform_id":"PTZbBlk__kQt-wfwzP5nwA9A","created_at":"2025-07-15T22:31:24.231812","updated_at":"2025-07-15T22:31:24.232089","deactivated_at":null,"recipient":"+525555555555","language":"en","type":"phone"}' headers: Connection: - keep-alive @@ -32,21 +23,19 @@ interactions: Content-Type: - application/json Date: - - Wed, 16 Mar 2022 22:33:22 GMT - X-Request-Time: - - 'value: 0.285' + - Tue, 15 Jul 2025 22:31:24 GMT x-amz-apigw-id: - - PGTT7EO2CYcFQ_w= + - NxZ9dHQeiYcEYyw= x-amzn-Remapped-Connection: - keep-alive x-amzn-Remapped-Content-Length: - '258' x-amzn-Remapped-Date: - - Wed, 16 Mar 2022 22:33:22 GMT + - Tue, 15 Jul 2025 22:31:24 GMT x-amzn-Remapped-Server: - - nginx/1.20.2 + - nginx/1.28.0 x-amzn-RequestId: - - 7be1235d-09b6-4bc2-b1d9-93b96ac66519 + - 742a0869-1f8f-487e-9e8c-bed92bb9a923 status: code: 201 message: Created diff --git a/tests/resources/test_users.py b/tests/resources/test_users.py index c8746e1e..2df4ba45 100644 --- a/tests/resources/test_users.py +++ b/tests/resources/test_users.py @@ -83,7 +83,6 @@ def test_user_update_user_email_from_verification(): ver = Verification.create( recipient='mail@cuenca.com', type=VerificationType.email, - platform_id='PL01', ) user = User.update(user_id, email_verification_id=ver.id) assert user.to_dict()['email_address'] == ver.recipient diff --git a/tests/resources/test_verifications.py b/tests/resources/test_verifications.py index 11fb6226..03a7895a 100644 --- a/tests/resources/test_verifications.py +++ b/tests/resources/test_verifications.py @@ -10,7 +10,6 @@ def test_verification_email_create(): verification: Verification = Verification.create( recipient='mail@cuenca.com', type=VerificationType.email, - platform_id='PL01', ) assert verification.id @@ -20,7 +19,6 @@ def test_verification_phone_create(): verification: Verification = Verification.create( recipient='+525555555555', type=VerificationType.phone, - platform_id='PL01', ) assert verification.id From fa647e0c0737b24ba25fd9b6ba6fd8fa4ae087cc Mon Sep 17 00:00:00 2001 From: gabino Date: Tue, 15 Jul 2025 18:29:37 -0600 Subject: [PATCH 2/9] Modify TermsOfService class --- cuenca/resources/terms_of_service.py | 4 +--- cuenca/version.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cuenca/resources/terms_of_service.py b/cuenca/resources/terms_of_service.py index c73bc696..03db46d5 100644 --- a/cuenca/resources/terms_of_service.py +++ b/cuenca/resources/terms_of_service.py @@ -2,7 +2,6 @@ from typing import ClassVar from cuenca_validations.types import TermsOfService as TermsOfServiceEnum -from cuenca_validations.types.general import SerializableHttpUrl from .base import Queryable, Retrievable @@ -11,8 +10,7 @@ class TermsOfService(Retrievable, Queryable): _resource: ClassVar = 'terms_of_service' id: str - is_active: bool created_at: dt.datetime + deactivated_at: dt.datetime | None type: TermsOfServiceEnum version: str - uri: SerializableHttpUrl diff --git a/cuenca/version.py b/cuenca/version.py index 2a9e8176..bc21c8e5 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '2.1.6.dev1' +__version__ = '2.1.6.dev2' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' From af1c2759d02b5e7f48bbb1074c65f46ea8d9c7ec Mon Sep 17 00:00:00 2001 From: gabino Date: Wed, 16 Jul 2025 12:01:37 -0600 Subject: [PATCH 3/9] Modify TermsOfService class to use Optional for deactivated_at attribute --- cuenca/resources/terms_of_service.py | 3 ++- cuenca/version.py | 2 +- requirements.txt | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cuenca/resources/terms_of_service.py b/cuenca/resources/terms_of_service.py index 03db46d5..a8f27384 100644 --- a/cuenca/resources/terms_of_service.py +++ b/cuenca/resources/terms_of_service.py @@ -4,6 +4,7 @@ from cuenca_validations.types import TermsOfService as TermsOfServiceEnum from .base import Queryable, Retrievable +from typing import Optional class TermsOfService(Retrievable, Queryable): @@ -11,6 +12,6 @@ class TermsOfService(Retrievable, Queryable): id: str created_at: dt.datetime - deactivated_at: dt.datetime | None + deactivated_at: Optional[dt.datetime] = None type: TermsOfServiceEnum version: str diff --git a/cuenca/version.py b/cuenca/version.py index bc21c8e5..5c5f0d01 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '2.1.6.dev2' +__version__ = '2.1.6.dev3' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' diff --git a/requirements.txt b/requirements.txt index a34ae772..247be4b6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ requests==2.32.3 -cuenca-validations==2.1.10 +cuenca-validations==2.1.11.dev1 pydantic-extra-types==2.10.2 From ee639f35c04b492c72ce988fe120676910f1d1ce Mon Sep 17 00:00:00 2001 From: gabino Date: Wed, 16 Jul 2025 12:01:59 -0600 Subject: [PATCH 4/9] Lint --- cuenca/resources/terms_of_service.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cuenca/resources/terms_of_service.py b/cuenca/resources/terms_of_service.py index a8f27384..a7355f47 100644 --- a/cuenca/resources/terms_of_service.py +++ b/cuenca/resources/terms_of_service.py @@ -1,10 +1,9 @@ import datetime as dt -from typing import ClassVar +from typing import ClassVar, Optional from cuenca_validations.types import TermsOfService as TermsOfServiceEnum from .base import Queryable, Retrievable -from typing import Optional class TermsOfService(Retrievable, Queryable): From 015c6bc9bcb056b5a4394190bc4624465065b16e Mon Sep 17 00:00:00 2001 From: gabino Date: Wed, 16 Jul 2025 15:45:37 -0600 Subject: [PATCH 5/9] Add create class method for instantiating UserTOSAgreement with a signature image URL --- cuenca/resources/users_tos_agreements.py | 32 +++++++++++-- .../test_user_tos_agreements_create.yaml | 47 +++++++++++++++++++ tests/resources/test_users_tos_agreements.py | 12 +++++ 3 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 tests/resources/cassettes/test_user_tos_agreements_create.yaml create mode 100644 tests/resources/test_users_tos_agreements.py diff --git a/cuenca/resources/users_tos_agreements.py b/cuenca/resources/users_tos_agreements.py index 05ea588a..904e1d59 100644 --- a/cuenca/resources/users_tos_agreements.py +++ b/cuenca/resources/users_tos_agreements.py @@ -1,8 +1,13 @@ import datetime as dt -from typing import ClassVar +from typing import ClassVar, Optional from cuenca_validations.types.general import SerializableHttpUrl +from cuenca_validations.types.requests import ( + FileCuencaUrl, + UserTOSAgreementRequest, +) +from ..http import Session, session as global_session from .base import Creatable, Queryable, Retrievable @@ -12,10 +17,27 @@ class UserTOSAgreement(Creatable, Retrievable, Queryable): id: str created_at: dt.datetime updated_at: dt.datetime - terms_of_service: str + terms_of_service_uri: str user_id: str ip: str location: str - digital_signature: str - signed_document_url: SerializableHttpUrl - notification_id: str + digital_signature: Optional[str] = None + signature_image_url: Optional[FileCuencaUrl] = None + signed_document_url: Optional[SerializableHttpUrl] = None + notification_id: Optional[str] = None + + @classmethod + def create( + cls, + location: str, + tos_id: str, + signature_image_url: Optional[FileCuencaUrl] = None, + *, + session: Session = global_session, + ) -> 'UserTOSAgreement': + req = UserTOSAgreementRequest( + location=location, + tos_id=tos_id, + signature_image_url=signature_image_url, + ) + return cls._create(session=session, **req.model_dump()) diff --git a/tests/resources/cassettes/test_user_tos_agreements_create.yaml b/tests/resources/cassettes/test_user_tos_agreements_create.yaml new file mode 100644 index 00000000..bd7946a8 --- /dev/null +++ b/tests/resources/cassettes/test_user_tos_agreements_create.yaml @@ -0,0 +1,47 @@ +interactions: +- request: + body: '{"tos_id": "TS67f5bf03c1fc891bdf36090d", "location": {"latitude": 9.3953792, + "longitude": -99.139584}, "signature_image_url": null}' + headers: + Authorization: + - DUMMY + Content-Length: + - '131' + Content-Type: + - application/json + User-Agent: + - cuenca-python/2.1.6.dev3 + X-Cuenca-Api-Version: + - '2020-03-19' + method: POST + uri: https://sandbox.cuenca.com/users_tos_agreements + response: + body: + string: '{"id":"UAlyeG0IgKSFi3ZZ2NPKjk3g","created_at":"2025-07-16T21:43:54.817163","updated_at":"2025-07-16T21:43:54.817510","user_id":"USS2gTzkh_Sm2ZPZGtfNOK_Q","terms_of_service_uri":"/terms_of_service/TS67f5bf03c1fc891bdf36090d","ip":"201.141.55.234","location":"9.3953792,-99.139584","signature_image_url":null,"digital_signature":null,"signed_document_url":null,"notification_id":null}' + headers: + Connection: + - keep-alive + Content-Length: + - '382' + Content-Type: + - application/json + Date: + - Wed, 16 Jul 2025 21:43:55 GMT + X-Request-Time: + - 'value: 0.827' + x-amz-apigw-id: + - N0l8OEVHiYcEBdA= + x-amzn-Remapped-Connection: + - keep-alive + x-amzn-Remapped-Content-Length: + - '382' + x-amzn-Remapped-Date: + - Wed, 16 Jul 2025 21:43:55 GMT + x-amzn-Remapped-Server: + - nginx/1.28.0 + x-amzn-RequestId: + - 7e9162b9-6ea8-4592-b28a-502ef7a89345 + status: + code: 201 + message: Created +version: 1 diff --git a/tests/resources/test_users_tos_agreements.py b/tests/resources/test_users_tos_agreements.py new file mode 100644 index 00000000..36ff02a2 --- /dev/null +++ b/tests/resources/test_users_tos_agreements.py @@ -0,0 +1,12 @@ +import pytest + +from cuenca.resources import UserTOSAgreement + + +@pytest.mark.vcr +def test_user_tos_agreements_create(): + tos = UserTOSAgreement.create( + location=dict(latitude=9.3953792, longitude=-99.139584), + tos_id="TS67f5bf03c1fc891bdf36090d", + ) + assert tos.id From 77d1d74a544834b521414ec402be2c6a3666619a Mon Sep 17 00:00:00 2001 From: gabino Date: Wed, 16 Jul 2025 15:45:50 -0600 Subject: [PATCH 6/9] Bump version to 2.1.6.dev4 --- cuenca/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuenca/version.py b/cuenca/version.py index 5c5f0d01..6e42f010 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '2.1.6.dev3' +__version__ = '2.1.6.dev4' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' From 7f95e7744e1f2a654049fb5497dcc532fc2d1797 Mon Sep 17 00:00:00 2001 From: gabino Date: Wed, 16 Jul 2025 17:10:44 -0600 Subject: [PATCH 7/9] Update test_user_tos_agreements to use string format for location coordinates --- tests/resources/test_users_tos_agreements.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resources/test_users_tos_agreements.py b/tests/resources/test_users_tos_agreements.py index 36ff02a2..5f73b464 100644 --- a/tests/resources/test_users_tos_agreements.py +++ b/tests/resources/test_users_tos_agreements.py @@ -6,7 +6,7 @@ @pytest.mark.vcr def test_user_tos_agreements_create(): tos = UserTOSAgreement.create( - location=dict(latitude=9.3953792, longitude=-99.139584), + location="9.3953792,-99.139584", tos_id="TS67f5bf03c1fc891bdf36090d", ) assert tos.id From cfd67f3bd6ded3ff6aeee86bf04ed2762dbb6bc5 Mon Sep 17 00:00:00 2001 From: gabino Date: Wed, 16 Jul 2025 17:23:37 -0600 Subject: [PATCH 8/9] Update cuenca-validations to version 2.1.11 and set package version to 2.1.6 --- cuenca/version.py | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cuenca/version.py b/cuenca/version.py index 6e42f010..a6cf70fb 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '2.1.6.dev4' +__version__ = '2.1.6' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' diff --git a/requirements.txt b/requirements.txt index 247be4b6..c6f3d6a4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ requests==2.32.3 -cuenca-validations==2.1.11.dev1 +cuenca-validations==2.1.11 pydantic-extra-types==2.10.2 From 62369a914b1e7631c79a215719e0ea4e69b15b77 Mon Sep 17 00:00:00 2001 From: gabino Date: Wed, 16 Jul 2025 17:25:48 -0600 Subject: [PATCH 9/9] Update test_user_tos_agreements_create function signature to include return type annotation --- tests/resources/test_users_tos_agreements.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resources/test_users_tos_agreements.py b/tests/resources/test_users_tos_agreements.py index 5f73b464..93a41caa 100644 --- a/tests/resources/test_users_tos_agreements.py +++ b/tests/resources/test_users_tos_agreements.py @@ -4,7 +4,7 @@ @pytest.mark.vcr -def test_user_tos_agreements_create(): +def test_user_tos_agreements_create() -> None: tos = UserTOSAgreement.create( location="9.3953792,-99.139584", tos_id="TS67f5bf03c1fc891bdf36090d",