cuenca-validations 2.1.38.dev2__py3-none-any.whl → 2.1.39__py3-none-any.whl

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.
@@ -2,13 +2,14 @@ __all__ = [
2
2
  'AccountUseType',
3
3
  'AccountQuery',
4
4
  'Address',
5
+ 'AgentQuery',
6
+ 'AgentRequest',
5
7
  'ApiKeyQuery',
6
8
  'ApiKeyUpdateRequest',
7
9
  'AuthorizerTransaction',
8
10
  'BalanceEntryQuery',
9
11
  'BankAccountValidationQuery',
10
12
  'BankAccountValidationRequest',
11
- 'BankCode',
12
13
  'PostalCodeQuery',
13
14
  'UsersTOSQuery',
14
15
  'TOSQuery',
@@ -46,7 +47,6 @@ __all__ = [
46
47
  'FileRequest',
47
48
  'FileUploadRequest',
48
49
  'FraudFundsTransferRequest',
49
- 'FraudFundsTransferTipoPago',
50
50
  'Gender',
51
51
  'IncomeType',
52
52
  'IssuerNetwork',
@@ -147,7 +147,6 @@ from .enums import (
147
147
  EventType,
148
148
  FileExtension,
149
149
  FileFormat,
150
- FraudFundsTransferTipoPago,
151
150
  Gender,
152
151
  IncomeType,
153
152
  IssuerNetwork,
@@ -178,7 +177,6 @@ from .enums import (
178
177
  )
179
178
  from .files import BatchFileMetadata
180
179
  from .general import (
181
- BankCode,
182
180
  JSONEncoder,
183
181
  LogConfig,
184
182
  SantizedDict,
@@ -204,6 +202,7 @@ from .identities import (
204
202
  )
205
203
  from .queries import (
206
204
  AccountQuery,
205
+ AgentQuery,
207
206
  ApiKeyQuery,
208
207
  BalanceEntryQuery,
209
208
  BankAccountValidationQuery,
@@ -227,6 +226,7 @@ from .queries import (
227
226
  WalletTransactionQuery,
228
227
  )
229
228
  from .requests import (
229
+ AgentRequest,
230
230
  ApiKeyUpdateRequest,
231
231
  BankAccountValidationRequest,
232
232
  BeneficiaryRequest,
@@ -1,4 +1,4 @@
1
- from enum import Enum, IntEnum
1
+ from enum import Enum
2
2
 
3
3
 
4
4
  class CardNetwork(str, Enum):
@@ -589,6 +589,7 @@ class SessionType(str, Enum):
589
589
  account_entries = 'session.account_entries'
590
590
  download_file = 'session.download_file'
591
591
  upload_file = 'session.upload_file'
592
+ agent = 'session.agent'
592
593
 
593
594
 
594
595
  class WebhookObject(str, Enum):
@@ -743,9 +744,3 @@ class RequiredAction(str, Enum):
743
744
  level_up_required = 'level_up_required'
744
745
  level_up_invitation = 'level_up_invitation'
745
746
  fix_documents = 'fix_documents'
746
-
747
-
748
- class FraudFundsTransferTipoPago(IntEnum):
749
- participante_participante = 7
750
- devolucion_especial_ordenes_aceptadas_acreditadas = 23
751
- devolucion_extemporanea_especial_ordenes_acreditadas = 24
@@ -2,7 +2,6 @@ import json
2
2
  from dataclasses import dataclass
3
3
  from typing import Annotated, Any, Optional
4
4
 
5
- from clabe import BANK_NAMES
6
5
  from pydantic import (
7
6
  AfterValidator,
8
7
  AnyUrl,
@@ -42,19 +41,6 @@ NormalizedName = Annotated[
42
41
  ]
43
42
 
44
43
 
45
- def validate_bank_code(bank_code: str) -> str:
46
- if bank_code not in BANK_NAMES:
47
- raise ValueError('Not a valid bank code')
48
- return bank_code
49
-
50
-
51
- BankCode = Annotated[
52
- str,
53
- StringConstraints(strip_whitespace=True),
54
- AfterValidator(validate_bank_code),
55
- ]
56
-
57
-
58
44
  class SantizedDict(dict):
59
45
  def __init__(self, *args, **kwargs):
60
46
  super().__init__(*args, **kwargs)
@@ -193,6 +193,10 @@ class SessionQuery(QueryParams):
193
193
  type: SessionType
194
194
 
195
195
 
196
+ class AgentQuery(QueryParams):
197
+ active: Optional[bool] = None
198
+
199
+
196
200
  class FileQuery(QueryParams):
197
201
  type: Optional[KYCFileType] = None
198
202
  id: Optional[str] = None
@@ -1,7 +1,7 @@
1
1
  import datetime as dt
2
2
  from typing import Annotated, Any, Optional, Union
3
3
 
4
- from clabe import Clabe
4
+ from clabe import BANK_NAMES, Clabe
5
5
  from pydantic import (
6
6
  BaseModel,
7
7
  ConfigDict,
@@ -29,7 +29,6 @@ from ..types.enums import (
29
29
  Country,
30
30
  EcommerceIndicator,
31
31
  FileExtension,
32
- FraudFundsTransferTipoPago,
33
32
  Gender,
34
33
  IncomeType,
35
34
  IssuerNetwork,
@@ -67,7 +66,6 @@ from .card import (
67
66
  StrictPaymentCardNumber,
68
67
  )
69
68
  from .general import (
70
- BankCode,
71
69
  LogConfig,
72
70
  NonEmptyStr,
73
71
  SerializableAnyUrl,
@@ -329,17 +327,21 @@ class WalletTransactionRequest(BaseRequest):
329
327
  class FraudFundsTransferRequest(BaseRequest):
330
328
  user_id: NonEmptyStr
331
329
  clabe: Optional[Clabe] = None
332
- bank_code: Optional[BankCode] = None
333
- tipo_pago: Optional[FraudFundsTransferTipoPago] = None
330
+ bank_code: Optional[str] = None
334
331
  amount: Optional[StrictPositiveInt] = None
335
332
  concepto: Optional[NonEmptyStr] = None
336
333
 
334
+ @field_validator('bank_code')
335
+ @classmethod
336
+ def validate_bank_code(cls, bank_code: Optional[str]) -> Optional[str]:
337
+ if bank_code is not None and bank_code not in BANK_NAMES:
338
+ raise ValueError('Not a valid bank code')
339
+ return bank_code
340
+
337
341
  @model_validator(mode='after')
338
342
  def validate_destination(self) -> 'FraudFundsTransferRequest':
339
343
  if self.clabe is None and self.bank_code is None:
340
344
  raise ValueError('clabe or bank_code required')
341
- if self.bank_code is not None and self.tipo_pago is None:
342
- raise ValueError('tipo_pago required when using bank_code')
343
345
  return self
344
346
 
345
347
 
@@ -643,6 +645,21 @@ class SessionRequest(BaseRequest):
643
645
  )
644
646
 
645
647
 
648
+ class AgentRequest(BaseRequest):
649
+ pairing_code: str
650
+ phone_number: PhoneNumber
651
+ device_info: DictStrAny = Field(default_factory=dict)
652
+ model_config = ConfigDict(
653
+ json_schema_extra={
654
+ 'example': {
655
+ 'pairing_code': 'secret_code',
656
+ 'phone_number': '+525512345678',
657
+ 'device_info': {'client': 'cursor', 'os': 'macOS'},
658
+ }
659
+ }
660
+ )
661
+
662
+
646
663
  class EndpointRequest(BaseRequest):
647
664
  url: SerializableHttpUrl
648
665
  events: Optional[list[WebhookEvent]] = None
@@ -1 +1 @@
1
- __version__ = '2.1.38.dev2'
1
+ __version__ = '2.1.39'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cuenca_validations
3
- Version: 2.1.38.dev2
3
+ Version: 2.1.39
4
4
  Summary: Cuenca common validations
5
5
  Home-page: https://github.com/cuenca-mx/cuenca-validations
6
6
  Author: Cuenca
@@ -4,27 +4,27 @@ cuenca_validations/errors.py,sha256=OtM8EgiKqYdz9Hn66AbBO96orL1or7efkyt0vh0Zxbs,
4
4
  cuenca_validations/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  cuenca_validations/typing.py,sha256=1QCu81IbVZZpyInjyeAuO-nF36gpT5Gi4o6V9PozuOU,204
6
6
  cuenca_validations/validators.py,sha256=zXSnU5-EMbQZBD-PfFXgP4Z6G7cm7KFDWXB7Nie6WUk,2682
7
- cuenca_validations/version.py,sha256=7q0-xL57DP35yE_ZWFqUudz4RweXMDO779zWULY6jvA,28
8
- cuenca_validations/types/__init__.py,sha256=MuaKIoDkRyu9zIGpge0B1INHGK8NpIFhyH5ldXb5ADE,5735
7
+ cuenca_validations/version.py,sha256=fxvFZHn365ly6Wo79iyEaKVUDccrsv0pyHqS5dxQxZY,23
8
+ cuenca_validations/types/__init__.py,sha256=EyusEtrFFMlzswaFIU5DbcGAQQy2VnF2yRdc_yYIf2o,5711
9
9
  cuenca_validations/types/card.py,sha256=UGzz8NTFAverUmdUKAK1oGHnOnjSNTpIRUm93vKSSGY,1295
10
- cuenca_validations/types/enums.py,sha256=CBdFbrrw1w-PmBpRekYhN6b0Awqbf2-oxDzHZmvgqY0,20795
10
+ cuenca_validations/types/enums.py,sha256=lR54AWnM85-b8EOlhNaAhXLu1UiBVBbuV4f-LjChD1c,20614
11
11
  cuenca_validations/types/files.py,sha256=2CszbwF9ytXV9suFFwyDjYG4XxY8UhCjRw3HttVXXNw,269
12
- cuenca_validations/types/general.py,sha256=ldYUnlrzQdPnJ8ADenr_4PCScUwxjRacpsVO1s60Uy0,5928
12
+ cuenca_validations/types/general.py,sha256=eYFYwyx_a4_J480GYpqW3DFbZabDFcUjvLRMQbShIUc,5622
13
13
  cuenca_validations/types/helpers.py,sha256=4veeLZbugHHqZk0ezSim978VhH6Vq8XTrEhe1eE_r3A,1531
14
14
  cuenca_validations/types/identities.py,sha256=j2xxh3UYHJe6IbAwr9yNXJkebTth_-g3SUmHeiPez8M,5513
15
15
  cuenca_validations/types/morals.py,sha256=davabh5hAnFVQyM7-yCyDaT5ewXnm0cr1BtqDIwzkX8,1833
16
- cuenca_validations/types/queries.py,sha256=OonJ6CBDR6OF_kTv49AsE3zLEzQPCF4xpSqzSBpQgEs,5795
17
- cuenca_validations/types/requests.py,sha256=XeXdiSl7ptZAYK4w9uaPNBj_0V16ymj8MvLVwRfc2Cw,25180
18
- cuenca_validations-2.1.38.dev2.dist-info/licenses/LICENSE,sha256=wR76FmxBbfnQpwELkkE5iMF8sFIafEMgXLTE4N4WPTc,1063
16
+ cuenca_validations/types/queries.py,sha256=KnS_jbuUn5k1dZhliEyFxvttfZ22w0hO5x4qTsZR2g0,5862
17
+ cuenca_validations/types/requests.py,sha256=pEaJ55wQ948ymAl_gvG-yWgj0_abYHcGwTudcNVXIw4,25640
18
+ cuenca_validations-2.1.39.dist-info/licenses/LICENSE,sha256=wR76FmxBbfnQpwELkkE5iMF8sFIafEMgXLTE4N4WPTc,1063
19
19
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  tests/test_card.py,sha256=QAfRz7e11gWICPnFJZ2tiYgUsFV3C9TwzJXrDnDNXFw,1202
21
21
  tests/test_errors.py,sha256=ixiIgEuBuzfsL5p4uCFdF32XqFRtTPF6EVhGJ0keOrI,930
22
22
  tests/test_helpers.py,sha256=fx2R7y6oQO8XeQzevJe826NuHkBgvtznZicomchB3Gg,899
23
23
  tests/test_requests.py,sha256=3XMx2A-BK21g1Exm4RTVm6eKTOzeZH-8FzKJXQmmMmA,4141
24
24
  tests/test_statement.py,sha256=IOE0rRRBgBZSJv_FLaETEyn5NzzXKMNTqgjv99GX-68,1436
25
- tests/test_types.py,sha256=T4CssoCeRJrgOPs9D6YehEXfK_2aFUKecY6xPaougPw,24496
25
+ tests/test_types.py,sha256=rPjqPGfPU73MSdbeJpoW_ai5TAO25hWSnQAt_H7ZIeI,23055
26
26
  tests/test_validators.py,sha256=Jjr9gWTT4cRntGiKvQK4fncqx3JkEuTWkKm1VqpRHTs,1829
27
- cuenca_validations-2.1.38.dev2.dist-info/METADATA,sha256=iRAK0IQtrdsDQF4hqs8p9sUEr1Qw9IRkisXfZemj75Q,1600
28
- cuenca_validations-2.1.38.dev2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
29
- cuenca_validations-2.1.38.dev2.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
30
- cuenca_validations-2.1.38.dev2.dist-info/RECORD,,
27
+ cuenca_validations-2.1.39.dist-info/METADATA,sha256=1DrvA9gxu2Sw7IdZ9zg5DsfrAgJSYl11SlCnBDnDtIE,1595
28
+ cuenca_validations-2.1.39.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
29
+ cuenca_validations-2.1.39.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
30
+ cuenca_validations-2.1.39.dist-info/RECORD,,
tests/test_types.py CHANGED
@@ -675,73 +675,19 @@ def test_bank_account_validation_clabe_request():
675
675
  assert BankAccountValidationRequest(account_number='646180157098510917')
676
676
 
677
677
 
678
- @pytest.mark.parametrize(
679
- 'data, expected_dump',
680
- [
681
- (
682
- dict(
683
- user_id='US123',
684
- clabe='646180157098510917',
685
- amount=10000,
686
- concepto=' Devolución fraude ',
687
- ),
688
- dict(
689
- user_id='US123',
690
- clabe='646180157098510917',
691
- amount=10000,
692
- concepto='Devolución fraude',
693
- ),
694
- ),
695
- (
696
- dict(user_id='US123', clabe='646180157098510917'),
697
- dict(user_id='US123', clabe='646180157098510917'),
698
- ),
699
- *[
700
- (
701
- dict(
702
- user_id='US123',
703
- bank_code='40012',
704
- tipo_pago=tipo_pago,
705
- amount=5000,
706
- ),
707
- dict(
708
- user_id='US123',
709
- bank_code='40012',
710
- tipo_pago=tipo_pago,
711
- amount=5000,
712
- ),
713
- )
714
- for tipo_pago in (7, 23, 24)
715
- ],
716
- ],
717
- )
718
- def test_fraud_funds_transfer_request(data, expected_dump):
719
- request = FraudFundsTransferRequest(**data)
720
- assert request.model_dump() == expected_dump
678
+ def test_fraud_funds_transfer_request():
679
+ assert FraudFundsTransferRequest(
680
+ user_id='US123',
681
+ bank_code='40012',
682
+ ).model_dump() == {'user_id': 'US123', 'bank_code': '40012'}
721
683
 
684
+ with pytest.raises(ValidationError) as exc:
685
+ FraudFundsTransferRequest(user_id='US123')
686
+ assert 'clabe or bank_code required' in str(exc.value)
722
687
 
723
- @pytest.mark.parametrize(
724
- 'data, expected_error',
725
- [
726
- (dict(user_id='US123'), 'clabe or bank_code required'),
727
- (
728
- dict(user_id='US123', bank_code='40012'),
729
- 'tipo_pago required when using bank_code',
730
- ),
731
- (
732
- dict(user_id='US123', bank_code='40012', tipo_pago=1),
733
- 'Input should be 7, 23 or 24',
734
- ),
735
- (
736
- dict(user_id='US123', bank_code='99999', tipo_pago=7),
737
- 'Not a valid bank code',
738
- ),
739
- ],
740
- )
741
- def test_fraud_funds_transfer_request_invalid(data, expected_error):
742
688
  with pytest.raises(ValidationError) as exc:
743
- FraudFundsTransferRequest(**data)
744
- assert expected_error in str(exc.value)
689
+ FraudFundsTransferRequest(user_id='US123', bank_code='99999')
690
+ assert 'Not a valid bank code' in str(exc.value)
745
691
 
746
692
 
747
693
  @pytest.mark.parametrize(