cuenca-validations 2.1.48.dev2__py3-none-any.whl → 2.1.49.dev0__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.
@@ -83,7 +83,6 @@ __all__ = [
83
83
  'Profession',
84
84
  'QueryParams',
85
85
  'ReferencedClabeRequest',
86
- 'RejectTransferOrderRequest',
87
86
  'LegalRfc',
88
87
  'Rfc',
89
88
  'QuestionnairesRequest',
@@ -114,6 +113,7 @@ __all__ = [
114
113
  'TransferOrderStatus',
115
114
  'TransferQuery',
116
115
  'TransferRequest',
116
+ 'UpdateTransferOrderRequest',
117
117
  'UpdateTransferRequest',
118
118
  'UserCardNotification',
119
119
  'UserCredentialRequest',
@@ -280,7 +280,6 @@ from .requests import (
280
280
  PlatformRequest,
281
281
  QuestionnairesRequest,
282
282
  ReferencedClabeRequest,
283
- RejectTransferOrderRequest,
284
283
  SavingRequest,
285
284
  SavingUpdateRequest,
286
285
  SessionRequest,
@@ -289,6 +288,7 @@ from .requests import (
289
288
  TransferOrderLineRequest,
290
289
  TransferOrderRequest,
291
290
  TransferRequest,
291
+ UpdateTransferOrderRequest,
292
292
  UpdateTransferRequest,
293
293
  UserCredentialRequest,
294
294
  UserCredentialUpdateRequest,
@@ -1,5 +1,5 @@
1
1
  import datetime as dt
2
- from typing import Annotated, Any, Optional, Union
2
+ from typing import Annotated, Any, Literal, Optional, Union
3
3
 
4
4
  from clabe import BANK_NAMES, Clabe
5
5
  from pydantic import (
@@ -50,6 +50,7 @@ from ..types.enums import (
50
50
  TrackDataMethod,
51
51
  TransactionStatus,
52
52
  TransactionTokenValidationStatus,
53
+ TransferOrderStatus,
53
54
  UserCardNotification,
54
55
  UserStatus,
55
56
  VerificationStatus,
@@ -1068,11 +1069,34 @@ class TransferOrderRequest(BaseRequest):
1068
1069
  return self
1069
1070
 
1070
1071
 
1071
- class RejectTransferOrderRequest(BaseRequest):
1072
- rejection_reason: str
1072
+ class UpdateTransferOrderRequest(BaseRequest):
1073
+ status: Literal[
1074
+ TransferOrderStatus.authorized, TransferOrderStatus.rejected
1075
+ ]
1076
+ rejection_reason: Optional[str] = None
1073
1077
 
1074
1078
  model_config = ConfigDict(
1075
1079
  json_schema_extra={
1076
- 'example': {'rejection_reason': 'Monto incorrecto'},
1080
+ 'examples': [
1081
+ {'status': 'authorized'},
1082
+ {
1083
+ 'status': 'rejected',
1084
+ 'rejection_reason': 'Monto incorrecto',
1085
+ },
1086
+ ]
1077
1087
  },
1078
1088
  )
1089
+
1090
+ @model_validator(mode='after')
1091
+ def validate_rejection_reason(self) -> 'UpdateTransferOrderRequest':
1092
+ if self.status is TransferOrderStatus.rejected:
1093
+ if (
1094
+ self.rejection_reason is None
1095
+ or not self.rejection_reason.strip()
1096
+ ):
1097
+ raise ValueError('rejection_reason is required')
1098
+ elif self.rejection_reason is not None:
1099
+ raise ValueError(
1100
+ 'rejection_reason is only allowed when status is rejected'
1101
+ )
1102
+ return self
@@ -1 +1 @@
1
- __version__ = '2.1.48.dev2'
1
+ __version__ = '2.1.49.dev0'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cuenca_validations
3
- Version: 2.1.48.dev2
3
+ Version: 2.1.49.dev0
4
4
  Summary: Cuenca common validations
5
5
  Home-page: https://github.com/cuenca-mx/cuenca-validations
6
6
  Author: Cuenca
@@ -4,8 +4,8 @@ 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=WiG1nA9P-LOoeeac7LvTU5c6xyEwI2zmIZJ7cJBZ67U,28
8
- cuenca_validations/types/__init__.py,sha256=VZu01odevifIR7SR9-lpJC2Ysee8QLwVnIOj7cjEUTU,6711
7
+ cuenca_validations/version.py,sha256=E1OKARtICq_n0Q4ukZ9yaw-H6GS0VhkKcaXf2C4kIGg,28
8
+ cuenca_validations/types/__init__.py,sha256=M657giDGa3sejskWMPIAfCXJHDgbh4p9J9BnheKJR-A,6711
9
9
  cuenca_validations/types/card.py,sha256=UGzz8NTFAverUmdUKAK1oGHnOnjSNTpIRUm93vKSSGY,1295
10
10
  cuenca_validations/types/enums.py,sha256=If8N4-AbM9daHmnH6txmBb9AqN0Ey7gi3jmkOZOIDAU,21104
11
11
  cuenca_validations/types/files.py,sha256=2CszbwF9ytXV9suFFwyDjYG4XxY8UhCjRw3HttVXXNw,269
@@ -14,17 +14,17 @@ cuenca_validations/types/helpers.py,sha256=4veeLZbugHHqZk0ezSim978VhH6Vq8XTrEhe1
14
14
  cuenca_validations/types/identities.py,sha256=j2xxh3UYHJe6IbAwr9yNXJkebTth_-g3SUmHeiPez8M,5513
15
15
  cuenca_validations/types/morals.py,sha256=davabh5hAnFVQyM7-yCyDaT5ewXnm0cr1BtqDIwzkX8,1833
16
16
  cuenca_validations/types/queries.py,sha256=yJZGW3p6uWGaBm6mjDp7KBgg7oLh0CUlAJeeVLRzowk,6134
17
- cuenca_validations/types/requests.py,sha256=Ud4sxo-B5dRAbTtYB6lcFJzSknT2yMms1WVjGZ7YlDo,31485
18
- cuenca_validations-2.1.48.dev2.dist-info/licenses/LICENSE,sha256=wR76FmxBbfnQpwELkkE5iMF8sFIafEMgXLTE4N4WPTc,1063
17
+ cuenca_validations/types/requests.py,sha256=26YyfGHh1egdjAHUWTDjTtelXARWKNPB6npPHkW1Tcg,32336
18
+ cuenca_validations-2.1.49.dev0.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
- tests/test_requests.py,sha256=hS7uqo3pdi5lO-miDBNxO7S0lpI6tzAimBpBnx02e3E,8377
23
+ tests/test_requests.py,sha256=NlXAvKDLyVy0tYDUHy3oNkxeX1KcA-dfyqwftddHWBo,10627
24
24
  tests/test_statement.py,sha256=IOE0rRRBgBZSJv_FLaETEyn5NzzXKMNTqgjv99GX-68,1436
25
25
  tests/test_types.py,sha256=rPjqPGfPU73MSdbeJpoW_ai5TAO25hWSnQAt_H7ZIeI,23055
26
26
  tests/test_validators.py,sha256=Jjr9gWTT4cRntGiKvQK4fncqx3JkEuTWkKm1VqpRHTs,1829
27
- cuenca_validations-2.1.48.dev2.dist-info/METADATA,sha256=XgN9tibEGrut9ztzILQMoq4bAwxpRGvocKzsBAroG5g,1600
28
- cuenca_validations-2.1.48.dev2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
29
- cuenca_validations-2.1.48.dev2.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
30
- cuenca_validations-2.1.48.dev2.dist-info/RECORD,,
27
+ cuenca_validations-2.1.49.dev0.dist-info/METADATA,sha256=7CzNDGl4cHPMNcq-p0u36AMzFYj2tFFmM34sc-pfn_E,1600
28
+ cuenca_validations-2.1.49.dev0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
29
+ cuenca_validations-2.1.49.dev0.dist-info/top_level.txt,sha256=4233xdOs2HtuT-GFRjcDcwK0IwdwvWdczOtk0fPB6Gw,25
30
+ cuenca_validations-2.1.49.dev0.dist-info/RECORD,,
tests/test_requests.py CHANGED
@@ -5,6 +5,7 @@ from pydantic_extra_types.phone_numbers import PhoneNumber
5
5
  from cuenca_validations.types.enums import (
6
6
  Country,
7
7
  OperatorRole,
8
+ TransferOrderStatus,
8
9
  VerificationType,
9
10
  )
10
11
  from cuenca_validations.types.queries import OperatorQuery
@@ -15,6 +16,7 @@ from cuenca_validations.types.requests import (
15
16
  OperatorUpdateRequest,
16
17
  PasswordResetRequest,
17
18
  TransferOrderRequest,
19
+ UpdateTransferOrderRequest,
18
20
  UpdateTransferRequest,
19
21
  UserTOSAgreementRequest,
20
22
  UserUpdateRequest,
@@ -259,3 +261,57 @@ def test_transfer_order_request_shape() -> None:
259
261
  )
260
262
  with pytest.raises(ValidationError):
261
263
  TransferOrderRequest.model_validate({'idempotency_key': 'missing'})
264
+
265
+
266
+ def test_update_transfer_order_request_authorized() -> None:
267
+ req = UpdateTransferOrderRequest.model_validate({'status': 'authorized'})
268
+ assert req.status is TransferOrderStatus.authorized
269
+ assert req.rejection_reason is None
270
+
271
+
272
+ def test_update_transfer_order_request_rejected() -> None:
273
+ req = UpdateTransferOrderRequest.model_validate(
274
+ {'status': 'rejected', 'rejection_reason': 'Monto incorrecto'}
275
+ )
276
+ assert req.status is TransferOrderStatus.rejected
277
+ assert req.rejection_reason == 'Monto incorrecto'
278
+
279
+
280
+ def test_update_transfer_order_request_rejected_requires_reason() -> None:
281
+ with pytest.raises(ValidationError, match='rejection_reason is required'):
282
+ UpdateTransferOrderRequest.model_validate({'status': 'rejected'})
283
+ with pytest.raises(ValidationError, match='rejection_reason is required'):
284
+ UpdateTransferOrderRequest.model_validate(
285
+ {'status': 'rejected', 'rejection_reason': ''}
286
+ )
287
+ with pytest.raises(ValidationError, match='rejection_reason is required'):
288
+ UpdateTransferOrderRequest.model_validate(
289
+ {'status': 'rejected', 'rejection_reason': ' '}
290
+ )
291
+
292
+
293
+ def test_update_transfer_order_request_authorized_forbids_reason() -> None:
294
+ with pytest.raises(
295
+ ValidationError,
296
+ match='rejection_reason is only allowed when status is rejected',
297
+ ):
298
+ UpdateTransferOrderRequest.model_validate(
299
+ {'status': 'authorized', 'rejection_reason': 'no'}
300
+ )
301
+
302
+
303
+ def test_update_transfer_order_request_rejects_invalid_status() -> None:
304
+ with pytest.raises(ValidationError):
305
+ UpdateTransferOrderRequest.model_validate({'status': 'created'})
306
+ with pytest.raises(ValidationError):
307
+ UpdateTransferOrderRequest.model_validate({'status': 'expired'})
308
+ with pytest.raises(ValidationError):
309
+ UpdateTransferOrderRequest.model_validate({})
310
+
311
+
312
+ def test_update_transfer_order_request_forbids_extra() -> None:
313
+ with pytest.raises(ValidationError) as ex:
314
+ UpdateTransferOrderRequest.model_validate(
315
+ {'status': 'authorized', 'operator_id': 'OP123'}
316
+ )
317
+ assert 'Extra inputs are not permitted' in str(ex.value)