cuenca 1.0.3.dev0__py3-none-any.whl → 2.0.0__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.
Files changed (51) hide show
  1. cuenca/__init__.py +3 -3
  2. cuenca/resources/__init__.py +2 -0
  3. cuenca/resources/api_keys.py +7 -6
  4. cuenca/resources/arpc.py +3 -3
  5. cuenca/resources/balance_entries.py +2 -4
  6. cuenca/resources/base.py +53 -27
  7. cuenca/resources/card_activations.py +2 -2
  8. cuenca/resources/card_transactions.py +5 -5
  9. cuenca/resources/card_validations.py +6 -8
  10. cuenca/resources/cards.py +4 -4
  11. cuenca/resources/curp_validations.py +42 -42
  12. cuenca/resources/deposits.py +1 -1
  13. cuenca/resources/endpoints.py +24 -29
  14. cuenca/resources/file_batches.py +14 -7
  15. cuenca/resources/files.py +1 -1
  16. cuenca/resources/identities.py +14 -14
  17. cuenca/resources/kyc_validations.py +10 -8
  18. cuenca/resources/kyc_verifications.py +10 -8
  19. cuenca/resources/limited_wallets.py +5 -5
  20. cuenca/resources/login_tokens.py +5 -2
  21. cuenca/resources/otps.py +27 -0
  22. cuenca/resources/platforms.py +25 -28
  23. cuenca/resources/questionnaires.py +5 -3
  24. cuenca/resources/resources.py +10 -6
  25. cuenca/resources/savings.py +5 -5
  26. cuenca/resources/service_providers.py +2 -2
  27. cuenca/resources/sessions.py +8 -7
  28. cuenca/resources/transfers.py +6 -6
  29. cuenca/resources/user_credentials.py +2 -2
  30. cuenca/resources/user_events.py +5 -2
  31. cuenca/resources/user_lists_validation.py +4 -4
  32. cuenca/resources/user_logins.py +6 -4
  33. cuenca/resources/users.py +45 -52
  34. cuenca/resources/verifications.py +10 -9
  35. cuenca/resources/wallet_transactions.py +2 -2
  36. cuenca/resources/webhooks.py +4 -9
  37. cuenca/resources/whatsapp_transfers.py +4 -4
  38. cuenca/version.py +1 -1
  39. {cuenca-1.0.3.dev0.dist-info → cuenca-2.0.0.dist-info}/METADATA +20 -7
  40. {cuenca-1.0.3.dev0.dist-info → cuenca-2.0.0.dist-info}/RECORD +51 -49
  41. {cuenca-1.0.3.dev0.dist-info → cuenca-2.0.0.dist-info}/WHEEL +1 -1
  42. tests/conftest.py +3 -4
  43. tests/resources/test_card_activations.py +4 -4
  44. tests/resources/test_cards.py +0 -8
  45. tests/resources/test_commissions.py +2 -2
  46. tests/resources/test_endpoints.py +1 -1
  47. tests/resources/test_otps.py +28 -0
  48. tests/resources/test_sessions.py +1 -5
  49. tests/resources/test_transfers.py +1 -1
  50. {cuenca-1.0.3.dev0.dist-info → cuenca-2.0.0.dist-info}/LICENSE +0 -0
  51. {cuenca-1.0.3.dev0.dist-info → cuenca-2.0.0.dist-info}/top_level.txt +0 -0
