cuenca-validations 2.1.43__tar.gz → 2.1.44__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/PKG-INFO +1 -1
  2. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/types/__init__.py +12 -0
  3. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/types/enums.py +10 -0
  4. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/types/queries.py +4 -0
  5. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/types/requests.py +60 -0
  6. cuenca_validations-2.1.44/cuenca_validations/version.py +1 -0
  7. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations.egg-info/PKG-INFO +1 -1
  8. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/tests/test_requests.py +91 -1
  9. cuenca_validations-2.1.43/cuenca_validations/version.py +0 -1
  10. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/LICENSE +0 -0
  11. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/README.md +0 -0
  12. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/__init__.py +0 -0
  13. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/card_bins.py +0 -0
  14. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/errors.py +0 -0
  15. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/py.typed +0 -0
  16. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/types/card.py +0 -0
  17. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/types/files.py +0 -0
  18. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/types/general.py +0 -0
  19. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/types/helpers.py +0 -0
  20. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/types/identities.py +0 -0
  21. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/types/morals.py +0 -0
  22. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/typing.py +0 -0
  23. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations/validators.py +0 -0
  24. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations.egg-info/SOURCES.txt +0 -0
  25. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations.egg-info/dependency_links.txt +0 -0
  26. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations.egg-info/requires.txt +0 -0
  27. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/cuenca_validations.egg-info/top_level.txt +0 -0
  28. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/setup.cfg +0 -0
  29. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/setup.py +0 -0
  30. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/tests/__init__.py +0 -0
  31. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/tests/test_card.py +0 -0
  32. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/tests/test_errors.py +0 -0
  33. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/tests/test_helpers.py +0 -0
  34. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/tests/test_statement.py +0 -0
  35. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/tests/test_types.py +0 -0
  36. {cuenca_validations-2.1.43 → cuenca_validations-2.1.44}/tests/test_validators.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cuenca_validations
3
- Version: 2.1.43
3
+ Version: 2.1.44
4
4
  Summary: Cuenca common validations
5
5
  Home-page: https://github.com/cuenca-mx/cuenca-validations
6
6
  Author: Cuenca
