Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cuenca/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'FileBatch',
'Identity',
'IdentityEvent',
'LimitedWallet',
'LoginToken',
'Saving',
'ServiceProvider',
Expand Down Expand Up @@ -56,6 +57,7 @@
FileBatch,
Identity,
IdentityEvent,
LimitedWallet,
LoginToken,
Saving,
ServiceProvider,
Expand Down
3 changes: 3 additions & 0 deletions cuenca/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'FileBatch',
'Identity',
'IdentityEvent',
'LimitedWallet',
'LoginToken',
'Saving',
'ServiceProvider',
Expand Down Expand Up @@ -48,6 +49,7 @@
from .files import File
from .identities import Identity
from .identity_events import IdentityEvent
from .limited_wallets import LimitedWallet
from .login_tokens import LoginToken
from .resources import RESOURCES
from .savings import Saving
Expand Down Expand Up @@ -83,6 +85,7 @@
FileBatch,
Identity,
IdentityEvent,
LimitedWallet,
LoginToken,
Saving,
Session,
Expand Down
42 changes: 42 additions & 0 deletions cuenca/resources/limited_wallets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from dataclasses import dataclass
from typing import ClassVar, Optional, cast

from clabe import Clabe
from cuenca_validations.types import (
AccountQuery,
CurpField,
LimitedWalletRequest,
Rfc,
)

from .base import Wallet


@dataclass
class LimitedWallet(Wallet):
_resource: ClassVar = 'limited_wallets'
_query_params: ClassVar = AccountQuery
account_number: Clabe
allowed_rfc: Rfc
allowed_curp: CurpField

@classmethod
def create(
cls,
allowed_curp: Optional[CurpField] = None,
allowed_rfc: Optional[Rfc] = None,
) -> 'LimitedWallet':
"""
Limited wallet is a special sub-account to receive money only from
specific person, SPEI Deposits will be accepted only if the sender
account curp/rfc match with registered data

Args:
allowed_curp: Valid CURP
allowed_rfc: Valid RFC
"""
request = LimitedWalletRequest(
allowed_curp=allowed_curp,
allowed_rfc=allowed_rfc,
)
return cast('LimitedWallet', cls._create(**request.dict()))
18 changes: 11 additions & 7 deletions cuenca/resources/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class User(Creatable, Retrievable, Updateable, Queryable):
identity_uri: str
level: int
created_at: dt.datetime
phone_number: PhoneNumber
email_address: EmailStr
profession: str
phone_number: Optional[PhoneNumber]
email_address: Optional[EmailStr]
profession: Optional[str]
terms_of_service: Optional[TOSAgreement]
status: Optional[UserStatus]
address: Optional[Address]
Expand All @@ -49,10 +49,12 @@ class User(Creatable, Retrievable, Updateable, Queryable):
def create(
cls,
curp: CurpField,
phone_number: PhoneNumber,
email_address: EmailStr,
profession: str,
address: Address,
phone_number: Optional[PhoneNumber] = None,
email_address: Optional[EmailStr] = None,
profession: Optional[str] = None,
address: Optional[Address] = None,
email_verification_id: Optional[str] = None,
phone_verification_id: Optional[str] = None,
*,
session: Session = global_session,
) -> 'User':
Expand All @@ -62,6 +64,8 @@ def create(
email_address=email_address,
profession=profession,
address=address,
email_verification_id=email_verification_id,
phone_verification_id=phone_verification_id,
)
return cast('User', cls._create(session=session, **req.dict()))

Expand Down
2 changes: 1 addition & 1 deletion cuenca/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '0.8.0'
__version__ = '0.9.0'
CLIENT_VERSION = __version__
API_VERSION = '2020-03-19'
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests==2.27.1
cuenca-validations==0.10.0
cuenca-validations==0.10.1
dataclasses>=0.7;python_version<"3.7"
56 changes: 56 additions & 0 deletions tests/resources/cassettes/test_limited_wallet_create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
interactions:
- request:
body: '{"allowed_curp": "TAXM840916HNEMXT02", "allowed_rfc": "TAXM840916123"}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- DUMMY
Connection:
- keep-alive
Content-Length:
- '70'
Content-Type:
- application/json
User-Agent:
- cuenca-python/0.8.1.dev0
X-Cuenca-Api-Version:
- '2020-03-19'
method: POST
uri: https://sandbox.cuenca.com/limited_wallets
response:
body:
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"}'
headers:
Connection:
- keep-alive
Content-Length:
- '292'
Content-Type:
- application/json
Date:
- Tue, 05 Apr 2022 23:00:30 GMT
X-Amzn-Trace-Id:
- Root=1-624cca0d-777e789766cb37857cf62965;Sampled=0
X-Request-Time:
- 'value: 1.039'
x-amz-apigw-id:
- QISCFHDBiYcFVNQ=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '292'
x-amzn-Remapped-Date:
- Tue, 05 Apr 2022 23:00:30 GMT
x-amzn-Remapped-Server:
- nginx/1.20.2
x-amzn-Remapped-x-amzn-RequestId:
- ffeee6be-a037-422d-ab2b-d739866c6ade
x-amzn-RequestId:
- d106e615-825d-4412-bf58-1ab8d9aaba02
status:
code: 201
message: Created
version: 1
52 changes: 52 additions & 0 deletions tests/resources/cassettes/test_limited_wallet_retrieve.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- DUMMY
Connection:
- keep-alive
User-Agent:
- cuenca-python/0.8.1.dev0
X-Cuenca-Api-Version:
- '2020-03-19'
method: GET
uri: https://sandbox.cuenca.com/limited_wallets/LA3vx08KlQCXsaP9qyWfb680
response:
body:
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"}'
headers:
Connection:
- keep-alive
Content-Length:
- '292'
Content-Type:
- application/json
Date:
- Tue, 05 Apr 2022 23:01:40 GMT
X-Amzn-Trace-Id:
- Root=1-624cca54-3540a54414ac35972cb3c426;Sampled=0
X-Request-Time:
- 'value: 0.292'
x-amz-apigw-id:
- QISNPE83iYcF2MQ=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '292'
x-amzn-Remapped-Date:
- Tue, 05 Apr 2022 23:01:40 GMT
x-amzn-Remapped-Server:
- nginx/1.20.2
x-amzn-Remapped-x-amzn-RequestId:
- 3fbb3706-abb5-4e66-a702-8be94a85d572
x-amzn-RequestId:
- 9149cc06-3370-4718-9f2b-61a8178be034
status:
code: 200
message: OK
version: 1
21 changes: 21 additions & 0 deletions tests/resources/test_limited_wallets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest

from cuenca import LimitedWallet


@pytest.mark.vcr
def test_limited_wallet_create():
curp = 'TAXM840916HNEMXT02'
rfc = 'TAXM840916123'
wallet = LimitedWallet.create(allowed_curp=curp, allowed_rfc=rfc)
assert wallet.id is not None
assert wallet.balance == 0
assert wallet.allowed_curp == curp
assert wallet.allowed_rfc == rfc


@pytest.mark.vcr
def test_limited_wallet_retrieve():
id = 'LA3vx08KlQCXsaP9qyWfb680'
wallet = LimitedWallet.retrieve(id)
assert wallet.id == id