Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency/update cuenca validations #413

Merged
merged 7 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cuenca/resources/endpoints.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from typing import ClassVar, Optional

from cuenca_validations.types.enums import WebhookEvent
from cuenca_validations.types.general import SerializableHttpUrl
from cuenca_validations.types.requests import (
EndpointRequest,
EndpointUpdateRequest,
)
from pydantic import ConfigDict, Field, HttpUrl
from pydantic import ConfigDict, Field

from ..http import Session, session as global_session
from .base import Creatable, Deactivable, Queryable, Retrievable, Updateable
Expand All @@ -14,7 +15,7 @@
class Endpoint(Creatable, Deactivable, Retrievable, Queryable, Updateable):
_resource: ClassVar = 'endpoints'

url: HttpUrl = Field(description='HTTPS url to send webhooks')
url: SerializableHttpUrl = Field(description='HTTPS url to send webhooks')
secret: str = Field(
description='token to verify the webhook is sent by Cuenca '
'using HMAC algorithm',
Expand Down Expand Up @@ -51,7 +52,7 @@ class Endpoint(Creatable, Deactivable, Retrievable, Queryable, Updateable):
@classmethod
def create(
cls,
url: HttpUrl,
url: SerializableHttpUrl,
events: Optional[list[WebhookEvent]] = None,
*,
session: Session = global_session,
Expand All @@ -72,7 +73,7 @@ def create(
def update(
cls,
endpoint_id: str,
url: Optional[HttpUrl] = None,
url: Optional[SerializableHttpUrl] = None,
events: Optional[list[WebhookEvent]] = None,
is_enable: Optional[bool] = None,
*,
Expand Down
4 changes: 2 additions & 2 deletions cuenca/resources/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import ClassVar, Optional

from cuenca_validations.types import FileQuery, FileUploadRequest, KYCFileType
from pydantic import HttpUrl
from cuenca_validations.types.general import SerializableHttpUrl

from ..http import Session, session as global_session
from .base import Downloadable, Queryable, Uploadable
Expand All @@ -14,7 +14,7 @@ class File(Downloadable, Queryable, Uploadable):

extension: str
type: KYCFileType
url: HttpUrl
url: SerializableHttpUrl
user_id: str

@classmethod
Expand Down
7 changes: 4 additions & 3 deletions cuenca/resources/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from typing import ClassVar, Optional

from cuenca_validations.types import SessionRequest, SessionType
from pydantic import AnyUrl, ConfigDict
from cuenca_validations.types.general import SerializableAnyUrl
from pydantic import ConfigDict

from .. import http
from .base import Creatable, Queryable, Retrievable
Expand All @@ -16,8 +17,8 @@ class Session(Creatable, Retrievable, Queryable):
user_id: str
platform_id: str
expires_at: dt.datetime
success_url: Optional[AnyUrl] = None
failure_url: Optional[AnyUrl] = None
success_url: Optional[SerializableAnyUrl] = None
failure_url: Optional[SerializableAnyUrl] = None
type: Optional[SessionType] = None

model_config = ConfigDict(
Expand Down
9 changes: 7 additions & 2 deletions cuenca/resources/user_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def create(
session: Session = global_session,
) -> 'UserCredential':
req = UserCredentialRequest(password=password, user_id=user_id)
return cls._create(**req.model_dump(), session=session)
data = req.model_dump()
data['password'] = data['password'].get_secret_value()
return cls._create(**data, session=session)

@classmethod
def update(
Expand All @@ -40,4 +42,7 @@ def update(
is_active=is_active,
password=password,
)
return cls._update(id=user_id, **req.model_dump(), session=session)
data = req.model_dump()
if password:
data['password'] = data['password'].get_secret_value()
return cls._update(id=user_id, **data, session=session)
5 changes: 3 additions & 2 deletions cuenca/resources/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
UserUpdateRequest,
)
from cuenca_validations.types.enums import Country, Gender, State
from cuenca_validations.types.general import SerializableHttpUrl
from cuenca_validations.types.identities import Curp
from pydantic import ConfigDict, EmailStr, Field, HttpUrl
from pydantic import ConfigDict, EmailStr, Field

from ..http import Session, session as global_session
from .balance_entries import BalanceEntry
Expand Down Expand Up @@ -147,7 +148,7 @@ def update(
status: Optional[UserStatus] = None,
email_verification_id: Optional[str] = None,
phone_verification_id: Optional[str] = None,
curp_document: Optional[HttpUrl] = None,
curp_document: Optional[SerializableHttpUrl] = None,
*,
session: Session = global_session,
) -> 'User':
Expand Down
2 changes: 1 addition & 1 deletion cuenca/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '2.0.0'
__version__ = '2.0.1'
CLIENT_VERSION = __version__
API_VERSION = '2020-03-19'
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests==2.32.3
cuenca-validations==2.0.0
cuenca-validations==2.0.4
pydantic-extra-types==2.10.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
python_requires='>=3.9',
install_requires=[
'requests>=2.32.0',
'cuenca-validations>=2.0.0',
'cuenca-validations>=2.0.4',
'pydantic-extra-types>=2.10.0',
],
classifiers=[
Expand Down
6 changes: 3 additions & 3 deletions tests/resources/cassettes/test_update_password.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
interactions:
- request:
body: '{"password": "222222"}'
body: '{"password": "22222222"}'
headers:
Accept:
- '*/*'
Expand Down Expand Up @@ -54,7 +54,7 @@ interactions:
code: 201
message: Created
- request:
body: '{"password": "222222"}'
body: '{"password": "22222222"}'
headers:
Accept:
- '*/*'
Expand Down Expand Up @@ -108,7 +108,7 @@ interactions:
code: 201
message: Created
- request:
body: '{"is_active": null, "password": "111111"}'
body: '{"is_active": null, "password": "11111111"}'
headers:
Accept:
- '*/*'
Expand Down
6 changes: 3 additions & 3 deletions tests/resources/test_user_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

@pytest.mark.vcr
def test_update_password():
UserCredential.create('222222')
UserLogin.create('222222')
UserCredential.update(password='111111')
UserCredential.create('22222222')
UserLogin.create('22222222')
UserCredential.update(password='11111111')


@pytest.mark.vcr
Expand Down
Loading