cuenca-validations 2.1.43__tar.gz → 2.1.45__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.45}/PKG-INFO +1 -1
  2. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/types/__init__.py +18 -0
  3. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/types/enums.py +15 -0
  4. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/types/queries.py +4 -0
  5. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/types/requests.py +94 -0
  6. cuenca_validations-2.1.45/cuenca_validations/version.py +1 -0
  7. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations.egg-info/PKG-INFO +1 -1
  8. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/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.45}/LICENSE +0 -0
  11. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/README.md +0 -0
  12. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/__init__.py +0 -0
  13. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/card_bins.py +0 -0
  14. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/errors.py +0 -0
  15. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/py.typed +0 -0
  16. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/types/card.py +0 -0
  17. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/types/files.py +0 -0
  18. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/types/general.py +0 -0
  19. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/types/helpers.py +0 -0
  20. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/types/identities.py +0 -0
  21. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/types/morals.py +0 -0
  22. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/typing.py +0 -0
  23. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations/validators.py +0 -0
  24. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations.egg-info/SOURCES.txt +0 -0
  25. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations.egg-info/dependency_links.txt +0 -0
  26. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations.egg-info/requires.txt +0 -0
  27. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/cuenca_validations.egg-info/top_level.txt +0 -0
  28. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/setup.cfg +0 -0
  29. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/setup.py +0 -0
  30. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/tests/__init__.py +0 -0
  31. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/tests/test_card.py +0 -0
  32. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/tests/test_errors.py +0 -0
  33. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/tests/test_helpers.py +0 -0
  34. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/tests/test_statement.py +0 -0
  35. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/tests/test_types.py +0 -0
  36. {cuenca_validations-2.1.43 → cuenca_validations-2.1.45}/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.45
4
4
  Summary: Cuenca common validations
5
5
  Home-page: https://github.com/cuenca-mx/cuenca-validations
6
6
  Author: Cuenca