cuenca/__init__.py CHANGED
@@ -23,6 +23,7 @@ __all__ = [
23
23
  'KYCVerification',
24
24
  'LimitedWallet',
25
25
  'LoginToken',
26
+ 'Otp',
26
27
  'Platform',
27
28
  'Questionnaires',
28
29
  'Saving',
@@ -43,8 +44,6 @@ __all__ = [
43
44
  'get_balance',
44
45
  ]
45
46
 
46
- from typing import cast
47
-
48
47
  from . import http
49
48
  from .resources import (
50
49
  Account,
@@ -70,6 +69,7 @@ from .resources import (
70
69
  KYCVerification,
71
70
  LimitedWallet,
72
71
  LoginToken,
72
+ Otp,
73
73
  Platform,
74
74
  Questionnaires,
75
75
  Saving,
@@ -94,5 +94,5 @@ session = http.session
94
94
 
95
95
 
96
96
  def get_balance(session: http.Session = session) -> int:
97
- balance_entry = cast('BalanceEntry', BalanceEntry.first(session=session))
97
+ balance_entry = BalanceEntry.first(session=session)
98
98
  return balance_entry.rolling_balance if balance_entry else 0
@@ -22,6 +22,7 @@ __all__ = [
22
22
  'KYCVerification',
23
23
  'LimitedWallet',
24
24
  'LoginToken',
25
+ 'Otp',
25
26
  'Platform',
26
27
  'Questionnaires',
27
28
  'Saving',
@@ -62,6 +63,7 @@ from .kyc_validations import KYCValidation
62
63
  from .kyc_verifications import KYCVerification
63
64
  from .limited_wallets import LimitedWallet
64
65
  from .login_tokens import LoginToken
66
+ from .otps import Otp
65
67
  from .platforms import Platform
66
68
  from .questionnaires import Questionnaires
67
69
  from .resources import RESOURCES
@@ -2,6 +2,7 @@ import datetime as dt
2
2
  from typing import ClassVar, Optional
3
3
 
4
4
  from cuenca_validations.types import ApiKeyQuery, ApiKeyUpdateRequest
5
+ from pydantic import ConfigDict
5
6
 
6
7
  from ..http import Session, session as global_session
7
8
  from .base import Creatable, Queryable, Retrievable, Updateable
@@ -12,11 +13,10 @@ class ApiKey(Creatable, Queryable, Retrievable, Updateable):
12
13
  _query_params: ClassVar = ApiKeyQuery
13
14
 
14
15
  secret: str
15
- deactivated_at: Optional[dt.datetime]
16
- user_id: Optional[str]
17
-
18
- class Config:
19
- schema_extra = {
16
+ deactivated_at: Optional[dt.datetime] = None
17
+ user_id: Optional[str] = None
18
+ model_config = ConfigDict(
19
+ json_schema_extra={
20
20
  'example': {
21
21
  'id': 'AKNEUInh69SuKXXmK95sROwQ',
22
22
  'updated_at': '2021-08-24T14:15:22Z',
@@ -26,6 +26,7 @@ class ApiKey(Creatable, Queryable, Retrievable, Updateable):
26
26
  'user_id': 'USWqY5cvkISJOxHyEKjAKf8w',
27
27
  }
28
28
  }
29
+ )
29
30
 
30
31
  @property
31
32
  def active(self) -> bool:
@@ -74,4 +75,4 @@ class ApiKey(Creatable, Queryable, Retrievable, Updateable):
74
75
  req = ApiKeyUpdateRequest(
75
76
  metadata=metadata, user_id=user_id, platform_id=platform_id
76
77
  )
77
- return cls._update(api_key_id, **req.dict(), session=session)
78
+ return cls._update(api_key_id, **req.model_dump(), session=session)
cuenca/resources/arpc.py CHANGED
@@ -23,8 +23,8 @@ class Arpc(Creatable):
23
23
 
24
24
  created_at: dt.datetime
25
25
  card_uri: str
26
- is_valid_arqc: Optional[bool]
27
- arpc: Optional[str]
26
+ is_valid_arqc: Optional[bool] = None
27
+ arpc: Optional[str] = None
28
28
 
29
29
  @classmethod
30
30
  def create(
@@ -52,4 +52,4 @@ class Arpc(Creatable):
52
52
  unique_number=unique_number,
53
53
  track_data_method=track_data_method,
54
54
  )
55
- return cls._create(session=session, **req.dict())
55
+ return cls._create(session=session, **req.model_dump())
@@ -1,4 +1,4 @@
1
- from typing import ClassVar, TypeVar, cast
1
+ from typing import ClassVar, Union, cast
2
2
 
3
3
  from cuenca_validations.types import BalanceEntryQuery, EntryType
4
4
 
@@ -8,9 +8,7 @@ from .cards import Card
8
8
  from .resources import retrieve_uri
9
9
  from .service_providers import ServiceProvider
10
10
 
11
- FundingInstrument = TypeVar(
12
- 'FundingInstrument', Account, ServiceProvider, Card
13
- )
11
+ FundingInstrument = Union[Account, ServiceProvider, Card]
14
12
 
15
13
 
16
14
  class BalanceEntry(Retrievable, Queryable):
cuenca/resources/base.py CHANGED
@@ -2,7 +2,7 @@ import base64
2
2
  import datetime as dt
3
3
  import json
4
4
  from io import BytesIO
5
- from typing import ClassVar, Generator, Optional, Type, TypeVar
5
+ from typing import Any, ClassVar, Generator, Optional, Type, TypeVar, cast
6
6
  from urllib.parse import urlencode
7
7
 
8
8
  from cuenca_validations.types import (
@@ -12,13 +12,12 @@ from cuenca_validations.types import (
12
12
  TransactionQuery,
13
13
  TransactionStatus,
14
14
  )
15
- from pydantic import BaseModel, Extra
15
+ from pydantic import BaseModel, ConfigDict
16
16
 
17
17
  from ..exc import MultipleResultsFound, NoResultFound
18
18
  from ..http import Session, session as global_session
19
19
 
20
20
  R_co = TypeVar('R_co', bound='Resource', covariant=True)
21
- Q_co = TypeVar('Q_co', bound='Queryable', covariant=True)
22
21
 
23
22
 
24
23
  class Resource(BaseModel):
@@ -26,17 +25,21 @@ class Resource(BaseModel):
26
25
 
27
26
  id: str
28
27
 
29
- class Config:
30
- extra = Extra.ignore
28
+ model_config = ConfigDict(
29
+ extra="ignore",
30
+ )
31
31
 
32
32
  def to_dict(self):
33
- return SantizedDict(self.dict())
33
+ return SantizedDict(self.model_dump())
34
34
 
35
35
 
36
36
  class Retrievable(Resource):
37
37
  @classmethod
38
38
  def retrieve(
39
- cls: Type[R_co], id: str, *, session: Session = global_session
39
+ cls: Type[R_co],
40
+ id: str,
41
+ *,
42
+ session: Session = global_session,
40
43
  ) -> R_co:
41
44
  resp = session.get(f'/{cls._resource}/{id}')
42
45
  return cls(**resp)
@@ -50,7 +53,10 @@ class Retrievable(Resource):
50
53
  class Creatable(Resource):
51
54
  @classmethod
52
55
  def _create(
53
- cls: Type[R_co], *, session: Session = global_session, **data
56
+ cls: Type[R_co],
57
+ *,
58
+ session: Session = global_session,
59
+ **data: Any,
54
60
  ) -> R_co:
55
61
  resp = session.post(cls._resource, data)
56
62
  return cls(**resp)
@@ -62,18 +68,26 @@ class Updateable(Resource):
62
68
 
63
69
  @classmethod
64
70
  def _update(
65
- cls: Type[R_co], id: str, *, session: Session = global_session, **data
71
+ cls: Type[R_co],
72
+ id: str,
73
+ *,
74
+ session: Session = global_session,
75
+ **data: Any,
66
76
  ) -> R_co:
67
77
  resp = session.patch(f'/{cls._resource}/{id}', data)
68
78
  return cls(**resp)
69
79
 
70
80
 
71
81
  class Deactivable(Resource):
72
- deactivated_at: Optional[dt.datetime]
82
+ deactivated_at: Optional[dt.datetime] = None
73
83
 
74
84
  @classmethod
75
85
  def deactivate(
76
- cls: Type[R_co], id: str, *, session: Session = global_session, **data
86
+ cls: Type[R_co],
87
+ id: str,
88
+ *,
89
+ session: Session = global_session,
90
+ **data: Any,
77
91
  ) -> R_co:
78
92
  resp = session.delete(f'/{cls._resource}/{id}', data)
79
93
  return cls(**resp)
@@ -116,7 +130,7 @@ class Uploadable(Resource):
116
130
  user_id: str,
117
131
  *,
118
132
  session: Session = global_session,
119
- **data,
133
+ **data: Any,
120
134
  ) -> R_co:
121
135
  encoded_file = base64.b64encode(file)
122
136
  resp = session.request(
@@ -138,10 +152,13 @@ class Queryable(Resource):
138
152
 
139
153
  @classmethod
140
154
  def one(
141
- cls: Type[Q_co], *, session: Session = global_session, **query_params
142
- ) -> Q_co:
143
- q = cls._query_params(limit=2, **query_params)
144
- resp = session.get(cls._resource, q.dict())
155
+ cls: Type[R_co],
156
+ *,
157
+ session: Session = global_session,
158
+ **query_params: Any,
159
+ ) -> R_co:
160
+ q = cast(Queryable, cls)._query_params(limit=2, **query_params)
161
+ resp = session.get(cls._resource, q.model_dump())
145
162
  items = resp['items']
146
163
  len_items = len(items)
147
164
  if not len_items:
@@ -152,10 +169,13 @@ class Queryable(Resource):
152
169
 
153
170
  @classmethod
154
171
  def first(
155
- cls: Type[Q_co], *, session: Session = global_session, **query_params
156
- ) -> Optional[Q_co]:
157
- q = cls._query_params(limit=1, **query_params)
158
- resp = session.get(cls._resource, q.dict())
172
+ cls: Type[R_co],
173
+ *,
174
+ session: Session = global_session,
175
+ **query_params: Any,
176
+ ) -> Optional[R_co]:
177
+ q = cast(Queryable, cls)._query_params(limit=1, **query_params)
178
+ resp = session.get(cls._resource, q.model_dump())
159
179
  try:
160
180
  item = resp['items'][0]
161
181
  except IndexError:
@@ -166,19 +186,25 @@ class Queryable(Resource):
166
186
 
167
187
  @classmethod
168
188
  def count(
169
- cls: Type[Q_co], *, session: Session = global_session, **query_params
189
+ cls: Type[R_co],
190
+ *,
191
+ session: Session = global_session,
192
+ **query_params: Any,
170
193
  ) -> int:
171
- q = cls._query_params(count=True, **query_params)
172
- resp = session.get(cls._resource, q.dict())
194
+ q = cast(Queryable, cls)._query_params(count=True, **query_params)
195
+ resp = session.get(cls._resource, q.model_dump())
173
196
  return resp['count']
174
197
 
175
198
  @classmethod
176
199
  def all(
177
- cls: Type[Q_co], *, session: Session = global_session, **query_params
178
- ) -> Generator[Q_co, None, None]:
200
+ cls: Type[R_co],
201
+ *,
202
+ session: Session = global_session,
203
+ **query_params: Any,
204
+ ) -> Generator[R_co, None, None]:
179
205
  session = session or global_session
180
- q = cls._query_params(**query_params)
181
- next_page_uri = f'{cls._resource}?{urlencode(q.dict())}'
206
+ q = cast(Queryable, cls)._query_params(**query_params)
207
+ next_page_uri = f'{cls._resource}?{urlencode(q.model_dump())}'
182
208
  while next_page_uri:
183
209
  page = session.get(next_page_uri)
184
210
  yield from (cls(**item) for item in page['items'])
@@ -15,7 +15,7 @@ class CardActivation(Creatable):
15
15
  created_at: dt.datetime
16
16
  user_id: str
17
17
  ip_address: str
18
- card_uri: Optional[str]
18
+ card_uri: Optional[str] = None
19
19
  success: bool
20
20
 
21
21
  @classmethod
@@ -42,7 +42,7 @@ class CardActivation(Creatable):
42
42
  exp_year=exp_year,
43
43
  cvv2=cvv2,
44
44
  )
45
- return cls._create(session=session, **req.dict())
45
+ return cls._create(session=session, **req.model_dump())
46
46
 
47
47
  @property
48
48
  def card(self) -> Optional[Card]:
@@ -1,4 +1,4 @@
1
- from typing import ClassVar, List, Optional, cast
1
+ from typing import ClassVar, Optional, cast
2
2
 
3
3
  from cuenca_validations.types import (
4
4
  CardErrorType,
@@ -19,19 +19,19 @@ class CardTransaction(Transaction):
19
19
 
20
20
  type: CardTransactionType
21
21
  network: CardNetwork
22
- related_card_transaction_uris: List[str]
22
+ related_card_transaction_uris: list[str]
23
23
  card_uri: str
24
24
  card_last4: str
25
25
  card_type: CardType
26
26
  metadata: dict
27
- error_type: Optional[CardErrorType]
27
+ error_type: Optional[CardErrorType] = None
28
28
 
29
29
  @property # type: ignore
30
- def related_card_transactions(self) -> Optional[List['CardTransaction']]:
30
+ def related_card_transactions(self) -> Optional[list['CardTransaction']]:
31
31
  if not self.related_card_transaction_uris:
32
32
  return []
33
33
  return cast(
34
- List['CardTransaction'],
34
+ list['CardTransaction'],
35
35
  retrieve_uris(self.related_card_transaction_uris),
36
36
  )
37
37
 
@@ -18,11 +18,11 @@ class CardValidation(Creatable):
18
18
  user_id: str
19
19
  card_status: CardStatus
20
20
  card_type: CardType
21
- is_valid_cvv: Optional[bool]
22
- is_valid_cvv2: Optional[bool]
23
- is_valid_icvv: Optional[bool]
24
- is_valid_pin_block: Optional[bool]
25
- is_valid_exp_date: Optional[bool]
21
+ is_valid_cvv: Optional[bool] = None
22
+ is_valid_cvv2: Optional[bool] = None
23
+ is_valid_icvv: Optional[bool] = None
24
+ is_valid_pin_block: Optional[bool] = None
25
+ is_valid_exp_date: Optional[bool] = None
26
26
  is_pin_attempts_exceeded: bool
27
27
  is_expired: bool
28
28
  platform_id: Optional[str] = None
@@ -51,9 +51,7 @@ class CardValidation(Creatable):
51
51
  pin_block=pin_block,
52
52
  pin_attempts_exceeded=pin_attempts_exceeded,
53
53
  )
54
- return cast(
55
- 'CardValidation', cls._create(session=session, **req.dict())
56
- )
54
+ return cls._create(session=session, **req.model_dump())
57
55
 
58
56
  @property
59
57
  def card(self) -> Card:
cuenca/resources/cards.py CHANGED
@@ -21,12 +21,12 @@ class Card(Retrievable, Queryable, Creatable, Updateable):
21
21
  _resource: ClassVar = 'cards'
22
22
  _query_params: ClassVar = CardQuery
23
23
 
24
- user_id: Optional[str]
24
+ user_id: Optional[str] = None
25
25
  number: str
26
26
  exp_month: int
27
27
  exp_year: int
28
28
  cvv2: str
29
- pin: Optional[str]
29
+ pin: Optional[str] = None
30
30
  type: CardType
31
31
  status: CardStatus
32
32
  issuer: CardIssuer
@@ -81,7 +81,7 @@ class Card(Retrievable, Queryable, Creatable, Updateable):
81
81
  card_holder_user_id=card_holder_user_id,
82
82
  is_dynamic_cvv=is_dynamic_cvv,
83
83
  )
84
- return cls._create(session=session, **req.dict())
84
+ return cls._create(session=session, **req.model_dump())
85
85
 
86
86
  @classmethod
87
87
  def update(
@@ -106,7 +106,7 @@ class Card(Retrievable, Queryable, Creatable, Updateable):
106
106
  req = CardUpdateRequest(
107
107
  status=status, pin_block=pin_block, is_dynamic_cvv=is_dynamic_cvv
108
108
  )
109
- return cls._update(card_id, session=session, **req.dict())
109
+ return cls._update(card_id, session=session, **req.model_dump())
110
110
 
111
111
  @classmethod
112
112
  def deactivate(
@@ -7,7 +7,8 @@ from cuenca_validations.types import (
7
7
  Gender,
8
8
  State,
9
9
  )
10
- from cuenca_validations.types.identities import CurpField
10
+ from cuenca_validations.types.identities import Curp
11
+ from pydantic import ConfigDict, Field
11
12
 
12
13
  from ..http import Session, session as global_session
13
14
  from .base import Creatable, Retrievable
@@ -17,44 +18,42 @@ class CurpValidation(Creatable, Retrievable):
17
18
  _resource: ClassVar = 'curp_validations'
18
19
 
19
20
  created_at: dt.datetime
20
- names: Optional[str] = None
21
- first_surname: Optional[str] = None
22
- second_surname: Optional[str] = None
23
- date_of_birth: Optional[dt.date] = None
24
- country_of_birth: Optional[Country] = None
25
- state_of_birth: Optional[State] = None
26
- gender: Optional[Gender] = None
27
- nationality: Optional[Country] = None
28
- manual_curp: Optional[CurpField] = None
29
- calculated_curp: CurpField
30
- validated_curp: Optional[CurpField] = None
31
- renapo_curp_match: bool
32
- renapo_full_match: bool
33
-
34
- class Config:
35
- fields = {
36
- 'names': {'description': 'Official name from Renapo'},
37
- 'first_surname': {'description': 'Official surname from Renapo'},
38
- 'second_surname': {'description': 'Official surname from Renapo'},
39
- 'country_of_birth': {'description': 'In format ISO 3166 Alpha-2'},
40
- 'state_of_birth': {'description': 'In format ISO 3166 Alpha-2'},
41
- 'nationality': {'description': 'In format ISO 3166 Alpha-2'},
42
- 'manual_curp': {'description': 'curp provided in request'},
43
- 'calculated_curp': {
44
- 'description': 'Calculated CURP based on request data'
45
- },
46
- 'validated_curp': {
47
- 'description': 'CURP validated in Renapo, null if not exists'
48
- },
49
- 'renapo_curp_match': {
50
- 'description': 'True if CURP exists and is valid'
51
- },
52
- 'renapo_full_match': {
53
- 'description': 'True if all fields provided match the response'
54
- ' from RENAPO. Accents in names are ignored'
55
- },
56
- }
57
- schema_extra = {
21
+ names: Optional[str] = Field(None, description='Official name from Renapo')
22
+ first_surname: Optional[str] = Field(
23
+ None, description='Official surname from Renapo'
24
+ )
25
+ second_surname: Optional[str] = Field(
26
+ None, description='Official surname from Renapo'
27
+ )
28
+ date_of_birth: Optional[dt.date] = Field(
29
+ None, description='In format ISO 3166 Alpha-2'
30
+ )
31
+ country_of_birth: Optional[Country] = Field(
32
+ None, description='In format ISO 3166 Alpha-2'
33
+ )
34
+ state_of_birth: Optional[State] = Field(None, description='State of birth')
35
+ gender: Optional[Gender] = Field(None, description='Gender')
36
+ nationality: Optional[Country] = Field(
37
+ None, description='In format ISO 3166 Alpha-2'
38
+ )
39
+ manual_curp: Optional[Curp] = Field(
40
+ None, description='curp provided in request'
41
+ )
42
+ calculated_curp: Curp = Field(
43
+ description='Calculated CURP based on request data'
44
+ )
45
+ validated_curp: Optional[Curp] = Field(
46
+ None, description='CURP validated in Renapo, null if not exists'
47
+ )
48
+ renapo_curp_match: bool = Field(
49
+ description='True if CURP exists and is valid'
50
+ )
51
+ renapo_full_match: bool = Field(
52
+ description='True if all fields provided match the response from '
53
+ 'RENAPO. Accents in names are ignored',
54
+ )
55
+ model_config = ConfigDict(
56
+ json_schema_extra={
58
57
  'example': {
59
58
  'id': 'CVNEUInh69SuKXXmK95sROwQ',
60
59
  'created_at': '2019-08-24T14:15:22Z',
@@ -72,7 +71,8 @@ class CurpValidation(Creatable, Retrievable):
72
71
  'renapo_curp_match': True,
73
72
  'renapo_full_match': True,
74
73
  }
75
- }
74
+ },
75
+ )
76
76
 
77
77
  @classmethod
78
78
  def create(
@@ -84,7 +84,7 @@ class CurpValidation(Creatable, Retrievable):
84
84
  state_of_birth: Optional[State] = None,
85
85
  gender: Optional[Gender] = None,
86
86
  second_surname: Optional[str] = None,
87
- manual_curp: Optional[CurpField] = None,
87
+ manual_curp: Optional[Curp] = None,
88
88
  *,
89
89
  session: Session = global_session,
90
90
  ) -> 'CurpValidation':
@@ -98,4 +98,4 @@ class CurpValidation(Creatable, Retrievable):
98
98
  gender=gender,
99
99
  manual_curp=manual_curp,
100
100
  )
101
- return cls._create(session=session, **req.dict())
101
+ return cls._create(session=session, **req.model_dump())
@@ -13,7 +13,7 @@ class Deposit(Transaction):
13
13
 
14
14
  network: DepositNetwork
15
15
  source_uri: str
16
- tracking_key: Optional[str] # clave rastreo if network is SPEI
16
+ tracking_key: Optional[str] = None # clave rastreo if network is SPEI
17
17
 
18
18
  @property # type: ignore
19
19
  def source(self) -> Account:
@@ -1,11 +1,11 @@
1
- from typing import ClassVar, List, Optional
1
+ from typing import ClassVar, Optional
2
2
 
3
3
  from cuenca_validations.types.enums import WebhookEvent
4
4
  from cuenca_validations.types.requests import (
5
5
  EndpointRequest,
6
6
  EndpointUpdateRequest,
7
7
  )
8
- from pydantic import HttpUrl
8
+ from pydantic import ConfigDict, Field, HttpUrl
9
9
 
10
10
  from ..http import Session, session as global_session
11
11
  from .base import Creatable, Deactivable, Queryable, Retrievable, Updateable
@@ -14,28 +14,21 @@ from .base import Creatable, Deactivable, Queryable, Retrievable, Updateable
14
14
  class Endpoint(Creatable, Deactivable, Retrievable, Queryable, Updateable):
15
15
  _resource: ClassVar = 'endpoints'
16
16
 
17
- url: HttpUrl
18
- secret: str
19
- is_enable: bool
20
- events: List[WebhookEvent]
21
-
22
- class Config:
23
- fields = {
24
- 'url': {'description': 'HTTPS url to send webhooks'},
25
- 'secret': {
26
- 'description': 'token to verify the webhook is sent by Cuenca '
27
- 'using HMAC algorithm'
28
- },
29
- 'is_enable': {
30
- 'description': 'Allows user to turn-off the endpoint '
31
- 'without the need of deleting it'
32
- },
33
- 'events': {
34
- 'description': 'list of enabled events. If None, '
35
- 'all events will be enabled for this Endpoint'
36
- },
37
- }
38
- schema_extra = {
17
+ url: HttpUrl = Field(description='HTTPS url to send webhooks')
18
+ secret: str = Field(
19
+ description='token to verify the webhook is sent by Cuenca '
20
+ 'using HMAC algorithm',
21
+ )
22
+ is_enable: bool = Field(
23
+ description='Allows user to turn-off the endpoint without the '
24
+ 'need of deleting it',
25
+ )
26
+ events: list[WebhookEvent] = Field(
27
+ description='list of enabled events. If None, all events will '
28
+ 'be enabled for this Endpoint',
29
+ )
30
+ model_config = ConfigDict(
31
+ json_schema_extra={
39
32
  'example': {
40
33
  '_id': 'ENxxne2Z5VSTKZm_w8Hzffcw',
41
34
  'platform_id': 'PTZoPrrPT6Ts-9myamq5h1bA',
@@ -52,13 +45,14 @@ class Endpoint(Creatable, Deactivable, Retrievable, Queryable, Updateable):
52
45
  ],
53
46
  'is_enable': True,
54
47
  }
55
- }
48
+ },
49
+ )
56
50
 
57
51
  @classmethod
58
52
  def create(
59
53
  cls,
60
54
  url: HttpUrl,
61
- events: Optional[List[WebhookEvent]] = None,
55
+ events: Optional[list[WebhookEvent]] = None,
62
56
  *,
63
57
  session: Session = global_session,
64
58
  ) -> 'Endpoint':
@@ -72,14 +66,14 @@ class Endpoint(Creatable, Deactivable, Retrievable, Queryable, Updateable):
72
66
  :return: New active endpoint
73
67
  """
74
68
  req = EndpointRequest(url=url, events=events)
75
- return cls._create(session=session, **req.dict())
69
+ return cls._create(session=session, **req.model_dump())
76
70
 
77
71
  @classmethod
78
72
  def update(
79
73
  cls,
80
74
  endpoint_id: str,
81
75
  url: Optional[HttpUrl] = None,
82
- events: Optional[List[WebhookEvent]] = None,
76
+ events: Optional[list[WebhookEvent]] = None,
83
77
  is_enable: Optional[bool] = None,
84
78
  *,
85
79
  session: Session = global_session,
@@ -89,6 +83,7 @@ class Endpoint(Creatable, Deactivable, Retrievable, Queryable, Updateable):
89
83
  like url and is_active.
90
84
  :param endpoint_id: existing endpoint_id
91
85
  :param url
86
+ :param events: Optional list of enabled events to update
92
87
  :param is_enable
93
88
  :param session
94
89
  :return: Updated endpoint object
@@ -96,4 +91,4 @@ class Endpoint(Creatable, Deactivable, Retrievable, Queryable, Updateable):
96
91
  req = EndpointUpdateRequest(
97
92
  url=url, is_enable=is_enable, events=events
98
93
  )
99
- return cls._update(endpoint_id, session=session, **req.dict())
94
+ return cls._update(endpoint_id, session=session, **req.model_dump())
@@ -1,6 +1,10 @@
1
- from typing import ClassVar, Dict, List
1
+ from typing import ClassVar
2
2
 
3
- from cuenca_validations.types import BatchFileMetadata, FileBatchUploadRequest
3
+ from cuenca_validations.types import (
4
+ BatchFileMetadata,
5
+ FileBatchUploadRequest,
6
+ FileRequest,
7
+ )
4
8
 
5
9
  from ..http import Session, session as global_session
6
10
  from .base import Creatable, Queryable
@@ -9,17 +13,20 @@ from .base import Creatable, Queryable
9
13
  class FileBatch(Creatable, Queryable):
10
14
  _resource: ClassVar = 'file_batches'
11
15
 
12
- received_files: List[BatchFileMetadata]
13
- uploaded_files: List[BatchFileMetadata]
16
+ received_files: list[BatchFileMetadata]
17
+ uploaded_files: list[BatchFileMetadata]
14
18
  user_id: str
15
19
 
16
20
  @classmethod
17
21
  def create(
18
22
  cls,
19
- files: List[Dict],
23
+ files: list[dict],
20
24
  user_id: str,
21
25
  *,
22
26
  session: Session = global_session,
23
27
  ) -> 'FileBatch':
24
- req = FileBatchUploadRequest(files=files, user_id=user_id)
25
- return cls._create(session=session, **req.dict())
28
+ req = FileBatchUploadRequest(
29
+ files=[FileRequest(**f) for f in files],
30
+ user_id=user_id,
31
+ )
32
+ return cls._create(session=session, **req.model_dump())