@@ -62,6 +62,12 @@ __all__ = [
62
62
  'MonthlySpendingType',
63
63
  'LegalPersonRequest',
64
64
  'LegalPersonUpdateRequest',
65
+ 'OperatorLoginRequest',
66
+ 'OperatorQuery',
67
+ 'OperatorRequest',
68
+ 'OperatorRole',
69
+ 'OperatorStatus',
70
+ 'OperatorUpdateRequest',
65
71
  'PartnerRequest',
66
72
  'PartnerUpdateRequest',
67
73
  'PasswordResetRequest',
@@ -158,6 +164,8 @@ from .enums import (
158
164
  Language,
159
165
  MonthlyMovementsType,
160
166
  MonthlySpendingType,
167
+ OperatorRole,
168
+ OperatorStatus,
161
169
  PlatformType,
162
170
  PosCapability,
163
171
  Profession,
@@ -216,6 +224,7 @@ from .queries import (
216
224
  EventQuery,
217
225
  FileQuery,
218
226
  IdentityQuery,
227
+ OperatorQuery,
219
228
  PostalCodeQuery,
220
229
  QueryParams,
221
230
  SessionQuery,
@@ -244,6 +253,9 @@ from .requests import (
244
253
  LegalPersonRequest,
245
254
  LegalPersonUpdateRequest,
246
255
  LimitedWalletRequest,
256
+ OperatorLoginRequest,
257
+ OperatorRequest,
258
+ OperatorUpdateRequest,
247
259
  PartnerRequest,
248
260
  PartnerUpdateRequest,
249
261
  PasswordResetRequest,
@@ -746,3 +746,13 @@ class RequiredAction(str, Enum):
746
746
  level_up_invitation = 'level_up_invitation'
747
747
  fix_documents = 'fix_documents'
748
748
  wait_validation = 'wait_validation'
749
+
750
+
751
+ class OperatorRole(str, Enum):
752
+ operator = 'operator'
753
+ authorizer = 'authorizer'
754
+
755
+
756
+ class OperatorStatus(str, Enum):
757
+ active = 'active'
758
+ deactivated = 'deactivated'
@@ -153,6 +153,10 @@ class AccountQuery(QueryParams):
153
153
  account_number: Optional[str] = None
154
154
 
155
155
 
156
+ class OperatorQuery(QueryParams):
157
+ email: Optional[EmailStr] = None
158
+
159
+
156
160
  class BalanceEntryQuery(QueryParams):
157
161
  funding_instrument_uri: Optional[str] = None
158
162
  wallet_id: str = 'default'
@@ -36,6 +36,8 @@ from ..types.enums import (
36
36
  KYCValidationSource,
37
37
  MonthlyMovementsType,
38
38
  MonthlySpendingType,
39
+ OperatorRole,
40
+ OperatorStatus,
39
41
  PlatformType,
40
42
  PosCapability,
41
43
  Profession,
@@ -899,5 +901,63 @@ class LegalPersonUpdateRequest(BaseRequest):
899
901
  legal_representatives: Optional[list[LegalRepresentative]] = None
900
902
 
901
903
 
904
+ class OperatorRequest(BaseRequest):
905
+ name: str
906
+ email: EmailStr
907
+ phone: PhoneNumber
908
+ legal_person_id: str
909
+ role: OperatorRole
910
+
911
+ model_config = ConfigDict(
912
+ json_schema_extra={
913
+ 'example': {
914
+ 'name': 'Maria Lopez',
915
+ 'email': 'maria.lopez@aceros.com',
916
+ 'phone': '+525512345678',
917
+ 'legal_person_id': 'USWqY5cvkISJOxHyEKjAKf8w',
918
+ 'role': 'operator',
919
+ }
920
+ },
921
+ )
922
+
923
+ @field_validator('email', mode='before')
924
+ @classmethod
925
+ def validate_email(cls, email: str) -> str:
926
+ return normalize_email(email)
927
+
928
+
929
+ class OperatorUpdateRequest(BaseRequest):
930
+ name: Optional[str] = None
931
+ phone: Optional[PhoneNumber] = None
932
+ role: Optional[OperatorRole] = None
933
+ status: Optional[OperatorStatus] = None
934
+
935
+ @model_validator(mode="before")
936
+ @classmethod
937
+ def check_at_least_one_param(cls, values: DictStrAny) -> DictStrAny:
938
+ if not values:
939
+ raise ValueError('At least one parameter must be provided')
940
+ return values
941
+
942
+
943
+ class OperatorLoginRequest(BaseRequest):
944
+ email: EmailStr
945
+ password: Annotated[Password, LogConfig(masked=True)]
946
+
947
+ model_config = ConfigDict(
948
+ json_schema_extra={
949
+ 'example': {
950
+ 'email': 'maria.lopez@aceros.com',
951
+ 'password': 'supersecret',
952
+ }
953
+ },
954
+ )
955
+
956
+ @field_validator('email', mode='before')
957
+ @classmethod
958
+ def validate_email(cls, email: str) -> str:
959
+ return normalize_email(email)
960
+
961
+
902
962
  class PhoneVerificationAssociationRequest(BaseRequest):
903
963
  verification_id: str
@@ -0,0 +1 @@
1
+ __version__ = '2.1.44'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cuenca_validations
3
- Version: 2.1.43
3
+ Version: 2.1.44
4
4
  Summary: Cuenca common validations
5
5
  Home-page: https://github.com/cuenca-mx/cuenca-validations
6
6
  Author: Cuenca
@@ -2,8 +2,16 @@ import pytest
2
2
  from pydantic import ValidationError
3
3
  from pydantic_extra_types.phone_numbers import PhoneNumber
4
4
 
5
- from cuenca_validations.types.enums import Country, VerificationType
5
+ from cuenca_validations.types.enums import (
6
+ Country,
7
+ OperatorRole,
8
+ VerificationType,
9
+ )
10
+ from cuenca_validations.types.queries import OperatorQuery
6
11
  from cuenca_validations.types.requests import (
12
+ OperatorLoginRequest,
13
+ OperatorRequest,
14
+ OperatorUpdateRequest,
7
15
  PasswordResetRequest,
8
16
  UpdateTransferRequest,
9
17
  UserTOSAgreementRequest,
@@ -13,6 +21,88 @@ from cuenca_validations.types.requests import (
13
21
  from cuenca_validations.typing import DictStrAny
14
22
 
15
23
 
24
+ def test_operator_request_valid() -> None:
25
+ req = OperatorRequest(
26
+ name='Maria Lopez',
27
+ email='Maria+Tag@Aceros.com',
28
+ phone=PhoneNumber('+525512345678'),
29
+ legal_person_id='USWqY5cvkISJOxHyEKjAKf8w',
30
+ role=OperatorRole.operator,
31
+ )
32
+ assert req.email == 'maria@aceros.com'
33
+
34
+
35
+ def test_operator_request_rejects_invalid_role() -> None:
36
+ with pytest.raises(ValidationError) as ex:
37
+ OperatorRequest.model_validate(
38
+ {
39
+ 'name': 'Maria Lopez',
40
+ 'email': 'maria@aceros.com',
41
+ 'phone': '+525512345678',
42
+ 'legal_person_id': 'USWqY5cvkISJOxHyEKjAKf8w',
43
+ 'role': 'admin',
44
+ }
45
+ )
46
+ assert 'role' in str(ex.value)
47
+
48
+
49
+ def test_operator_update_requires_at_least_one_param() -> None:
50
+ with pytest.raises(ValueError) as ex:
51
+ OperatorUpdateRequest()
52
+ assert 'At least one parameter must be provided' in str(ex.value)
53
+
54
+
55
+ def test_operator_update_valid() -> None:
56
+ req = OperatorUpdateRequest.model_validate({'name': 'New name'})
57
+ assert req.name == 'New name'
58
+
59
+
60
+ def test_operator_login_request_valid() -> None:
61
+ req = OperatorLoginRequest.model_validate(
62
+ {
63
+ 'email': 'Operator+Tag@Aceros.com',
64
+ 'password': 'supersecret',
65
+ }
66
+ )
67
+ assert req.email == 'operator@aceros.com'
68
+
69
+
70
+ def test_operator_login_request_rejects_short_password() -> None:
71
+ with pytest.raises(ValidationError) as ex:
72
+ OperatorLoginRequest.model_validate(
73
+ {
74
+ 'email': 'operator@aceros.com',
75
+ 'password': 'short',
76
+ }
77
+ )
78
+ assert 'password' in str(ex.value)
79
+
80
+
81
+ def test_operator_login_request_forbids_extra() -> None:
82
+ with pytest.raises(ValidationError) as ex:
83
+ OperatorLoginRequest.model_validate(
84
+ {
85
+ 'email': 'operator@aceros.com',
86
+ 'password': 'supersecret',
87
+ 'foo': 'bar',
88
+ }
89
+ )
90
+ assert 'Extra inputs are not permitted' in str(ex.value)
91
+
92
+
93
+ def test_operator_query_valid() -> None:
94
+ query = OperatorQuery.model_validate({'email': 'maria.lopez@aceros.com'})
95
+ assert str(query.email) == 'maria.lopez@aceros.com'
96
+
97
+
98
+ def test_operator_query_forbids_extra() -> None:
99
+ with pytest.raises(ValidationError) as ex:
100
+ OperatorQuery.model_validate(
101
+ {'email': 'maria@aceros.com', 'foo': 'bar'}
102
+ )
103
+ assert 'Extra inputs are not permitted' in str(ex.value)
104
+
105
+
16
106
  @pytest.mark.parametrize('environment', ['api.stage', 'api.sandbox', 'api'])
17
107
  def test_file_cuenca_url(environment: str) -> None:
18
108
  request_data: DictStrAny = dict(
@@ -1 +0,0 @@
1
- __version__ = '2.1.43'