Skip to content

Commit 2d15551

Browse files
authored
Add ExistPhone resource (#424)
* Add ExistPhone resource * Add PhoneVerificationAssociation resource * Update cuenca-validations to version 2.1.12 in requirements.txt * Update version to 2.1.7 in version.py * Refactor ExistPhone and PhoneVerificationAssociation resources to ExistPhones and PhoneVerificationAssociations * Update version to 2.1.7 in version.py
1 parent 1f77dd9 commit 2d15551

File tree

10 files changed

+159
-2
lines changed

10 files changed

+159
-2
lines changed

cuenca/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
'TermsOfService',
4646
'UserTOSAgreement',
4747
'PostalCodes',
48+
'ExistPhones',
49+
'PhoneVerificationAssociations',
4850
]
4951

5052
from . import http
@@ -64,6 +66,7 @@
6466
CurpValidation,
6567
Deposit,
6668
Endpoint,
69+
ExistPhones,
6770
File,
6871
FileBatch,
6972
Identity,
@@ -73,6 +76,7 @@
7376
LimitedWallet,
7477
LoginToken,
7578
Otp,
79+
PhoneVerificationAssociations,
7680
Platform,
7781
PostalCodes,
7882
Questionnaires,

cuenca/resources/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
'Endpoint',
1717
'File',
1818
'FileBatch',
19+
'ExistPhones',
1920
'Identity',
2021
'IdentityEvent',
2122
'KYCValidation',
2223
'LimitedWallet',
2324
'LoginToken',
2425
'Otp',
2526
'Platform',
27+
'PhoneVerificationAssociation',
2628
'Questionnaires',
2729
'Saving',
2830
'ServiceProvider',
@@ -58,6 +60,7 @@
5860
from .curp_validations import CurpValidation
5961
from .deposits import Deposit
6062
from .endpoints import Endpoint
63+
from .exist_phones import ExistPhones
6164
from .file_batches import FileBatch
6265
from .files import File
6366
from .identities import Identity
@@ -67,6 +70,7 @@
6770
from .limited_wallets import LimitedWallet
6871
from .login_tokens import LoginToken
6972
from .otps import Otp
73+
from .phone_verification_associations import PhoneVerificationAssociations
7074
from .platforms import Platform
7175
from .postal_codes import PostalCodes
7276
from .questionnaires import Questionnaires
@@ -132,6 +136,7 @@
132136
JwtToken,
133137
TermsOfService,
134138
UserTOSAgreement,
139+
PhoneVerificationAssociations,
135140
]
136141
for resource_cls in resource_classes:
137142
RESOURCES[resource_cls._resource] = resource_cls # type: ignore

cuenca/resources/exist_phones.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from typing import ClassVar
2+
3+
from pydantic_extra_types.phone_numbers import PhoneNumber
4+
5+
from .base import Retrievable
6+
7+
8+
class ExistPhones(Retrievable):
9+
_resource: ClassVar = 'exist_phones'
10+
11+
id: PhoneNumber
12+
exist: bool
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import datetime as dt
2+
from typing import ClassVar
3+
4+
from cuenca_validations.types.requests import (
5+
PhoneVerificationAssociationRequest,
6+
)
7+
8+
from ..http import Session, session as global_session
9+
from .base import Creatable
10+
11+
12+
class PhoneVerificationAssociations(Creatable):
13+
_resource: ClassVar = 'phone_verification_associations'
14+
15+
verification_id: str
16+
user_id: str
17+
created_at: dt.datetime
18+
19+
@classmethod
20+
def create(
21+
cls, verification_id: str, session: Session = global_session
22+
) -> 'PhoneVerificationAssociations':
23+
req = PhoneVerificationAssociationRequest(
24+
verification_id=verification_id
25+
)
26+
return cls._create(session=session, **req.model_dump())