@@ -1,6 +1,9 @@
1
1
  __all__ = [
2
2
  'AccountUseType',
3
3
  'AccountQuery',
4
+ 'AccountRequest',
5
+ 'AccountUpdateRequest',
6
+ 'AccountValidationStatus',
4
7
  'Address',
5
8
  'AgentQuery',
6
9
  'AgentRequest',
@@ -62,6 +65,12 @@ __all__ = [
62
65
  'MonthlySpendingType',
63
66
  'LegalPersonRequest',
64
67
  'LegalPersonUpdateRequest',
68
+ 'OperatorLoginRequest',
69
+ 'OperatorQuery',
70
+ 'OperatorRequest',
71
+ 'OperatorRole',
72
+ 'OperatorStatus',
73
+ 'OperatorUpdateRequest',
65
74
  'PartnerRequest',
66
75
  'PartnerUpdateRequest',
67
76
  'PasswordResetRequest',
@@ -132,6 +141,7 @@ __all__ = [
132
141
  from .card import StrictPaymentCardNumber
133
142
  from .enums import (
134
143
  AccountUseType,
144
+ AccountValidationStatus,
135
145
  AuthorizerTransaction,
136
146
  BankAccountStatus,
137
147
  CardErrorType,
@@ -158,6 +168,8 @@ from .enums import (
158
168
  Language,
159
169
  MonthlyMovementsType,
160
170
  MonthlySpendingType,
171
+ OperatorRole,
172
+ OperatorStatus,
161
173
  PlatformType,
162
174
  PosCapability,
163
175
  Profession,
@@ -216,6 +228,7 @@ from .queries import (
216
228
  EventQuery,
217
229
  FileQuery,
218
230
  IdentityQuery,
231
+ OperatorQuery,
219
232
  PostalCodeQuery,
220
233
  QueryParams,
221
234
  SessionQuery,
@@ -229,6 +242,8 @@ from .queries import (
229
242
  WalletTransactionQuery,
230
243
  )
231
244
  from .requests import (
245
+ AccountRequest,
246
+ AccountUpdateRequest,
232
247
  AgentRequest,
233
248
  ApiKeyUpdateRequest,
234
249
  BankAccountValidationRequest,
@@ -244,6 +259,9 @@ from .requests import (
244
259
  LegalPersonRequest,
245
260
  LegalPersonUpdateRequest,
246
261
  LimitedWalletRequest,
262
+ OperatorLoginRequest,
263
+ OperatorRequest,
264
+ OperatorUpdateRequest,
247
265
  PartnerRequest,
248
266
  PartnerUpdateRequest,
249
267
  PasswordResetRequest,
@@ -746,3 +746,18 @@ 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 AccountValidationStatus(str, Enum):
752
+ verified = 'verified'
753
+ pending = 'pending'
754
+
755
+
756
+ class OperatorRole(str, Enum):
757
+ operator = 'operator'
758
+ authorizer = 'authorizer'
759
+
760
+
761
+ class OperatorStatus(str, Enum):
762
+ active = 'active'
763
+ 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'
@@ -18,6 +18,7 @@ from pydantic_extra_types.coordinate import Coordinate
18
18
 
19
19
  from ..types.enums import (
20
20
  AccountUseType,
21
+ AccountValidationStatus,
21
22
  AuthorizerTransaction,
22
23
  CardDesign,
23
24
  CardFundingType,
@@ -36,6 +37,8 @@ from ..types.enums import (
36
37
  KYCValidationSource,
37
38
  MonthlyMovementsType,
38
39
  MonthlySpendingType,
40
+ OperatorRole,
41
+ OperatorStatus,
39
42
  PlatformType,
40
43
  PosCapability,
41
44
  Profession,
@@ -735,6 +738,39 @@ class LimitedWalletRequest(BaseRequest):
735
738
  allowed_rfc: Optional[Rfc] = None
736
739
 
737
740
 
741
+ class AccountRequest(BaseRequest):
742
+ name: StrictStr
743
+ account_number: Clabe
744
+ alias: Optional[StrictStr] = None
745
+ curp: Optional[Curp] = None
746
+ rfc: Optional[Rfc] = None
747
+
748
+ model_config = ConfigDict(
749
+ json_schema_extra={
750
+ 'example': {
751
+ 'name': 'Aceros del Norte SA de CV',
752
+ 'account_number': '072691004495711499',
753
+ 'alias': 'Proveedor acero',
754
+ }
755
+ },
756
+ )
757
+
758
+
759
+ class AccountUpdateRequest(BaseRequest):
760
+ name: Optional[StrictStr] = None
761
+ alias: Optional[StrictStr] = None
762
+ validation_status: Optional[AccountValidationStatus] = None
763
+
764
+ model_config = ConfigDict(
765
+ json_schema_extra={
766
+ 'example': {
767
+ 'alias': 'Fletes',
768
+ 'validation_status': 'verified',
769
+ }
770
+ },
771
+ )
772
+
773
+
738
774
  class PlatformRequest(BaseModel):
739
775
  name: str
740
776
  rfc: Optional[str] = None
@@ -899,5 +935,63 @@ class LegalPersonUpdateRequest(BaseRequest):
899
935
  legal_representatives: Optional[list[LegalRepresentative]] = None
900
936
 
901
937
 
938
+ class OperatorRequest(BaseRequest):
939
+ name: str
940
+ email: EmailStr
941
+ phone: PhoneNumber
942
+ legal_person_id: str
943
+ role: OperatorRole
944
+
945
+ model_config = ConfigDict(
946
+ json_schema_extra={
947
+ 'example': {
948
+ 'name': 'Maria Lopez',
949
+ 'email': 'maria.lopez@aceros.com',
950
+ 'phone': '+525512345678',
951
+ 'legal_person_id': 'USWqY5cvkISJOxHyEKjAKf8w',
952
+ 'role': 'operator',
953
+ }
954
+ },
955
+ )
956
+
957
+ @field_validator('email', mode='before')
958
+ @classmethod
959
+ def validate_email(cls, email: str) -> str:
960
+ return normalize_email(email)
961
+
962
+
963
+ class OperatorUpdateRequest(BaseRequest):
964
+ name: Optional[str] = None
965
+ phone: Optional[PhoneNumber] = None
966
+ role: Optional[OperatorRole] = None
967
+ status: Optional[OperatorStatus] = None
968
+
969
+ @model_validator(mode="before")
970
+ @classmethod
971
+ def check_at_least_one_param(cls, values: DictStrAny) -> DictStrAny:
972
+ if not values:
973
+ raise ValueError('At least one parameter must be provided')
974
+ return values
975
+
976
+
977
+ class OperatorLoginRequest(BaseRequest):
978
+ email: EmailStr
979
+ password: Annotated[Password, LogConfig(masked=True)]
980
+
981
+ model_config = ConfigDict(
982
+ json_schema_extra={
983
+ 'example': {
984
+ 'email': 'maria.lopez@aceros.com',
985
+ 'password': 'supersecret',
986
+ }
987
+ },
988
+ )
989
+
990
+ @field_validator('email', mode='before')
991
+ @classmethod
992
+ def validate_email(cls, email: str) -> str:
993
+ return normalize_email(email)
994
+
995
+
902
996
  class PhoneVerificationAssociationRequest(BaseRequest):
903
997
  verification_id: str
@@ -0,0 +1 @@
1
+ __version__ = '2.1.45'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cuenca_validations
3
- Version: 2.1.43
3
+ Version: 2.1.45
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'