From ea313444f25d1043bf9584bf1ad7f33dd5cc171d Mon Sep 17 00:00:00 2001 From: gabino Date: Thu, 17 Jul 2025 12:36:50 -0600 Subject: [PATCH 1/6] Add ExistPhone resource --- cuenca/__init__.py | 2 + cuenca/resources/__init__.py | 2 + cuenca/resources/exist_phone.py | 12 ++++++ cuenca/version.py | 2 +- .../cassettes/test_exist_phone_retrieve.yaml | 40 +++++++++++++++++++ tests/resources/test_exist_phone.py | 11 +++++ 6 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 cuenca/resources/exist_phone.py create mode 100644 tests/resources/cassettes/test_exist_phone_retrieve.yaml create mode 100644 tests/resources/test_exist_phone.py diff --git a/cuenca/__init__.py b/cuenca/__init__.py index 40533eaf..9592231d 100644 --- a/cuenca/__init__.py +++ b/cuenca/__init__.py @@ -45,6 +45,7 @@ 'TermsOfService', 'UserTOSAgreement', 'PostalCodes', + 'ExistPhone', ] from . import http @@ -64,6 +65,7 @@ CurpValidation, Deposit, Endpoint, + ExistPhone, File, FileBatch, Identity, diff --git a/cuenca/resources/__init__.py b/cuenca/resources/__init__.py index b61650c0..12a19fb0 100644 --- a/cuenca/resources/__init__.py +++ b/cuenca/resources/__init__.py @@ -16,6 +16,7 @@ 'Endpoint', 'File', 'FileBatch', + 'ExistPhone', 'Identity', 'IdentityEvent', 'KYCValidation', @@ -58,6 +59,7 @@ from .curp_validations import CurpValidation from .deposits import Deposit from .endpoints import Endpoint +from .exist_phone import ExistPhone from .file_batches import FileBatch from .files import File from .identities import Identity diff --git a/cuenca/resources/exist_phone.py b/cuenca/resources/exist_phone.py new file mode 100644 index 00000000..0ad2693e --- /dev/null +++ b/cuenca/resources/exist_phone.py @@ -0,0 +1,12 @@ +from typing import ClassVar + +from pydantic_extra_types.phone_numbers import PhoneNumber + +from .base import Retrievable + + +class ExistPhone(Retrievable): + _resource: ClassVar = 'exist_phone' + + id: PhoneNumber + exist: bool diff --git a/cuenca/version.py b/cuenca/version.py index a6cf70fb..7c06d6a5 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '2.1.6' +__version__ = '2.1.7' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' diff --git a/tests/resources/cassettes/test_exist_phone_retrieve.yaml b/tests/resources/cassettes/test_exist_phone_retrieve.yaml new file mode 100644 index 00000000..d37c92ca --- /dev/null +++ b/tests/resources/cassettes/test_exist_phone_retrieve.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: null + headers: + User-Agent: + - cuenca-python/2.1.7.dev1 + X-Cuenca-Api-Version: + - '2020-03-19' + method: GET + uri: https://sandbox.cuenca.com/exist_phone/+527331256958 + response: + body: + string: '{"id":"+527331256958","exist":true}' + headers: + Connection: + - keep-alive + Content-Length: + - '35' + Content-Type: + - application/json + Date: + - Thu, 17 Jul 2025 18:34:19 GMT + X-Request-Time: + - 'value: 0.041' + x-amz-apigw-id: + - N3dG4EzACYcEofg= + x-amzn-Remapped-Connection: + - keep-alive + x-amzn-Remapped-Content-Length: + - '35' + x-amzn-Remapped-Date: + - Thu, 17 Jul 2025 18:34:19 GMT + x-amzn-Remapped-Server: + - nginx/1.28.0 + x-amzn-RequestId: + - 51d8507c-c023-4b91-aa52-a6bdc499df89 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/resources/test_exist_phone.py b/tests/resources/test_exist_phone.py new file mode 100644 index 00000000..3a059695 --- /dev/null +++ b/tests/resources/test_exist_phone.py @@ -0,0 +1,11 @@ +import pytest + +from cuenca import ExistPhone + + +@pytest.mark.vcr +def test_exist_phone_retrieve(): + phone_number = '+527331256958' + exist_phone: ExistPhone = ExistPhone.retrieve(phone_number) + assert exist_phone.id == phone_number + assert exist_phone.exist From 972cc7ea913c837f106d52d8df5795532143d220 Mon Sep 17 00:00:00 2001 From: gabino Date: Mon, 21 Jul 2025 11:22:36 -0600 Subject: [PATCH 2/6] Add PhoneVerificationAssociation resource --- cuenca/__init__.py | 2 + cuenca/resources/__init__.py | 3 ++ .../phone_verification_association.py | 26 +++++++++++ cuenca/version.py | 2 +- requirements.txt | 2 +- ...phone_verification_association_create.yaml | 46 +++++++++++++++++++ .../test_phone_verification_association.py | 13 ++++++ 7 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 cuenca/resources/phone_verification_association.py create mode 100644 tests/resources/cassettes/test_phone_verification_association_create.yaml create mode 100644 tests/resources/test_phone_verification_association.py diff --git a/cuenca/__init__.py b/cuenca/__init__.py index 9592231d..8097c7c1 100644 --- a/cuenca/__init__.py +++ b/cuenca/__init__.py @@ -46,6 +46,7 @@ 'UserTOSAgreement', 'PostalCodes', 'ExistPhone', + 'PhoneVerificationAssociation', ] from . import http @@ -75,6 +76,7 @@ LimitedWallet, LoginToken, Otp, + PhoneVerificationAssociation, Platform, PostalCodes, Questionnaires, diff --git a/cuenca/resources/__init__.py b/cuenca/resources/__init__.py index 12a19fb0..b17cd70e 100644 --- a/cuenca/resources/__init__.py +++ b/cuenca/resources/__init__.py @@ -24,6 +24,7 @@ 'LoginToken', 'Otp', 'Platform', + 'PhoneVerificationAssociation', 'Questionnaires', 'Saving', 'ServiceProvider', @@ -69,6 +70,7 @@ from .limited_wallets import LimitedWallet from .login_tokens import LoginToken from .otps import Otp +from .phone_verification_association import PhoneVerificationAssociation from .platforms import Platform from .postal_codes import PostalCodes from .questionnaires import Questionnaires @@ -134,6 +136,7 @@ JwtToken, TermsOfService, UserTOSAgreement, + PhoneVerificationAssociation, ] for resource_cls in resource_classes: RESOURCES[resource_cls._resource] = resource_cls # type: ignore diff --git a/cuenca/resources/phone_verification_association.py b/cuenca/resources/phone_verification_association.py new file mode 100644 index 00000000..e3f42463 --- /dev/null +++ b/cuenca/resources/phone_verification_association.py @@ -0,0 +1,26 @@ +import datetime as dt +from typing import ClassVar + +from cuenca_validations.types.requests import ( + PhoneVerificationAssociationRequest, +) + +from ..http import Session, session as global_session +from .base import Creatable + + +class PhoneVerificationAssociation(Creatable): + _resource: ClassVar = 'phone_verification_association' + + verification_id: str + user_id: str + created_at: dt.datetime + + @classmethod + def create( + cls, verification_id: str, session: Session = global_session + ) -> 'PhoneVerificationAssociation': + req = PhoneVerificationAssociationRequest( + verification_id=verification_id + ) + return cls._create(session=session, **req.model_dump()) diff --git a/cuenca/version.py b/cuenca/version.py index 7c06d6a5..bc2d1000 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '2.1.7' +__version__ = '2.1.8.dev1' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' diff --git a/requirements.txt b/requirements.txt index c6f3d6a4..3330f3a1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ requests==2.32.3 -cuenca-validations==2.1.11 +cuenca-validations==2.1.12.dev1 pydantic-extra-types==2.10.2 diff --git a/tests/resources/cassettes/test_phone_verification_association_create.yaml b/tests/resources/cassettes/test_phone_verification_association_create.yaml new file mode 100644 index 00000000..f035b793 --- /dev/null +++ b/tests/resources/cassettes/test_phone_verification_association_create.yaml @@ -0,0 +1,46 @@ +interactions: +- request: + body: '{"verification_id": "VEeCjasQQWQM-Hr-odTGoKoQ"}' + headers: + Authorization: + - DUMMY + Content-Length: + - '47' + Content-Type: + - application/json + User-Agent: + - cuenca-python/2.1.7 + X-Cuenca-Api-Version: + - '2020-03-19' + method: POST + uri: https://sandbox.cuenca.com/phone_verification_association + response: + body: + string: '{"id":"PVuzCh7IsESSyGxyMdjgRY3A","verification_id":"VEeCjasQQWQM-Hr-odTGoKoQ","user_id":"USS2gTzkh_Sm2ZPZGtfNOK_Q","created_at":"2025-07-21T17:07:04.776955"}' + headers: + Connection: + - keep-alive + Content-Length: + - '157' + Content-Type: + - application/json + Date: + - Mon, 21 Jul 2025 17:07:04 GMT + X-Request-Time: + - 'value: 0.487' + x-amz-apigw-id: + - OEcE3FGUCYcEvbw= + x-amzn-Remapped-Connection: + - keep-alive + x-amzn-Remapped-Content-Length: + - '157' + x-amzn-Remapped-Date: + - Mon, 21 Jul 2025 17:07:04 GMT + x-amzn-Remapped-Server: + - nginx/1.28.0 + x-amzn-RequestId: + - f10e5016-1ce3-429d-9d00-027a4d018c71 + status: + code: 201 + message: Created +version: 1 diff --git a/tests/resources/test_phone_verification_association.py b/tests/resources/test_phone_verification_association.py new file mode 100644 index 00000000..248ec0e5 --- /dev/null +++ b/tests/resources/test_phone_verification_association.py @@ -0,0 +1,13 @@ +import pytest + +from cuenca import PhoneVerificationAssociation + + +@pytest.mark.vcr +def test_phone_verification_association_create(): + + phone_verification_association = PhoneVerificationAssociation.create( + verification_id='VEeCjasQQWQM-Hr-odTGoKoQ', + ) + assert phone_verification_association.verification_id + assert phone_verification_association.user_id From 35e2d99eb1e79bcf3ab1c82e5d08dc22659c3e35 Mon Sep 17 00:00:00 2001 From: gabino Date: Tue, 22 Jul 2025 10:28:04 -0600 Subject: [PATCH 3/6] Update cuenca-validations to version 2.1.12 in requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 3330f3a1..0dd840ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ requests==2.32.3 -cuenca-validations==2.1.12.dev1 +cuenca-validations==2.1.12 pydantic-extra-types==2.10.2 From 7dec6b6b116b2ced17d09ccf8abd03d960289a1f Mon Sep 17 00:00:00 2001 From: gabino Date: Tue, 22 Jul 2025 10:38:15 -0600 Subject: [PATCH 4/6] Update version to 2.1.7 in version.py --- cuenca/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuenca/version.py b/cuenca/version.py index bc2d1000..7c06d6a5 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '2.1.8.dev1' +__version__ = '2.1.7' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' From 7723fc8645a7abc49a8bf25d201cada2415da389 Mon Sep 17 00:00:00 2001 From: gabino Date: Wed, 23 Jul 2025 09:18:49 -0600 Subject: [PATCH 5/6] Refactor ExistPhone and PhoneVerificationAssociation resources to ExistPhones and PhoneVerificationAssociations --- cuenca/__init__.py | 8 ++++---- cuenca/resources/__init__.py | 8 ++++---- cuenca/resources/{exist_phone.py => exist_phones.py} | 4 ++-- ..._association.py => phone_verification_associations.py} | 6 +++--- cuenca/version.py | 2 +- tests/resources/cassettes/test_exist_phone_retrieve.yaml | 4 ++-- .../test_phone_verification_association_create.yaml | 4 ++-- tests/resources/test_exist_phone.py | 4 ++-- tests/resources/test_phone_verification_association.py | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) rename cuenca/resources/{exist_phone.py => exist_phones.py} (68%) rename cuenca/resources/{phone_verification_association.py => phone_verification_associations.py} (79%) diff --git a/cuenca/__init__.py b/cuenca/__init__.py index 8097c7c1..c9595ed2 100644 --- a/cuenca/__init__.py +++ b/cuenca/__init__.py @@ -45,8 +45,8 @@ 'TermsOfService', 'UserTOSAgreement', 'PostalCodes', - 'ExistPhone', - 'PhoneVerificationAssociation', + 'ExistPhones', + 'PhoneVerificationAssociations', ] from . import http @@ -66,7 +66,7 @@ CurpValidation, Deposit, Endpoint, - ExistPhone, + ExistPhones, File, FileBatch, Identity, @@ -76,7 +76,7 @@ LimitedWallet, LoginToken, Otp, - PhoneVerificationAssociation, + PhoneVerificationAssociations, Platform, PostalCodes, Questionnaires, diff --git a/cuenca/resources/__init__.py b/cuenca/resources/__init__.py index b17cd70e..dd7bc412 100644 --- a/cuenca/resources/__init__.py +++ b/cuenca/resources/__init__.py @@ -16,7 +16,7 @@ 'Endpoint', 'File', 'FileBatch', - 'ExistPhone', + 'ExistPhones', 'Identity', 'IdentityEvent', 'KYCValidation', @@ -60,7 +60,7 @@ from .curp_validations import CurpValidation from .deposits import Deposit from .endpoints import Endpoint -from .exist_phone import ExistPhone +from .exist_phones import ExistPhones from .file_batches import FileBatch from .files import File from .identities import Identity @@ -70,7 +70,7 @@ from .limited_wallets import LimitedWallet from .login_tokens import LoginToken from .otps import Otp -from .phone_verification_association import PhoneVerificationAssociation +from .phone_verification_associations import PhoneVerificationAssociations from .platforms import Platform from .postal_codes import PostalCodes from .questionnaires import Questionnaires @@ -136,7 +136,7 @@ JwtToken, TermsOfService, UserTOSAgreement, - PhoneVerificationAssociation, + PhoneVerificationAssociations, ] for resource_cls in resource_classes: RESOURCES[resource_cls._resource] = resource_cls # type: ignore diff --git a/cuenca/resources/exist_phone.py b/cuenca/resources/exist_phones.py similarity index 68% rename from cuenca/resources/exist_phone.py rename to cuenca/resources/exist_phones.py index 0ad2693e..22e53e16 100644 --- a/cuenca/resources/exist_phone.py +++ b/cuenca/resources/exist_phones.py @@ -5,8 +5,8 @@ from .base import Retrievable -class ExistPhone(Retrievable): - _resource: ClassVar = 'exist_phone' +class ExistPhones(Retrievable): + _resource: ClassVar = 'exist_phones' id: PhoneNumber exist: bool diff --git a/cuenca/resources/phone_verification_association.py b/cuenca/resources/phone_verification_associations.py similarity index 79% rename from cuenca/resources/phone_verification_association.py rename to cuenca/resources/phone_verification_associations.py index e3f42463..91424dbf 100644 --- a/cuenca/resources/phone_verification_association.py +++ b/cuenca/resources/phone_verification_associations.py @@ -9,8 +9,8 @@ from .base import Creatable -class PhoneVerificationAssociation(Creatable): - _resource: ClassVar = 'phone_verification_association' +class PhoneVerificationAssociations(Creatable): + _resource: ClassVar = 'phone_verification_associations' verification_id: str user_id: str @@ -19,7 +19,7 @@ class PhoneVerificationAssociation(Creatable): @classmethod def create( cls, verification_id: str, session: Session = global_session - ) -> 'PhoneVerificationAssociation': + ) -> 'PhoneVerificationAssociations': req = PhoneVerificationAssociationRequest( verification_id=verification_id ) diff --git a/cuenca/version.py b/cuenca/version.py index 7c06d6a5..1b7a56f2 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '2.1.7' +__version__ = '2.1.7.dev2' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' diff --git a/tests/resources/cassettes/test_exist_phone_retrieve.yaml b/tests/resources/cassettes/test_exist_phone_retrieve.yaml index d37c92ca..7cc0b7d9 100644 --- a/tests/resources/cassettes/test_exist_phone_retrieve.yaml +++ b/tests/resources/cassettes/test_exist_phone_retrieve.yaml @@ -3,11 +3,11 @@ interactions: body: null headers: User-Agent: - - cuenca-python/2.1.7.dev1 + - cuenca-python/2.1.7.dev2 X-Cuenca-Api-Version: - '2020-03-19' method: GET - uri: https://sandbox.cuenca.com/exist_phone/+527331256958 + uri: https://sandbox.cuenca.com/exist_phones/+527331256958 response: body: string: '{"id":"+527331256958","exist":true}' diff --git a/tests/resources/cassettes/test_phone_verification_association_create.yaml b/tests/resources/cassettes/test_phone_verification_association_create.yaml index f035b793..3ad9e12f 100644 --- a/tests/resources/cassettes/test_phone_verification_association_create.yaml +++ b/tests/resources/cassettes/test_phone_verification_association_create.yaml @@ -9,11 +9,11 @@ interactions: Content-Type: - application/json User-Agent: - - cuenca-python/2.1.7 + - cuenca-python/2.1.7.dev2 X-Cuenca-Api-Version: - '2020-03-19' method: POST - uri: https://sandbox.cuenca.com/phone_verification_association + uri: https://sandbox.cuenca.com/phone_verification_associations response: body: string: '{"id":"PVuzCh7IsESSyGxyMdjgRY3A","verification_id":"VEeCjasQQWQM-Hr-odTGoKoQ","user_id":"USS2gTzkh_Sm2ZPZGtfNOK_Q","created_at":"2025-07-21T17:07:04.776955"}' diff --git a/tests/resources/test_exist_phone.py b/tests/resources/test_exist_phone.py index 3a059695..966af541 100644 --- a/tests/resources/test_exist_phone.py +++ b/tests/resources/test_exist_phone.py @@ -1,11 +1,11 @@ import pytest -from cuenca import ExistPhone +from cuenca import ExistPhones @pytest.mark.vcr def test_exist_phone_retrieve(): phone_number = '+527331256958' - exist_phone: ExistPhone = ExistPhone.retrieve(phone_number) + exist_phone: ExistPhones = ExistPhones.retrieve(phone_number) assert exist_phone.id == phone_number assert exist_phone.exist diff --git a/tests/resources/test_phone_verification_association.py b/tests/resources/test_phone_verification_association.py index 248ec0e5..d39d186e 100644 --- a/tests/resources/test_phone_verification_association.py +++ b/tests/resources/test_phone_verification_association.py @@ -1,12 +1,12 @@ import pytest -from cuenca import PhoneVerificationAssociation +from cuenca import PhoneVerificationAssociations @pytest.mark.vcr def test_phone_verification_association_create(): - phone_verification_association = PhoneVerificationAssociation.create( + phone_verification_association = PhoneVerificationAssociations.create( verification_id='VEeCjasQQWQM-Hr-odTGoKoQ', ) assert phone_verification_association.verification_id From a6b6ca99d7c14250288dc084a7e0b3cc5d114401 Mon Sep 17 00:00:00 2001 From: gabino Date: Wed, 23 Jul 2025 17:49:00 -0600 Subject: [PATCH 6/6] Update version to 2.1.7 in version.py --- cuenca/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuenca/version.py b/cuenca/version.py index 1b7a56f2..7c06d6a5 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '2.1.7.dev2' +__version__ = '2.1.7' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19'