Skip to content

Commit 97a2ac3

Browse files
rogelioLpzfelipao-mxchiqeen03pachCode
authored
Limited wallets and Arteria Types (#248)
* limited wallets * lint * cuenca validations * add LimitedWallet model to resources package * resource * tests and cassets * version * types arteria by Manu * Moving verifications to create * Update version.py * Update requirements.txt * Update version.py Co-authored-by: Felipe López <flh.1989@gmail.com> Co-authored-by: Manuel Avalos <manuelavalos97@gmail.com> Co-authored-by: Pach <arturo@cuenca.com>
1 parent 9a3f652 commit 97a2ac3

File tree

9 files changed

+189
-9
lines changed

9 files changed

+189
-9
lines changed

cuenca/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
'FileBatch',
1818
'Identity',
1919
'IdentityEvent',
20+
'LimitedWallet',
2021
'LoginToken',
2122
'Saving',
2223
'ServiceProvider',
@@ -56,6 +57,7 @@
5657
FileBatch,
5758
Identity,
5859
IdentityEvent,
60+
LimitedWallet,
5961
LoginToken,
6062
Saving,
6163
ServiceProvider,

cuenca/resources/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
'FileBatch',
1717
'Identity',
1818
'IdentityEvent',
19+
'LimitedWallet',
1920
'LoginToken',
2021
'Saving',
2122
'ServiceProvider',
@@ -48,6 +49,7 @@
4849
from .files import File
4950
from .identities import Identity
5051
from .identity_events import IdentityEvent
52+
from .limited_wallets import LimitedWallet
5153
from .login_tokens import LoginToken
5254
from .resources import RESOURCES
5355
from .savings import Saving
@@ -83,6 +85,7 @@
8385
FileBatch,
8486
Identity,
8587
IdentityEvent,
88+
LimitedWallet,
8689
LoginToken,
8790
Saving,
8891
Session,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from dataclasses import dataclass
2+
from typing import ClassVar, Optional, cast
3+
4+
from clabe import Clabe
5+
from cuenca_validations.types import (
6+
AccountQuery,
7+
CurpField,
8+
LimitedWalletRequest,
9+
Rfc,
10+
)
11+
12+
from .base import Wallet
13+
14+
15+
@dataclass
16+
class LimitedWallet(Wallet):
17+
_resource: ClassVar = 'limited_wallets'
18+
_query_params: ClassVar = AccountQuery
19+
account_number: Clabe
20+
allowed_rfc: Rfc
21+
allowed_curp: CurpField
22+
23+
@classmethod
24+
def create(
25+
cls,
26+
allowed_curp: Optional[CurpField] = None,
27+
allowed_rfc: Optional[Rfc] = None,
28+
) -> 'LimitedWallet':
29+
"""
30+
Limited wallet is a special sub-account to receive money only from
31+
specific person, SPEI Deposits will be accepted only if the sender
32+
account curp/rfc match with registered data
33+
34+
Args:
35+
allowed_curp: Valid CURP
36+
allowed_rfc: Valid RFC
37+
"""
38+
request = LimitedWalletRequest(
39+
allowed_curp=allowed_curp,
40+
allowed_rfc=allowed_rfc,
41+
)
42+
return cast('LimitedWallet', cls._create(**request.dict()))

cuenca/resources/users.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class User(Creatable, Retrievable, Updateable, Queryable):
3333
identity_uri: str
3434
level: int
3535
created_at: dt.datetime
36-
phone_number: PhoneNumber
37-
email_address: EmailStr
38-
profession: str
36+
phone_number: Optional[PhoneNumber]
37+
email_address: Optional[EmailStr]
38+
profession: Optional[str]
3939
terms_of_service: Optional[TOSAgreement]
4040
status: Optional[UserStatus]
4141
address: Optional[Address]
@@ -49,10 +49,12 @@ class User(Creatable, Retrievable, Updateable, Queryable):
4949
def create(
5050
cls,
5151
curp: CurpField,
52-
phone_number: PhoneNumber,
53-
email_address: EmailStr,
54-
profession: str,
55-
address: Address,
52+
phone_number: Optional[PhoneNumber] = None,
53+
email_address: Optional[EmailStr] = None,
54+
profession: Optional[str] = None,
55+
address: Optional[Address] = None,
56+
email_verification_id: Optional[str] = None,
57+
phone_verification_id: Optional[str] = None,
5658
*,
5759
session: Session = global_session,
5860
) -> 'User':
@@ -62,6 +64,8 @@ def create(
6264
email_address=email_address,
6365
profession=profession,
6466
address=address,
67+
email_verification_id=email_verification_id,
68+
phone_verification_id=phone_verification_id,
6569
)
6670
return cast('User', cls._create(session=session, **req.dict()))
6771

cuenca/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '0.8.0'
1+
__version__ = '0.9.0'
22
CLIENT_VERSION = __version__
33
API_VERSION = '2020-03-19'

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
requests==2.27.1
2-
cuenca-validations==0.10.0
2+
cuenca-validations==0.10.1
33
dataclasses>=0.7;python_version<"3.7"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
interactions:
2+
- request:
3+
body: '{"allowed_curp": "TAXM840916HNEMXT02", "allowed_rfc": "TAXM840916123"}'
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Authorization:
10+
- DUMMY
11+
Connection:
12+
- keep-alive
13+
Content-Length:
14+
- '70'
15+
Content-Type:
16+
- application/json
17+
User-Agent:
18+
- cuenca-python/0.8.1.dev0
19+
X-Cuenca-Api-Version:
20+
- '2020-03-19'
21+
method: POST
22+
uri: https://sandbox.cuenca.com/limited_wallets
23+
response:
24+
body:
25+
string: '{"id":"LA3vx08KlQCXsaP9qyWfb680","created_at":"2022-04-05T23:00:29.446957","updated_at":"2022-04-05T23:00:29.446965","user_id":"US1le53HEq05OMrFTIlzqGJK","balance":0,"deactivated_at":null,"account_number":"646180157057065610","allowed_rfc":"TAXM840916123","allowed_curp":"TAXM840916HNEMXT02"}'
26+
headers:
27+
Connection:
28+
- keep-alive
29+
Content-Length:
30+
- '292'
31+
Content-Type:
32+
- application/json
33+
Date:
34+
- Tue, 05 Apr 2022 23:00:30 GMT
35+
X-Amzn-Trace-Id:
36+
- Root=1-624cca0d-777e789766cb37857cf62965;Sampled=0
37+
X-Request-Time:
38+
- 'value: 1.039'
39+
x-amz-apigw-id:
40+
- QISCFHDBiYcFVNQ=
41+
x-amzn-Remapped-Connection:
42+
- keep-alive
43+
x-amzn-Remapped-Content-Length:
44+
- '292'
45+
x-amzn-Remapped-Date:
46+
- Tue, 05 Apr 2022 23:00:30 GMT
47+
x-amzn-Remapped-Server:
48+
- nginx/1.20.2
49+
x-amzn-Remapped-x-amzn-RequestId:
50+
- ffeee6be-a037-422d-ab2b-d739866c6ade
51+
x-amzn-RequestId:
52+
- d106e615-825d-4412-bf58-1ab8d9aaba02
53+
status:
54+
code: 201
55+
message: Created
56+
version: 1
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Authorization:
10+
- DUMMY
11+
Connection:
12+
- keep-alive
13+
User-Agent:
14+
- cuenca-python/0.8.1.dev0
15+
X-Cuenca-Api-Version:
16+
- '2020-03-19'
17+
method: GET
18+
uri: https://sandbox.cuenca.com/limited_wallets/LA3vx08KlQCXsaP9qyWfb680
19+
response:
20+
body:
21+
string: '{"id":"LA3vx08KlQCXsaP9qyWfb680","created_at":"2022-04-05T23:00:29.446000","updated_at":"2022-04-05T23:00:29.446000","user_id":"US1le53HEq05OMrFTIlzqGJK","balance":0,"deactivated_at":null,"account_number":"646180157057065610","allowed_rfc":"TAXM840916123","allowed_curp":"TAXM840916HNEMXT02"}'
22+
headers:
23+
Connection:
24+
- keep-alive
25+
Content-Length:
26+
- '292'
27+
Content-Type:
28+
- application/json
29+
Date:
30+
- Tue, 05 Apr 2022 23:01:40 GMT
31+
X-Amzn-Trace-Id:
32+
- Root=1-624cca54-3540a54414ac35972cb3c426;Sampled=0
33+
X-Request-Time:
34+
- 'value: 0.292'
35+
x-amz-apigw-id:
36+
- QISNPE83iYcF2MQ=
37+
x-amzn-Remapped-Connection:
38+
- keep-alive
39+
x-amzn-Remapped-Content-Length:
40+
- '292'
41+
x-amzn-Remapped-Date:
42+
- Tue, 05 Apr 2022 23:01:40 GMT
43+
x-amzn-Remapped-Server:
44+
- nginx/1.20.2
45+
x-amzn-Remapped-x-amzn-RequestId:
46+
- 3fbb3706-abb5-4e66-a702-8be94a85d572
47+
x-amzn-RequestId:
48+
- 9149cc06-3370-4718-9f2b-61a8178be034
49+
status:
50+
code: 200
51+
message: OK
52+
version: 1
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import pytest
2+
3+
from cuenca import LimitedWallet
4+
5+
6+
@pytest.mark.vcr
7+
def test_limited_wallet_create():
8+
curp = 'TAXM840916HNEMXT02'
9+
rfc = 'TAXM840916123'
10+
wallet = LimitedWallet.create(allowed_curp=curp, allowed_rfc=rfc)
11+
assert wallet.id is not None
12+
assert wallet.balance == 0
13+
assert wallet.allowed_curp == curp
14+
assert wallet.allowed_rfc == rfc
15+
16+
17+
@pytest.mark.vcr
18+
def test_limited_wallet_retrieve():
19+
id = 'LA3vx08KlQCXsaP9qyWfb680'
20+
wallet = LimitedWallet.retrieve(id)
21+
assert wallet.id == id

0 commit comments

Comments
 (0)