cuenca 2.0.0.dev5__py3-none-any.whl → 2.0.0.dev7__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 +1 -3
- cuenca/resources/__init__.py +0 -2
- cuenca/resources/api_keys.py +6 -7
- cuenca/resources/arpc.py +3 -4
- cuenca/resources/base.py +67 -51
- cuenca/resources/card_activations.py +2 -5
- cuenca/resources/card_transactions.py +0 -1
- cuenca/resources/card_validations.py +2 -4
- cuenca/resources/cards.py +4 -5
- cuenca/resources/clabes.py +2 -2
- cuenca/resources/curp_validations.py +10 -14
- cuenca/resources/endpoints.py +5 -11
- cuenca/resources/file_batches.py +4 -5
- cuenca/resources/files.py +4 -15
- cuenca/resources/identities.py +2 -2
- cuenca/resources/kyc_validations.py +3 -4
- cuenca/resources/kyc_verifications.py +7 -8
- cuenca/resources/limited_wallets.py +5 -5
- cuenca/resources/login_tokens.py +3 -8
- cuenca/resources/otps.py +5 -4
- cuenca/resources/platforms.py +5 -7
- cuenca/resources/questionnaires.py +3 -4
- cuenca/resources/resources.py +1 -2
- cuenca/resources/savings.py +4 -6
- cuenca/resources/sessions.py +10 -14
- cuenca/resources/transfers.py +4 -5
- cuenca/resources/user_credentials.py +3 -8
- cuenca/resources/user_events.py +1 -0
- cuenca/resources/user_lists_validation.py +6 -10
- cuenca/resources/user_logins.py +3 -4
- cuenca/resources/users.py +11 -16
- cuenca/resources/verifications.py +5 -10
- cuenca/resources/wallet_transactions.py +2 -2
- cuenca/resources/webhooks.py +2 -6
- cuenca/version.py +1 -1
- {cuenca-2.0.0.dev5.dist-info → cuenca-2.0.0.dev7.dist-info}/METADATA +4 -4
- {cuenca-2.0.0.dev5.dist-info → cuenca-2.0.0.dev7.dist-info}/RECORD +46 -47
- tests/resources/test_api_keys.py +2 -2
- tests/resources/test_cards.py +0 -8
- tests/resources/test_endpoints.py +1 -1
- tests/resources/test_login_tokens.py +1 -1
- tests/resources/test_otps.py +1 -1
- tests/resources/test_sessions.py +1 -5
- cuenca/resources/jwt.py +0 -12
- {cuenca-2.0.0.dev5.dist-info → cuenca-2.0.0.dev7.dist-info}/LICENSE +0 -0
- {cuenca-2.0.0.dev5.dist-info → cuenca-2.0.0.dev7.dist-info}/WHEEL +0 -0
- {cuenca-2.0.0.dev5.dist-info → cuenca-2.0.0.dev7.dist-info}/top_level.txt +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
|
-
from typing import ClassVar, Optional
|
|
2
|
+
from typing import ClassVar, Optional
|
|
3
3
|
|
|
4
4
|
from cuenca_validations.types import (
|
|
5
5
|
Address,
|
|
6
|
-
|
|
6
|
+
Curp,
|
|
7
7
|
KYCVerificationUpdateRequest,
|
|
8
8
|
Rfc,
|
|
9
9
|
)
|
|
@@ -20,9 +20,10 @@ class KYCVerification(Creatable, Retrievable, Updateable):
|
|
|
20
20
|
created_at: dt.datetime
|
|
21
21
|
deactivated_at: Optional[dt.datetime] = None
|
|
22
22
|
verification_id: Optional[str] = None
|
|
23
|
-
curp: Optional[
|
|
23
|
+
curp: Optional[Curp] = None
|
|
24
24
|
rfc: Optional[Rfc] = None
|
|
25
25
|
address: Optional[Address] = None
|
|
26
|
+
|
|
26
27
|
model_config = ConfigDict(
|
|
27
28
|
json_schema_extra={
|
|
28
29
|
'example': {
|
|
@@ -40,15 +41,13 @@ class KYCVerification(Creatable, Retrievable, Updateable):
|
|
|
40
41
|
|
|
41
42
|
@classmethod
|
|
42
43
|
def create(cls, session: Session = global_session) -> 'KYCVerification':
|
|
43
|
-
return
|
|
44
|
+
return cls._create(session=session)
|
|
44
45
|
|
|
45
46
|
@classmethod
|
|
46
47
|
def update(
|
|
47
48
|
cls,
|
|
48
49
|
kyc_id: str,
|
|
49
|
-
curp:
|
|
50
|
+
curp: Optional[Curp] = None,
|
|
50
51
|
) -> 'KYCVerification':
|
|
51
52
|
req = KYCVerificationUpdateRequest(curp=curp)
|
|
52
|
-
return
|
|
53
|
-
'KYCVerification', cls._update(id=kyc_id, **req.model_dump())
|
|
54
|
-
)
|
|
53
|
+
return cls._update(id=kyc_id, **req.model_dump())
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
from typing import ClassVar, Optional
|
|
1
|
+
from typing import ClassVar, Optional
|
|
2
2
|
|
|
3
3
|
from clabe import Clabe
|
|
4
4
|
from cuenca_validations.types import (
|
|
5
5
|
AccountQuery,
|
|
6
|
-
|
|
6
|
+
Curp,
|
|
7
7
|
LimitedWalletRequest,
|
|
8
8
|
Rfc,
|
|
9
9
|
)
|
|
@@ -16,12 +16,12 @@ class LimitedWallet(Wallet):
|
|
|
16
16
|
_query_params: ClassVar = AccountQuery
|
|
17
17
|
account_number: Clabe
|
|
18
18
|
allowed_rfc: Optional[Rfc] = None
|
|
19
|
-
allowed_curp:
|
|
19
|
+
allowed_curp: Curp
|
|
20
20
|
|
|
21
21
|
@classmethod
|
|
22
22
|
def create(
|
|
23
23
|
cls,
|
|
24
|
-
allowed_curp:
|
|
24
|
+
allowed_curp: Optional[Curp] = None,
|
|
25
25
|
allowed_rfc: Optional[Rfc] = None,
|
|
26
26
|
) -> 'LimitedWallet':
|
|
27
27
|
"""
|
|
@@ -37,4 +37,4 @@ class LimitedWallet(Wallet):
|
|
|
37
37
|
allowed_curp=allowed_curp,
|
|
38
38
|
allowed_rfc=allowed_rfc,
|
|
39
39
|
)
|
|
40
|
-
return
|
|
40
|
+
return cls._create(**request.model_dump())
|
cuenca/resources/login_tokens.py
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
from typing import ClassVar
|
|
1
|
+
from typing import ClassVar
|
|
2
2
|
|
|
3
|
-
from pydantic import ConfigDict
|
|
3
|
+
from pydantic import ConfigDict
|
|
4
4
|
|
|
5
5
|
from ..http import Session, session as global_session
|
|
6
6
|
from .base import Creatable
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
# mypy: disable-error-code=override
|
|
10
9
|
class LoginToken(Creatable):
|
|
11
10
|
_resource: ClassVar = 'login_tokens'
|
|
12
11
|
|
|
13
|
-
# Override the `id` field to be a `SecretStr`
|
|
14
|
-
# To ensure sensitive data is not exposed in logs.
|
|
15
|
-
id: SecretStr # type: ignore
|
|
16
|
-
|
|
17
12
|
model_config = ConfigDict(
|
|
18
13
|
json_schema_extra={'example': {'id': 'LTNEUInh69SuKXXmK95sROwQ'}}
|
|
19
14
|
)
|
|
@@ -25,4 +20,4 @@ class LoginToken(Creatable):
|
|
|
25
20
|
Make sure to store this token in a safe place
|
|
26
21
|
:return: Token that you can use in cuenca.configure
|
|
27
22
|
"""
|
|
28
|
-
return
|
|
23
|
+
return cls._create(session=session)
|
cuenca/resources/otps.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
from typing import ClassVar
|
|
1
|
+
from typing import ClassVar
|
|
2
2
|
|
|
3
|
-
from pydantic import ConfigDict
|
|
3
|
+
from pydantic import ConfigDict
|
|
4
4
|
|
|
5
5
|
from ..http import Session, session as global_session
|
|
6
6
|
from .base import Creatable
|
|
@@ -8,7 +8,8 @@ from .base import Creatable
|
|
|
8
8
|
|
|
9
9
|
class Otp(Creatable):
|
|
10
10
|
_resource: ClassVar = 'otps'
|
|
11
|
-
secret:
|
|
11
|
+
secret: str
|
|
12
|
+
|
|
12
13
|
model_config = ConfigDict(
|
|
13
14
|
json_schema_extra={
|
|
14
15
|
'example': {
|
|
@@ -23,4 +24,4 @@ class Otp(Creatable):
|
|
|
23
24
|
"""
|
|
24
25
|
Use this method to create a OTP seed
|
|
25
26
|
"""
|
|
26
|
-
return
|
|
27
|
+
return cls._create(session=session)
|
cuenca/resources/platforms.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
|
-
from typing import ClassVar, Optional
|
|
2
|
+
from typing import ClassVar, Optional
|
|
3
3
|
|
|
4
4
|
from cuenca_validations.types import Country, PlatformRequest, State
|
|
5
5
|
from pydantic import ConfigDict, Field
|
|
@@ -12,7 +12,7 @@ class Platform(Creatable):
|
|
|
12
12
|
_resource: ClassVar = 'platforms'
|
|
13
13
|
|
|
14
14
|
created_at: dt.datetime
|
|
15
|
-
name: str = Field(
|
|
15
|
+
name: str = Field(description='name of the platform being created')
|
|
16
16
|
rfc: Optional[str] = Field(None, description='RFC or CURP of the platform')
|
|
17
17
|
establishment_date: Optional[dt.date] = Field(
|
|
18
18
|
None, description='when the platform was established'
|
|
@@ -46,7 +46,7 @@ class Platform(Creatable):
|
|
|
46
46
|
'phone_number': '+525555555555',
|
|
47
47
|
'email_address': 'art@eria.com',
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|
|
50
50
|
)
|
|
51
51
|
|
|
52
52
|
@classmethod
|
|
@@ -54,7 +54,7 @@ class Platform(Creatable):
|
|
|
54
54
|
cls,
|
|
55
55
|
name: str,
|
|
56
56
|
rfc: Optional[str] = None,
|
|
57
|
-
establishment_date: Optional[
|
|
57
|
+
establishment_date: Optional[str] = None,
|
|
58
58
|
country: Optional[Country] = None,
|
|
59
59
|
state: Optional[State] = None,
|
|
60
60
|
economic_activity: Optional[str] = None,
|
|
@@ -73,6 +73,4 @@ class Platform(Creatable):
|
|
|
73
73
|
phone_number=phone_number,
|
|
74
74
|
email_address=email_address,
|
|
75
75
|
)
|
|
76
|
-
return
|
|
77
|
-
'Platform', cls._create(session=session, **req.model_dump())
|
|
78
|
-
)
|
|
76
|
+
return cls._create(session=session, **req.model_dump())
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
|
-
from typing import ClassVar
|
|
2
|
+
from typing import ClassVar
|
|
3
3
|
|
|
4
4
|
from cuenca_validations.types import QuestionnairesRequest
|
|
5
5
|
from pydantic import ConfigDict
|
|
@@ -15,6 +15,7 @@ class Questionnaires(Creatable, Retrievable):
|
|
|
15
15
|
token: str
|
|
16
16
|
form_id: str
|
|
17
17
|
user_id: str
|
|
18
|
+
|
|
18
19
|
model_config = ConfigDict(
|
|
19
20
|
json_schema_extra={
|
|
20
21
|
'example': {
|
|
@@ -39,6 +40,4 @@ class Questionnaires(Creatable, Retrievable):
|
|
|
39
40
|
token=token,
|
|
40
41
|
form_id=form_id,
|
|
41
42
|
)
|
|
42
|
-
return
|
|
43
|
-
'Questionnaires', cls._create(session=session, **req.model_dump())
|
|
44
|
-
)
|
|
43
|
+
return cls._create(session=session, **req.model_dump())
|
cuenca/resources/resources.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import re
|
|
2
|
-
from typing import cast
|
|
3
2
|
|
|
4
3
|
from .base import Retrievable
|
|
5
4
|
|
|
@@ -12,7 +11,7 @@ def retrieve_uri(uri: str) -> Retrievable:
|
|
|
12
11
|
if not m:
|
|
13
12
|
raise ValueError(f'uri is not a valid format: {uri}')
|
|
14
13
|
resource, id_ = m.groups()
|
|
15
|
-
return
|
|
14
|
+
return RESOURCES[resource].retrieve(id_)
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
def retrieve_uris(uris: list[str]) -> list[Retrievable]:
|
cuenca/resources/savings.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
|
-
from typing import ClassVar, Optional
|
|
2
|
+
from typing import ClassVar, Optional
|
|
3
3
|
|
|
4
4
|
from cuenca_validations.types import (
|
|
5
5
|
SavingCategory,
|
|
@@ -27,14 +27,14 @@ class Saving(Wallet, Updateable):
|
|
|
27
27
|
category: SavingCategory,
|
|
28
28
|
goal_amount: Optional[int] = None,
|
|
29
29
|
goal_date: Optional[dt.datetime] = None,
|
|
30
|
-
):
|
|
30
|
+
) -> 'Saving':
|
|
31
31
|
request = SavingRequest(
|
|
32
32
|
name=name,
|
|
33
33
|
category=category,
|
|
34
34
|
goal_amount=goal_amount,
|
|
35
35
|
goal_date=goal_date,
|
|
36
36
|
)
|
|
37
|
-
return
|
|
37
|
+
return cls._create(**request.model_dump())
|
|
38
38
|
|
|
39
39
|
@classmethod
|
|
40
40
|
def update(
|
|
@@ -51,6 +51,4 @@ class Saving(Wallet, Updateable):
|
|
|
51
51
|
goal_amount=goal_amount,
|
|
52
52
|
goal_date=goal_date,
|
|
53
53
|
)
|
|
54
|
-
return
|
|
55
|
-
'Saving', cls._update(id=saving_id, **request.model_dump())
|
|
56
|
-
)
|
|
54
|
+
return cls._update(id=saving_id, **request.model_dump())
|
cuenca/resources/sessions.py
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
|
-
from typing import ClassVar, Optional
|
|
2
|
+
from typing import ClassVar, Optional
|
|
3
3
|
|
|
4
|
-
from cuenca_validations.types import
|
|
5
|
-
from pydantic import
|
|
4
|
+
from cuenca_validations.types import SessionRequest, SessionType
|
|
5
|
+
from pydantic import AnyUrl, ConfigDict
|
|
6
6
|
|
|
7
7
|
from .. import http
|
|
8
8
|
from .base import Creatable, Queryable, Retrievable
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
# mypy: disable-error-code=override
|
|
12
11
|
class Session(Creatable, Retrievable, Queryable):
|
|
13
12
|
_resource: ClassVar = 'sessions'
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
# To ensure sensitive data is not exposed in logs.
|
|
17
|
-
id: SecretStr = None # type: ignore
|
|
14
|
+
id: str
|
|
18
15
|
created_at: dt.datetime
|
|
19
16
|
user_id: str
|
|
20
17
|
platform_id: str
|
|
21
18
|
expires_at: dt.datetime
|
|
22
|
-
success_url: Optional[
|
|
23
|
-
failure_url: Optional[
|
|
19
|
+
success_url: Optional[AnyUrl] = None
|
|
20
|
+
failure_url: Optional[AnyUrl] = None
|
|
24
21
|
type: Optional[SessionType] = None
|
|
22
|
+
|
|
25
23
|
model_config = ConfigDict(
|
|
26
24
|
json_schema_extra={
|
|
27
25
|
'example': {
|
|
@@ -50,9 +48,7 @@ class Session(Creatable, Retrievable, Queryable):
|
|
|
50
48
|
req = SessionRequest(
|
|
51
49
|
user_id=user_id,
|
|
52
50
|
type=type,
|
|
53
|
-
success_url=success_url,
|
|
54
|
-
failure_url=failure_url,
|
|
55
|
-
)
|
|
56
|
-
return cast(
|
|
57
|
-
'Session', cls._create(session=session, **req.model_dump())
|
|
51
|
+
success_url=success_url,
|
|
52
|
+
failure_url=failure_url,
|
|
58
53
|
)
|
|
54
|
+
return cls._create(session=session, **req.model_dump())
|
cuenca/resources/transfers.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
2
|
from typing import ClassVar, Optional, cast
|
|
3
3
|
|
|
4
|
-
from clabe import Clabe
|
|
5
4
|
from cuenca_validations.types import (
|
|
6
5
|
TransferNetwork,
|
|
7
6
|
TransferQuery,
|
|
@@ -63,14 +62,14 @@ class Transfer(Transaction, Creatable):
|
|
|
63
62
|
if not idempotency_key:
|
|
64
63
|
idempotency_key = cls._gen_idempotency_key(account_number, amount)
|
|
65
64
|
req = TransferRequest(
|
|
66
|
-
account_number=
|
|
65
|
+
account_number=account_number,
|
|
67
66
|
amount=amount,
|
|
68
67
|
descriptor=descriptor,
|
|
69
68
|
recipient_name=recipient_name,
|
|
70
69
|
idempotency_key=idempotency_key,
|
|
71
70
|
user_id=user_id,
|
|
72
71
|
)
|
|
73
|
-
return
|
|
72
|
+
return cls._create(**req.model_dump())
|
|
74
73
|
|
|
75
74
|
@classmethod
|
|
76
75
|
def create_many(cls, requests: list[TransferRequest]) -> DictStrAny:
|
|
@@ -81,7 +80,7 @@ class Transfer(Transaction, Creatable):
|
|
|
81
80
|
except (CuencaException, HTTPError) as e:
|
|
82
81
|
transfers['errors'].append(dict(request=req, error=e))
|
|
83
82
|
else:
|
|
84
|
-
transfers['submitted'].append(
|
|
83
|
+
transfers['submitted'].append(transfer)
|
|
85
84
|
return transfers
|
|
86
85
|
|
|
87
86
|
@staticmethod
|
|
@@ -91,4 +90,4 @@ class Transfer(Transaction, Creatable):
|
|
|
91
90
|
idempotency_key, but this provides some level of protection against
|
|
92
91
|
submitting duplicate transfers
|
|
93
92
|
"""
|
|
94
|
-
return f'{dt.datetime.utcnow().date()}:
|
|
93
|
+
return f'{dt.datetime.utcnow().date()}:{account_number}:{amount}'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
|
-
from typing import ClassVar, Optional
|
|
2
|
+
from typing import ClassVar, Optional
|
|
3
3
|
|
|
4
4
|
from cuenca_validations.types.requests import (
|
|
5
5
|
UserCredentialRequest,
|
|
@@ -25,9 +25,7 @@ class UserCredential(Creatable, Updateable):
|
|
|
25
25
|
session: Session = global_session,
|
|
26
26
|
) -> 'UserCredential':
|
|
27
27
|
req = UserCredentialRequest(password=password, user_id=user_id)
|
|
28
|
-
return
|
|
29
|
-
'UserCredential', cls._create(**req.model_dump(), session=session)
|
|
30
|
-
)
|
|
28
|
+
return cls._create(**req.model_dump(), session=session)
|
|
31
29
|
|
|
32
30
|
@classmethod
|
|
33
31
|
def update(
|
|
@@ -42,7 +40,4 @@ class UserCredential(Creatable, Updateable):
|
|
|
42
40
|
is_active=is_active,
|
|
43
41
|
password=password,
|
|
44
42
|
)
|
|
45
|
-
return
|
|
46
|
-
'UserCredential',
|
|
47
|
-
cls._update(id=user_id, **req.model_dump(), session=session),
|
|
48
|
-
)
|
|
43
|
+
return cls._update(id=user_id, **req.model_dump(), session=session)
|
cuenca/resources/user_events.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
|
-
from typing import ClassVar, Optional
|
|
2
|
+
from typing import ClassVar, Optional
|
|
3
3
|
|
|
4
|
-
from clabe import Clabe
|
|
5
4
|
from cuenca_validations.types import UserListsRequest, VerificationStatus
|
|
6
|
-
from cuenca_validations.types.identities import
|
|
5
|
+
from cuenca_validations.types.identities import Curp
|
|
7
6
|
|
|
8
7
|
from ..http import Session, session as global_session
|
|
9
8
|
from .base import Creatable, Retrievable
|
|
@@ -15,7 +14,7 @@ class UserListsValidation(Creatable, Retrievable):
|
|
|
15
14
|
names: Optional[str] = None
|
|
16
15
|
first_surname: Optional[str] = None
|
|
17
16
|
second_surname: Optional[str] = None
|
|
18
|
-
curp: Optional[
|
|
17
|
+
curp: Optional[Curp] = None
|
|
19
18
|
account_number: Optional[str] = None
|
|
20
19
|
status: Optional[VerificationStatus] = None
|
|
21
20
|
|
|
@@ -25,7 +24,7 @@ class UserListsValidation(Creatable, Retrievable):
|
|
|
25
24
|
names: Optional[str] = None,
|
|
26
25
|
first_surname: Optional[str] = None,
|
|
27
26
|
second_surname: Optional[str] = None,
|
|
28
|
-
curp: Optional[
|
|
27
|
+
curp: Optional[Curp] = None,
|
|
29
28
|
account_number: Optional[str] = None,
|
|
30
29
|
*,
|
|
31
30
|
session: Session = global_session,
|
|
@@ -35,9 +34,6 @@ class UserListsValidation(Creatable, Retrievable):
|
|
|
35
34
|
first_surname=first_surname,
|
|
36
35
|
second_surname=second_surname,
|
|
37
36
|
curp=curp,
|
|
38
|
-
account_number=
|
|
39
|
-
)
|
|
40
|
-
return cast(
|
|
41
|
-
'UserListsValidation',
|
|
42
|
-
cls._create(session=session, **req.model_dump()),
|
|
37
|
+
account_number=account_number,
|
|
43
38
|
)
|
|
39
|
+
return cls._create(session=session, **req.model_dump())
|
cuenca/resources/user_logins.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
|
-
from typing import ClassVar, Optional
|
|
2
|
+
from typing import ClassVar, Optional
|
|
3
3
|
|
|
4
4
|
from cuenca_validations.types.requests import UserLoginRequest
|
|
5
5
|
from pydantic import ConfigDict
|
|
@@ -13,6 +13,7 @@ class UserLogin(Creatable):
|
|
|
13
13
|
|
|
14
14
|
last_login_at: Optional[dt.datetime] = None
|
|
15
15
|
success: bool
|
|
16
|
+
|
|
16
17
|
model_config = ConfigDict(
|
|
17
18
|
json_schema_extra={
|
|
18
19
|
'example': {
|
|
@@ -32,9 +33,7 @@ class UserLogin(Creatable):
|
|
|
32
33
|
session: Session = global_session,
|
|
33
34
|
) -> 'UserLogin':
|
|
34
35
|
req = UserLoginRequest(password=password, user_id=user_id)
|
|
35
|
-
login =
|
|
36
|
-
'UserLogin', cls._create(session=session, **req.model_dump())
|
|
37
|
-
)
|
|
36
|
+
login = cls._create(session=session, **req.model_dump())
|
|
38
37
|
if login.success:
|
|
39
38
|
session.headers['X-Cuenca-LoginId'] = login.id
|
|
40
39
|
return login
|
cuenca/resources/users.py
CHANGED
|
@@ -15,7 +15,7 @@ from cuenca_validations.types import (
|
|
|
15
15
|
UserUpdateRequest,
|
|
16
16
|
)
|
|
17
17
|
from cuenca_validations.types.enums import Country, Gender, State
|
|
18
|
-
from cuenca_validations.types.identities import
|
|
18
|
+
from cuenca_validations.types.identities import Curp
|
|
19
19
|
from pydantic import ConfigDict, EmailStr, Field, HttpUrl
|
|
20
20
|
|
|
21
21
|
from ..http import Session, session as global_session
|
|
@@ -31,10 +31,10 @@ class User(Creatable, Retrievable, Updateable, Queryable):
|
|
|
31
31
|
|
|
32
32
|
identity_uri: str
|
|
33
33
|
level: int = Field(
|
|
34
|
-
|
|
34
|
+
description='Account level according to KYC information'
|
|
35
35
|
)
|
|
36
36
|
required_level: int = Field(
|
|
37
|
-
|
|
37
|
+
description='Maximum level User can reach. Set by platform'
|
|
38
38
|
)
|
|
39
39
|
created_at: dt.datetime
|
|
40
40
|
phone_number: Optional[PhoneNumber] = None
|
|
@@ -71,7 +71,7 @@ class User(Creatable, Retrievable, Updateable, Queryable):
|
|
|
71
71
|
|
|
72
72
|
@property
|
|
73
73
|
def balance(self) -> int:
|
|
74
|
-
be =
|
|
74
|
+
be = BalanceEntry.first(user_id=self.id)
|
|
75
75
|
return be.rolling_balance if be else 0
|
|
76
76
|
|
|
77
77
|
model_config = ConfigDict(
|
|
@@ -97,14 +97,13 @@ class User(Creatable, Retrievable, Updateable, Queryable):
|
|
|
97
97
|
],
|
|
98
98
|
'platform_id': 'PT8UEv02zBTcymd4Kd3MO6pg',
|
|
99
99
|
}
|
|
100
|
-
}
|
|
100
|
+
}
|
|
101
101
|
)
|
|
102
102
|
|
|
103
103
|
@classmethod
|
|
104
104
|
def create(
|
|
105
105
|
cls,
|
|
106
|
-
curp:
|
|
107
|
-
id: Optional[str] = None,
|
|
106
|
+
curp: Curp,
|
|
108
107
|
phone_number: Optional[PhoneNumber] = None,
|
|
109
108
|
email_address: Optional[EmailStr] = None,
|
|
110
109
|
profession: Optional[str] = None,
|
|
@@ -118,7 +117,6 @@ class User(Creatable, Retrievable, Updateable, Queryable):
|
|
|
118
117
|
session: Session = global_session,
|
|
119
118
|
) -> 'User':
|
|
120
119
|
req = UserRequest(
|
|
121
|
-
id=id,
|
|
122
120
|
curp=curp,
|
|
123
121
|
phone_number=phone_number,
|
|
124
122
|
email_address=email_address,
|
|
@@ -130,7 +128,7 @@ class User(Creatable, Retrievable, Updateable, Queryable):
|
|
|
130
128
|
status=status,
|
|
131
129
|
terms_of_service=terms_of_service,
|
|
132
130
|
)
|
|
133
|
-
return
|
|
131
|
+
return cls._create(session=session, **req.model_dump())
|
|
134
132
|
|
|
135
133
|
@classmethod
|
|
136
134
|
def update(
|
|
@@ -149,10 +147,10 @@ class User(Creatable, Retrievable, Updateable, Queryable):
|
|
|
149
147
|
status: Optional[UserStatus] = None,
|
|
150
148
|
email_verification_id: Optional[str] = None,
|
|
151
149
|
phone_verification_id: Optional[str] = None,
|
|
152
|
-
|
|
150
|
+
curp_document: Optional[HttpUrl] = None,
|
|
153
151
|
*,
|
|
154
152
|
session: Session = global_session,
|
|
155
|
-
):
|
|
153
|
+
) -> 'User':
|
|
156
154
|
request = UserUpdateRequest(
|
|
157
155
|
phone_number=phone_number,
|
|
158
156
|
email_address=email_address,
|
|
@@ -166,13 +164,10 @@ class User(Creatable, Retrievable, Updateable, Queryable):
|
|
|
166
164
|
verification_id=verification_id,
|
|
167
165
|
email_verification_id=email_verification_id,
|
|
168
166
|
phone_verification_id=phone_verification_id,
|
|
169
|
-
|
|
167
|
+
curp_document=curp_document,
|
|
170
168
|
status=status,
|
|
171
169
|
)
|
|
172
|
-
return
|
|
173
|
-
'User',
|
|
174
|
-
cls._update(id=user_id, **request.model_dump(), session=session),
|
|
175
|
-
)
|
|
170
|
+
return cls._update(id=user_id, **request.model_dump(), session=session)
|
|
176
171
|
|
|
177
172
|
@property
|
|
178
173
|
def identity(self) -> Identity:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
|
-
from typing import ClassVar, Optional, Union
|
|
2
|
+
from typing import ClassVar, Optional, Union
|
|
3
3
|
|
|
4
4
|
from cuenca_validations.types import (
|
|
5
5
|
VerificationAttemptRequest,
|
|
@@ -17,7 +17,7 @@ class Verification(Creatable, Updateable):
|
|
|
17
17
|
_resource: ClassVar = 'verifications'
|
|
18
18
|
|
|
19
19
|
recipient: Union[EmailStr, PhoneNumber] = Field(
|
|
20
|
-
|
|
20
|
+
description='Phone or email to validate'
|
|
21
21
|
)
|
|
22
22
|
type: VerificationType
|
|
23
23
|
created_at: dt.datetime
|
|
@@ -31,7 +31,7 @@ class Verification(Creatable, Updateable):
|
|
|
31
31
|
'created_at': '2022-05-24T14:15:22Z',
|
|
32
32
|
'deactivated_at': None,
|
|
33
33
|
}
|
|
34
|
-
}
|
|
34
|
+
}
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
@classmethod
|
|
@@ -45,9 +45,7 @@ class Verification(Creatable, Updateable):
|
|
|
45
45
|
req = VerificationRequest(
|
|
46
46
|
recipient=recipient, type=type, platform_id=platform_id
|
|
47
47
|
)
|
|
48
|
-
return
|
|
49
|
-
'Verification', cls._create(**req.model_dump(), session=session)
|
|
50
|
-
)
|
|
48
|
+
return cls._create(**req.model_dump(), session=session)
|
|
51
49
|
|
|
52
50
|
@classmethod
|
|
53
51
|
def verify(
|
|
@@ -57,7 +55,4 @@ class Verification(Creatable, Updateable):
|
|
|
57
55
|
session: Session = global_session,
|
|
58
56
|
) -> 'Verification':
|
|
59
57
|
req = VerificationAttemptRequest(code=code)
|
|
60
|
-
return
|
|
61
|
-
'Verification',
|
|
62
|
-
cls._update(id=id, **req.model_dump(), session=session),
|
|
63
|
-
)
|
|
58
|
+
return cls._update(id=id, **req.model_dump(), session=session)
|
|
@@ -29,10 +29,10 @@ class WalletTransaction(Transaction, Creatable):
|
|
|
29
29
|
wallet_uri: str,
|
|
30
30
|
transaction_type: WalletTransactionType,
|
|
31
31
|
amount: int,
|
|
32
|
-
):
|
|
32
|
+
) -> 'WalletTransaction':
|
|
33
33
|
request = WalletTransactionRequest(
|
|
34
34
|
wallet_uri=wallet_uri,
|
|
35
35
|
transaction_type=transaction_type,
|
|
36
36
|
amount=amount,
|
|
37
37
|
)
|
|
38
|
-
return
|
|
38
|
+
return cls._create(**request.model_dump())
|
cuenca/resources/webhooks.py
CHANGED
|
@@ -9,9 +9,5 @@ from .base import Queryable, Retrievable
|
|
|
9
9
|
class Webhook(Retrievable, Queryable):
|
|
10
10
|
_resource: ClassVar = 'webhooks'
|
|
11
11
|
|
|
12
|
-
payload: dict[str, Any] = Field(
|
|
13
|
-
|
|
14
|
-
)
|
|
15
|
-
event: WebhookEvent = Field(
|
|
16
|
-
..., description='type of event being reported'
|
|
17
|
-
)
|
|
12
|
+
payload: dict[str, Any] = Field(description='object sent by the webhook')
|
|
13
|
+
event: WebhookEvent = Field(description='type of event being reported')
|
cuenca/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: cuenca
|
|
3
|
-
Version: 2.0.0.
|
|
3
|
+
Version: 2.0.0.dev7
|
|
4
4
|
Summary: Cuenca API Client
|
|
5
5
|
Home-page: https://github.com/cuenca-mx/cuenca-python
|
|
6
6
|
Author: Cuenca
|
|
@@ -15,9 +15,9 @@ Classifier: Operating System :: OS Independent
|
|
|
15
15
|
Requires-Python: >=3.9
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: requests>=2.32.
|
|
19
|
-
Requires-Dist: cuenca-validations
|
|
20
|
-
Requires-Dist: pydantic-extra-types>=2.10.
|
|
18
|
+
Requires-Dist: requests>=2.32.0
|
|
19
|
+
Requires-Dist: cuenca-validations>=2.0.0
|
|
20
|
+
Requires-Dist: pydantic-extra-types>=2.10.0
|
|
21
21
|
Dynamic: author
|
|
22
22
|
Dynamic: author-email
|
|
23
23
|
Dynamic: classifier
|