cuenca/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '2.1.6'
1+
__version__ = '2.1.7'
22
CLIENT_VERSION = __version__
33
API_VERSION = '2020-03-19'

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
requests==2.32.3
2-
cuenca-validations==2.1.11
2+
cuenca-validations==2.1.12
33
pydantic-extra-types==2.10.2
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
User-Agent:
6+
- cuenca-python/2.1.7.dev2
7+
X-Cuenca-Api-Version:
8+
- '2020-03-19'
9+
method: GET
10+
uri: https://sandbox.cuenca.com/exist_phones/+527331256958
11+
response:
12+
body:
13+
string: '{"id":"+527331256958","exist":true}'
14+
headers:
15+
Connection:
16+
- keep-alive
17+
Content-Length:
18+
- '35'
19+
Content-Type:
20+
- application/json
21+
Date:
22+
- Thu, 17 Jul 2025 18:34:19 GMT
23+
X-Request-Time:
24+
- 'value: 0.041'
25+
x-amz-apigw-id:
26+
- N3dG4EzACYcEofg=
27+
x-amzn-Remapped-Connection:
28+
- keep-alive
29+
x-amzn-Remapped-Content-Length:
30+
- '35'
31+
x-amzn-Remapped-Date:
32+
- Thu, 17 Jul 2025 18:34:19 GMT
33+
x-amzn-Remapped-Server:
34+
- nginx/1.28.0
35+
x-amzn-RequestId:
36+
- 51d8507c-c023-4b91-aa52-a6bdc499df89
37+
status:
38+
code: 200
39+
message: OK
40+
version: 1
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
interactions:
2+
- request:
3+
body: '{"verification_id": "VEeCjasQQWQM-Hr-odTGoKoQ"}'
4+
headers:
5+
Authorization:
6+
- DUMMY
7+
Content-Length:
8+
- '47'
9+
Content-Type:
10+
- application/json
11+
User-Agent:
12+
- cuenca-python/2.1.7.dev2
13+
X-Cuenca-Api-Version:
14+
- '2020-03-19'
15+
method: POST
16+
uri: https://sandbox.cuenca.com/phone_verification_associations
17+
response:
18+
body:
19+
string: '{"id":"PVuzCh7IsESSyGxyMdjgRY3A","verification_id":"VEeCjasQQWQM-Hr-odTGoKoQ","user_id":"USS2gTzkh_Sm2ZPZGtfNOK_Q","created_at":"2025-07-21T17:07:04.776955"}'
20+
headers:
21+
Connection:
22+
- keep-alive
23+
Content-Length:
24+
- '157'
25+
Content-Type:
26+
- application/json
27+
Date:
28+
- Mon, 21 Jul 2025 17:07:04 GMT
29+
X-Request-Time:
30+
- 'value: 0.487'
31+
x-amz-apigw-id:
32+
- OEcE3FGUCYcEvbw=
33+
x-amzn-Remapped-Connection:
34+
- keep-alive
35+
x-amzn-Remapped-Content-Length:
36+
- '157'
37+
x-amzn-Remapped-Date:
38+
- Mon, 21 Jul 2025 17:07:04 GMT
39+
x-amzn-Remapped-Server:
40+
- nginx/1.28.0
41+
x-amzn-RequestId:
42+
- f10e5016-1ce3-429d-9d00-027a4d018c71
43+
status:
44+
code: 201
45+
message: Created
46+
version: 1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
from cuenca import ExistPhones
4+
5+
6+
@pytest.mark.vcr
7+
def test_exist_phone_retrieve():
8+
phone_number = '+527331256958'
9+
exist_phone: ExistPhones = ExistPhones.retrieve(phone_number)
10+
assert exist_phone.id == phone_number
11+
assert exist_phone.exist
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import pytest
2+
3+
from cuenca import PhoneVerificationAssociations
4+
5+
6+
@pytest.mark.vcr
7+
def test_phone_verification_association_create():
8+
9+
phone_verification_association = PhoneVerificationAssociations.create(
10+
verification_id='VEeCjasQQWQM-Hr-odTGoKoQ',
11+
)
12+
assert phone_verification_association.verification_id
13+
assert phone_verification_association.user_id

0 commit comments

Comments
 (0)