cuenca 2.0.1__py3-none-any.whl → 2.0.2.dev1__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.
cuenca/__init__.py CHANGED
@@ -42,6 +42,7 @@ __all__ = [
42
42
  'WhatsappTransfer',
43
43
  'configure',
44
44
  'get_balance',
45
+ 'JwtToken',
45
46
  ]
46
47
 
47
48
  from . import http
@@ -65,6 +66,7 @@ from .resources import (
65
66
  FileBatch,
66
67
  Identity,
67
68
  IdentityEvent,
69
+ JwtToken,
68
70
  KYCValidation,
69
71
  KYCVerification,
70
72
  LimitedWallet,
@@ -38,6 +38,7 @@ __all__ = [
38
38
  'WalletTransaction',
39
39
  'Webhook',
40
40
  'WhatsappTransfer',
41
+ 'JwtToken',
41
42
  ]
42
43
 
43
44
  from .accounts import Account
@@ -59,6 +60,7 @@ from .file_batches import FileBatch
59
60
  from .files import File
60
61
  from .identities import Identity
61
62
  from .identity_events import IdentityEvent
63
+ from .jwt_tokens import JwtToken
62
64
  from .kyc_validations import KYCValidation
63
65
  from .kyc_verifications import KYCVerification
64
66
  from .limited_wallets import LimitedWallet
@@ -123,6 +125,7 @@ resource_classes = [
123
125
  WhatsappTransfer,
124
126
  Webhook,
125
127
  Platform,
128
+ JwtToken,
126
129
  ]
127
130
  for resource_cls in resource_classes:
128
131
  RESOURCES[resource_cls._resource] = resource_cls # type: ignore
@@ -1,7 +1,7 @@
1
1
  import datetime as dt
2
- from typing import ClassVar, Optional
2
+ from typing import Annotated, ClassVar, Optional
3
3
 
4
- from cuenca_validations.types import ApiKeyQuery, ApiKeyUpdateRequest
4
+ from cuenca_validations.types import ApiKeyQuery, ApiKeyUpdateRequest, Metadata
5
5
  from pydantic import ConfigDict
6
6
 
7
7
  from ..http import Session, session as global_session
@@ -12,7 +12,7 @@ class ApiKey(Creatable, Queryable, Retrievable, Updateable):
12
12
  _resource: ClassVar = 'api_keys'
13
13
  _query_params: ClassVar = ApiKeyQuery
14
14
 
15
- secret: str
15
+ secret: Annotated[str, Metadata(sensitive=True, log_chars=4)]
16
16
  deactivated_at: Optional[dt.datetime] = None
17
17
  user_id: Optional[str] = None
18
18
  model_config = ConfigDict(
@@ -0,0 +1,44 @@
1
+ import datetime as dt
2
+ from typing import Annotated, ClassVar
3
+
4
+ from cuenca_validations.types import Metadata
5
+ from pydantic import ConfigDict
6
+
7
+ from ..http import Session, session as global_session
8
+ from .base import Creatable
9
+
10
+
11
+ class JwtToken(Creatable):
12
+ _resource: ClassVar = 'token'
13
+
14
+ id: Annotated[str, Metadata(sensitive=True, log_chars=4)]
15
+ token: Annotated[str, Metadata(sensitive=True, log_chars=4)]
16
+ created_at: dt.datetime
17
+ api_key_uri: str
18
+
19
+ model_config = ConfigDict(
20
+ json_schema_extra={
21
+ 'example': {
22
+ 'id': (
23
+ 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3MzgzNjI'
24
+ '4NzcsImlhdCI6MTczNzc1ODA3Nywic3ViIjoiQUtzY3p5N3RzaVJkMkl'
25
+ 'iakxfbllGb2xRIiwidWlkIjoiNjRiZmQ0OTItZGFhMy0xMWVmLWEyMWU'
26
+ 'tMGE1OGE5ZmVhYzAyIn0.Er8kDsw4rtGkwAXpEgUhwyXFiBjYlwDVTGF'
27
+ 'tYW7o0go'
28
+ ),
29
+ 'token': (
30
+ 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3MzgzNjI'
31
+ '4NzcsImlhdCI6MTczNzc1ODA3Nywic3ViIjoiQUtzY3p5N3RzaVJkMkl'
32
+ 'iakxfbllGb2xRIiwidWlkIjoiNjRiZmQ0OTItZGFhMy0xMWVmLWEyMWU'
33
+ 'tMGE1OGE5ZmVhYzAyIn0.Er8kDsw4rtGkwAXpEgUhwyXFiBjYlwDVTGF'
34
+ 'tYW7o0go'
35
+ ),
36
+ 'created_at': '2025-01-24T22:34:37.659667',
37
+ 'api_key_uri': '/api_key/AKsczy7tsiRd2IbjL_nYFolQ',
38
+ }
39
+ }
40
+ )
41
+
42
+ @classmethod
43
+ def create(cls, session: Session = global_session) -> 'JwtToken':
44
+ return cls._create(session=session)
@@ -1,5 +1,6 @@
1
- from typing import ClassVar
1
+ from typing import Annotated, ClassVar
2
2
 
3
+ from cuenca_validations.types import Metadata
3
4
  from pydantic import ConfigDict
4
5
 
5
6
  from ..http import Session, session as global_session
@@ -9,6 +10,8 @@ from .base import Creatable
9
10
  class LoginToken(Creatable):
10
11
  _resource: ClassVar = 'login_tokens'
11
12
 
13
+ id: Annotated[str, Metadata(sensitive=True, log_chars=4)]
14
+
12
15
  model_config = ConfigDict(
13
16
  json_schema_extra={'example': {'id': 'LTNEUInh69SuKXXmK95sROwQ'}}
14
17
  )
cuenca/resources/otps.py CHANGED
@@ -1,5 +1,6 @@
1
- from typing import ClassVar
1
+ from typing import Annotated, ClassVar
2
2
 
3
+ from cuenca_validations.types import Metadata
3
4
  from pydantic import ConfigDict
4
5
 
5
6
  from ..http import Session, session as global_session
@@ -8,7 +9,7 @@ from .base import Creatable
8
9
 
9
10
  class Otp(Creatable):
10
11
  _resource: ClassVar = 'otps'
11
- secret: str
12
+ secret: Annotated[str, Metadata(sensitive=True, log_chars=4)]
12
13
 
13
14
  model_config = ConfigDict(
14
15
  json_schema_extra={
@@ -1,7 +1,7 @@
1
1
  import datetime as dt
2
- from typing import ClassVar, Optional
2
+ from typing import Annotated, ClassVar, Optional
3
3
 
4
- from cuenca_validations.types import SessionRequest, SessionType
4
+ from cuenca_validations.types import Metadata, SessionRequest, SessionType
5
5
  from cuenca_validations.types.general import SerializableAnyUrl
6
6
  from pydantic import ConfigDict
7
7
 
@@ -12,7 +12,7 @@ from .base import Creatable, Queryable, Retrievable
12
12
  class Session(Creatable, Retrievable, Queryable):
13
13
  _resource: ClassVar = 'sessions'
14
14
 
15
- id: str
15
+ id: Annotated[str, Metadata(sensitive=True, log_chars=4)]
16
16
  created_at: dt.datetime
17
17
  user_id: str
18
18
  platform_id: str
cuenca/version.py CHANGED
@@ -1,3 +1,3 @@
1
- __version__ = '2.0.1'
1
+ __version__ = '2.0.2.dev1'
2
2
  CLIENT_VERSION = __version__
3
3
  API_VERSION = '2020-03-19'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: cuenca
3
- Version: 2.0.1
3
+ Version: 2.0.2.dev1
4
4
  Summary: Cuenca API Client
5
5
  Home-page: https://github.com/cuenca-mx/cuenca-python
6
6
  Author: Cuenca
@@ -1,13 +1,13 @@
1
- cuenca/__init__.py,sha256=Lqmi5MUI4WQ1HWGTQOlpfh0Y3ujvJJ3vsvhBR2CPTno,1760
1
+ cuenca/__init__.py,sha256=KQOScdvJ-rAsCugliTHsrxnV2A2hCLVpKnwaJpv3qO0,1790
2
2
  cuenca/exc.py,sha256=r_lL03-JS0AsXw71wuNbiwNYLHNDagM56tRxpYyK6Lw,601
3
3
  cuenca/jwt.py,sha256=plB2ttHPZnL0xq3gqubw_Jjtj1QYG2E5bk99N3cn5zg,1502
4
4
  cuenca/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- cuenca/version.py,sha256=LjAvLwkqP0l1E6xo-ybP-kwTeliGgEy8G_pZixj2NPI,78
5
+ cuenca/version.py,sha256=ho04klpNnEYHZp1fQzYXlXcEokatCzKGoDFl26-l2V4,83
6
6
  cuenca/http/__init__.py,sha256=V5TG6Ro9d3VY7umzcbtanmvHlGkv-k71H0tqrdMyH-s,49
7
7
  cuenca/http/client.py,sha256=psXJiSgd3SUSJ5jwvhdBWsVMNadenG353BNVXdh7HMY,4168
8
- cuenca/resources/__init__.py,sha256=pySyBur3jnWA5yfHFuVZfdnk6nROj3BsLRy7vVWXFoc,3019
8
+ cuenca/resources/__init__.py,sha256=hD0V8_D3DV4aRZSR7hYrrQ-qRXvlVBxilnIEPa4H9nw,3082
9
9
  cuenca/resources/accounts.py,sha256=5yfNxAHpxWFosoR4WrPrDGpBCRkaQk98V-w0wCPPXqU,345
10
- cuenca/resources/api_keys.py,sha256=7pARbgLtaOR_ZmUsToBok5c2QXyY05ysiU0SBN0eJok,2544
10
+ cuenca/resources/api_keys.py,sha256=Sy9QZpcFDNqZrZnAEzG63pKt2igE9CgyxyOrCvjUhEs,2615
11
11
  cuenca/resources/arpc.py,sha256=a9gGIgpBV8RK2ePSPBxI5c4ET4MtKH6Po_HRiv73B5k,1689
12
12
  cuenca/resources/balance_entries.py,sha256=c2p9nXrKpMJ2xlQkTLP_ttycb1RitA979mP46mbZnEc,1073
13
13
  cuenca/resources/base.py,sha256=_DFyX6OOjhm2UO5KSCsupBJYHQYDNzhaZudvy1U8VS8,5742
@@ -26,17 +26,18 @@ cuenca/resources/file_batches.py,sha256=2Fsmz8ryOjvLn3dpsyR0G2iS0zNVR4ajovNkaMZa
26
26
  cuenca/resources/files.py,sha256=WZYRo76fIGXNXk2HzA252dSdIdA4bl3EjB6q0bb6BFg,1837
27
27
  cuenca/resources/identities.py,sha256=IdL495eTjx_2gDRxM9oG_QmDNOwaY7Nv9gzqeZu_Wdk,1092
28
28
  cuenca/resources/identity_events.py,sha256=K1G6IEGlw6n482nZhBo_CJNBdpKFCO6duMQr5y9k4x8,374
29
+ cuenca/resources/jwt_tokens.py,sha256=xxZBBNNj9HylTAAT8NVbx2xExq_JLoF98cIUuUOw3U8,1621
29
30
  cuenca/resources/kyc_validations.py,sha256=1G_dr6e1mpLUlqT9RmBgiC06eh0vQjMzosM5w3ZCQoE,1322
30
31
  cuenca/resources/kyc_verifications.py,sha256=ysvVS9zdvFZ1Wyh2G_cr_IMwYeLW5BRLVyAt46hTk4g,1563
31
32
  cuenca/resources/limited_wallets.py,sha256=Z3pKMRmMFTAaCw-KdzGSWfYFHCpy-ZrBwOmalVfSdRU,1049
32
- cuenca/resources/login_tokens.py,sha256=WgNynC03TYwih37j26TO8nZI3fAAQ6IC-RJEn_CXEtU,668
33
- cuenca/resources/otps.py,sha256=0LXYSNwI16Xsi8N7rmO8NHggSou8F2IWPQR5h2fAzf8,618
33
+ cuenca/resources/login_tokens.py,sha256=52AOEUngx5uNjUWXNp0icSFGIqu0e2ZulK5JkK7RV0o,788
34
+ cuenca/resources/otps.py,sha256=uYPJkBxFSMflAAfQo6GccR1CGSqu93n-OGTlPQmYsJg,725
34
35
  cuenca/resources/platforms.py,sha256=ztGcI-cNnushMRqKqjPaZg_ioS1bpR4vR88osHAyYXw,2560
35
36
  cuenca/resources/questionnaires.py,sha256=TKICPHghEhER83byMhe75Wb798K5veqv47RafYA5VOM,1043
36
37
  cuenca/resources/resources.py,sha256=sDkVwN-RguyoQXJhSYCa95Cem1AUmcgMJeFJveVf6Q0,912
37
38
  cuenca/resources/savings.py,sha256=3DBP1ygxhcScDpLvAQS_fF5chljyDTz4xwnltI0LCAg,1433
38
39
  cuenca/resources/service_providers.py,sha256=x-FNcyiUkdUsNCGudyLGYDbRkD2jPj8-T8U3IumxTVQ,310
39
- cuenca/resources/sessions.py,sha256=Enc8VVIjl9-2CHNxPac_QAc_TfE5x6oFFIEtLzoXPcU,1682
40
+ cuenca/resources/sessions.py,sha256=I7bpCcglL9BhV6mG2DkJp-fLGnnCyXO2rzZhMf_UsEE,1753
40
41
  cuenca/resources/statements.py,sha256=PqMvhoE9cvBneXjaS7w4JnTzYdDakkCkbdNYrd7b8LI,282
41
42
  cuenca/resources/transfers.py,sha256=v742SAGUIZfvYHfCNtk0hSm2uyhMGh00RbHIIJiqLzQ,3201
42
43
  cuenca/resources/user_credentials.py,sha256=glpxUa5-aYhgJ1ZG1g_c1PAWaQ9eEWP01lauBaccSQQ,1356
@@ -75,6 +76,7 @@ tests/resources/test_file_batches.py,sha256=xcVeWZns4j3_RPZEv8W1Ws4-bcaxOXTQzFyU
75
76
  tests/resources/test_files.py,sha256=2VSlvYnGHrw--mYNvA6hlpEw-olbW_Hlq2d4vdn8v7M,961
76
77
  tests/resources/test_identities.py,sha256=0osumiLrzKkGG4XLlL4nIdSp_nGutHaPf55w_IVREps,454
77
78
  tests/resources/test_identity_events.py,sha256=BZlM2RXKtCORdTDQCemY3NAR3KWb3mPNql4sd6oU4-U,344
79
+ tests/resources/test_jwt_tokens.py,sha256=XBvtz2C2HbUXXyoxP2iq27nOkLgkUgGI7GSECJzVGRE,664
78
80
  tests/resources/test_kyc_validations.py,sha256=TEyS6encW-InRpcAR4nDCfmkqqnn8yMC9AaS3iWm8Xw,420
79
81
  tests/resources/test_kyc_verifications.py,sha256=Y-ZU61o18I_3NFqMN2w4WGZTzwsIhULAtESqIXiizUY,634
80
82
  tests/resources/test_limited_wallets.py,sha256=c0zDDOip3lJk8chbcGr_nWCdkO9yuL_HbD1IikR5jH4,527
@@ -97,8 +99,8 @@ tests/resources/test_verifications.py,sha256=yyL-bdryQU3MvqnmAgnnzGG9t7UTxWwPiVu
97
99
  tests/resources/test_wallet_transactions.py,sha256=_L2hjPHT4FwwhxksUoaoVHwFFYOGWfF4ScCbk0kb7Hw,3945
98
100
  tests/resources/test_webhooks.py,sha256=nYCqAnlNJcMJKRHhgoHOWTQnFLWQHHvFyY8GVCxGTD8,328
99
101
  tests/resources/test_whatsapp_transfers.py,sha256=4Dmrsbytx7LRrLQo9M8TAL7cGKJufPStkp51UdRCnYU,1030
100
- cuenca-2.0.1.dist-info/LICENSE,sha256=aWv5PmUiAcNENEAdghcVQSeU56pXJHWexJYgklK9XLg,1063
101
- cuenca-2.0.1.dist-info/METADATA,sha256=rzBCl4HwBPVT7nMPJEUj62XJIEF4P6AhdzUFjB8AbZU,4961
102
- cuenca-2.0.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
103
- cuenca-2.0.1.dist-info/top_level.txt,sha256=5h3K7XJTmJniDloPq4sIJHni_xLw-Uoc6ZJ5mcw_lZY,13
104
- cuenca-2.0.1.dist-info/RECORD,,
102
+ cuenca-2.0.2.dev1.dist-info/LICENSE,sha256=aWv5PmUiAcNENEAdghcVQSeU56pXJHWexJYgklK9XLg,1063
103
+ cuenca-2.0.2.dev1.dist-info/METADATA,sha256=oAKuPMl4wGpL6NOcnb99rAyVCeqJmfBYuXYXACz10m0,4966
104
+ cuenca-2.0.2.dev1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
105
+ cuenca-2.0.2.dev1.dist-info/top_level.txt,sha256=5h3K7XJTmJniDloPq4sIJHni_xLw-Uoc6ZJ5mcw_lZY,13
106
+ cuenca-2.0.2.dev1.dist-info/RECORD,,
@@ -0,0 +1,28 @@
1
+ import pytest
2
+
3
+ from cuenca import JwtToken, LoginToken, UserLogin
4
+ from cuenca.http.client import Session
5
+
6
+
7
+ @pytest.fixture(scope='function')
8
+ def session():
9
+ session = Session()
10
+ session.configure(
11
+ 'api_key',
12
+ 'api_secret',
13
+ sandbox=True,
14
+ )
15
+ return session
16
+
17
+
18
+ @pytest.mark.vcr
19
+ def test_jwt_tokens(session):
20
+ UserLogin.create('111111', session=session)
21
+ login_token = LoginToken.create(session=session)
22
+ session.headers.pop(
23
+ 'X-Cuenca-LoginId',
24
+ )
25
+ session.configure(login_token=login_token.id)
26
+ jwt_token = JwtToken.create(session=session)
27
+ assert jwt_token
28
+ assert isinstance(jwt_token.token, str)