Skip to content
2 changes: 2 additions & 0 deletions cuenca_validations/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'BankAccountStatus',
'BatchFileMetadata',
'Beneficiary',
'BeneficiaryResponse',
'BillPaymentQuery',
'CardErrorType',
'CardFundingType',
Expand Down Expand Up @@ -187,6 +188,7 @@
from .identities import (
Address,
Beneficiary,
BeneficiaryResponse,
Curp,
KYCFile,
PhoneNumber,
Expand Down
21 changes: 20 additions & 1 deletion cuenca_validations/types/identities.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime as dt
from typing import Annotated, Optional
from typing import Annotated, Optional, Union

from pydantic import BaseModel, ConfigDict, Field, SecretStr, StringConstraints
from pydantic_extra_types.phone_numbers import PhoneNumber
Expand Down Expand Up @@ -108,6 +108,25 @@ class Beneficiary(BaseModel):
)


class BeneficiaryResponse(BaseModel):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no convendrá que este se llame Beneficiary y el de arriba se renombre a BeneficiaryRequest? este validator sería el que usa en el resource de cuenca-python y el otro solo para los requests en el endpoint de identify y en el User.create or User.update de cuenca-python

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

va, suena más natural

name: str
birth_date: dt.date
phone_number: Union[PhoneNumber, str]
user_relationship: str
percentage: Annotated[int, Field(ge=1, le=100)]
model_config = ConfigDict(
json_schema_extra={
"example": {
"name": "Juan Perez",
"birth_date": "1907-07-06",
"phone_number": "+525500998877",
"user_relationship": "friend",
"percentage": 100,
}
}
)


class VerificationErrors(BaseModel):
identifier: str = Field(
description='Unique identifier for the step validation'
Expand Down
4 changes: 2 additions & 2 deletions cuenca_validations/types/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ class UserTOSAgreementRequest(BaseModel):
signature_image_url: Optional[FileCuencaUrl] = None


class UserRequest(BaseModel):
class UserRequest(BaseRequest):
curp: Curp = Field(
description=(
'Mexican government ID (18 characters). ' 'Must be pre-validated.'
Expand Down Expand Up @@ -495,7 +495,7 @@ def validate_profession(cls, profession: Profession) -> Profession:
return profession


class UserUpdateRequest(BaseModel):
class UserUpdateRequest(BaseRequest):
profession: Optional[Profession] = None
email_verification_id: Optional[str] = None
phone_verification_id: Optional[str] = None
Expand Down
2 changes: 1 addition & 1 deletion cuenca_validations/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.1.16'
__version__ = '2.1.17'
25 changes: 0 additions & 25 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,16 +435,11 @@ def test_user_update_request():
percentage=50,
),
],
curp_document_uri='https://sandbox.cuenca.com/files/EF123',
profession=Profession.empleado,
)
update_req = UserUpdateRequest(**request)
beneficiaries = [b.model_dump() for b in update_req.beneficiaries]
assert beneficiaries == request['beneficiaries']
assert (
update_req.curp_document_uri.unicode_string()
== request['curp_document_uri']
)
assert update_req.profession == Profession.empleado

request['beneficiaries'] = [
Expand Down Expand Up @@ -480,26 +475,6 @@ def test_user_update_request():
assert 'The total percentage should be 100%' in str(v)
request.pop('beneficiaries')

tos_request = dict(
terms_of_service=dict(
version='2022-01-01',
ip='127.0.0.1',
location='1111,1111',
type='ifpe',
)
)
UserUpdateRequest(**tos_request)

tos_request = dict(
terms_of_service=dict(
version='2022-01-01',
ip='2001:0db8:0000:0000:0000:ff00:0042:8329',
location='1111,1111',
type='ifpe',
)
)
UserUpdateRequest(**tos_request)

kyc_request = dict(
govt_id=dict(
type='ine',
Expand Down
Loading