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
46 changes: 41 additions & 5 deletions cuenca/resources/clabes.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
from typing import ClassVar
from typing import ClassVar, Union

from cuenca_validations.types import (
ClabeQuery,
Curp,
ReferencedClabeRequest,
Rfc,
)
from pydantic import ConfigDict

from ..http import Session, session as global_session
from .base import Creatable, Queryable, Retrievable
from .base import Creatable, Queryable


class Clabe(Creatable, Queryable, Retrievable):
class Clabe(Creatable, Queryable):
_resource: ClassVar = 'clabes'
_query_params: ClassVar = ClabeQuery

clabe: str
user_id: str
allowed_curp_rfc: Union[Curp, Rfc]
is_default: bool = False

model_config = ConfigDict(
extra='ignore',
json_schema_extra={
'example': {
'id': '646180157020143365',
'clabe': '646180157020143365',
'user_id': 'USbIRH85qFQP5ggPKKQAu5PA',
'allowed_curp_rfc': 'LOPJ900101XXX',
'is_default': False,
'created_at': '2026-09-09T18:00:00.000000',
}
},
)

@classmethod
def create(cls, session: Session = global_session):
return cls._create(session=session)
def create(
cls,
legal_person_id: str,
allowed_curp_rfc: Union[Curp, Rfc],
*,
session: Session = global_session,
) -> 'Clabe':
req = ReferencedClabeRequest(
legal_person_id=legal_person_id,
allowed_curp_rfc=allowed_curp_rfc,
)
return cls._create(session=session, **req.model_dump())
2 changes: 1 addition & 1 deletion cuenca/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '2.2.4'
__version__ = '2.2.5'
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.32.3
cuenca-validations==2.1.44
cuenca-validations==2.1.46
pydantic-extra-types==2.10.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
python_requires='>=3.9',
install_requires=[
'requests>=2.32.0',
'cuenca-validations>=2.1.44',
'cuenca-validations>=2.1.46',
'pydantic-extra-types>=2.10.0',
],
classifiers=[
Expand Down
120 changes: 11 additions & 109 deletions tests/resources/cassettes/test_clabe_all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,138 +2,40 @@ interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- DUMMY
Connection:
- keep-alive
User-Agent:
- cuenca-python/0.13.10.dev102
X-Cuenca-Api-Version:
- '2020-03-19'
method: GET
uri: https://sandbox.cuenca.com/clabes
response:
body:
string: '{"items":[{"id":"CLD_zg463BQ6-yEjg8UE0jgQ","clabe":"646180157089988558","created_at":"2022-08-23T05:14:11.862000","user_id":"USbDnHlZYDShGoTS2NTD-Lmg"},{"id":"CLas7ZqaT5Quq6fgeiuel6KA","clabe":"646180157030689013","created_at":"2022-08-23T05:11:53.700000","user_id":"USbDnHlZYDShGoTS2NTD-Lmg"},{"id":"CLu4OYMy1USXOY4tGfGNUUsw","clabe":"646180157073856528","created_at":"2022-08-22T23:54:55.634000","user_id":"USbDnHlZYDShGoTS2NTD-Lmg"},{"id":"CLQSvYrsu7Qqm3WuhG0OVrlg","clabe":"646180157032158283","created_at":"2022-08-22T22:44:00.966000","user_id":"USbDnHlZYDShGoTS2NTD-Lmg"},{"id":"CLFyudOfs9Rt-ratC4WXJAoA","clabe":"646180157027880605","created_at":"2022-08-22T22:41:06.071000","user_id":"USbDnHlZYDShGoTS2NTD-Lmg"}],"next_page_uri":null,"count":null}'
headers:
Connection:
- keep-alive
Content-Length:
- '1049'
Content-Type:
- application/json
Date:
- Tue, 23 Aug 2022 05:21:51 GMT
X-Request-Time:
- 'value: 0.083'
x-amz-apigw-id:
- XTSNeEoIIAMFoDQ=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '1049'
x-amzn-Remapped-Date:
- Tue, 23 Aug 2022 05:21:51 GMT
x-amzn-Remapped-Server:
- nginx/1.22.0
x-amzn-RequestId:
- 6f394c5e-b5ff-44fa-9733-3cfb9b965360
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- DUMMY
Connection:
- keep-alive
User-Agent:
- cuenca-python/0.13.10.dev102
X-Cuenca-Api-Version:
- '2020-03-19'
method: GET
uri: https://sandbox.cuenca.com/clabes?count=1
response:
body:
string: '{"items":[],"next_page_uri":null,"count":5,}}}'
headers:
Connection:
- keep-alive
Content-Length:
- '337'
Content-Type:
- application/json
Date:
- Tue, 23 Aug 2022 05:22:45 GMT
X-Request-Time:
- 'value: 0.067'
x-amz-apigw-id:
- XTSV2FbBoAMFgYA=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '337'
x-amzn-Remapped-Date:
- Tue, 23 Aug 2022 05:22:45 GMT
x-amzn-Remapped-Server:
- nginx/1.22.0
x-amzn-RequestId:
- 91aa3a7f-6d68-44b4-85fb-4192dc51276e
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- DUMMY
Connection:
- keep-alive
User-Agent:
- cuenca-python/0.13.10.dev102
- cuenca-python/2.2.5
X-Cuenca-Api-Version:
- '2020-03-19'
method: GET
uri: https://sandbox.cuenca.com/clabes
uri: https://sandbox.cuenca.com/clabes?allowed_curp_rfc=LOPJ900101XXX
response:
body:
string: '{"items":[{"id":"CLD_zg463BQ6-yEjg8UE0jgQ","clabe":"646180157089988558","created_at":"2022-08-23T05:14:11.862000","user_id":"USbDnHlZYDShGoTS2NTD-Lmg"},{"id":"CLas7ZqaT5Quq6fgeiuel6KA","clabe":"646180157030689013","created_at":"2022-08-23T05:11:53.700000","user_id":"USbDnHlZYDShGoTS2NTD-Lmg"},{"id":"CLu4OYMy1USXOY4tGfGNUUsw","clabe":"646180157073856528","created_at":"2022-08-22T23:54:55.634000","user_id":"USbDnHlZYDShGoTS2NTD-Lmg"},{"id":"CLQSvYrsu7Qqm3WuhG0OVrlg","clabe":"646180157032158283","created_at":"2022-08-22T22:44:00.966000","user_id":"USbDnHlZYDShGoTS2NTD-Lmg"},{"id":"CLFyudOfs9Rt-ratC4WXJAoA","clabe":"646180157027880605","created_at":"2022-08-22T22:41:06.071000","user_id":"USbDnHlZYDShGoTS2NTD-Lmg"}],"next_page_uri":null,"count":null}'
string: '{"items":[{"id":"723548437718857180","clabe":"723548437718857180","created_at":"2026-02-04T19:57:26.392000","updated_at":"2026-02-04T19:57:26.392000","deactivated_at":null,"provider":"cuenca","user_id":"USmI9NnHJXTKi9ILP1aaWjlQ","allowed_curp_rfc":"LOPJ900101XXX","is_default":false}],"next_page_uri":null,"count":null}'
headers:
Connection:
- keep-alive
Content-Length:
- '1049'
- '319'
Content-Type:
- application/json
Date:
- Tue, 23 Aug 2022 05:23:36 GMT
- Tue, 15 Sep 2026 18:24:23 GMT
X-Request-Time:
- 'value: 0.070'
- 'value: 1.314'
x-amz-apigw-id:
- XTSd5EarIAMF42A=
- DwMFlEmHCYcEXIw=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '1049'
- '319'
x-amzn-Remapped-Date:
- Tue, 23 Aug 2022 05:23:36 GMT
- Tue, 15 Sep 2026 18:24:23 GMT
x-amzn-Remapped-Server:
- nginx/1.22.0
- nginx/1.30.4
x-amzn-RequestId:
- 21c1a41f-857a-4d6f-8ceb-944b4dfa5ffc
- 37828c23-0ec9-4f12-8db0-08f5778509f8
status:
code: 200
message: OK
Expand Down
30 changes: 12 additions & 18 deletions tests/resources/cassettes/test_clabe_create.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
interactions:
- request:
body: '{}'
body: '{"legal_person_id": "USmI9NnHJXTKi9ILP1aaWjlQ", "allowed_curp_rfc": "LOPJ900101XXX"}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- DUMMY
Connection:
- keep-alive
Content-Length:
- '2'
- '84'
Content-Type:
- application/json
User-Agent:
- cuenca-python/0.13.10.dev102
- cuenca-python/2.2.5
X-Cuenca-Api-Version:
- '2020-03-19'
method: POST
uri: https://sandbox.cuenca.com/clabes
response:
body:
string: '{"id":"CLD_zg463BQ6-yEjg8UE0jgQ","clabe":"646180157089988558","user_id":"USbDnHlZYDShGoTS2NTD-Lmg","created_at":"2022-08-23T05:14:11.862507"}'
string: '{"id":"723548437718857180","clabe":"723548437718857180","created_at":"2026-02-04T19:57:26.392000","updated_at":"2026-02-04T19:57:26.392000","deactivated_at":null,"provider":"cuenca","user_id":"USmI9NnHJXTKi9ILP1aaWjlQ","allowed_curp_rfc":"LOPJ900101XXX","is_default":false}'
headers:
Connection:
- keep-alive
Content-Length:
- '141'
- '273'
Content-Type:
- application/json
Date:
- Tue, 23 Aug 2022 05:14:11 GMT
- Tue, 15 Sep 2026 18:22:53 GMT
X-Request-Time:
- 'value: 0.200'
- 'value: 1.083'
x-amz-apigw-id:
- XTRFmFanoAMFeOA=
- DwL3dEeViYcENnA=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '141'
- '273'
x-amzn-Remapped-Date:
- Tue, 23 Aug 2022 05:14:11 GMT
- Tue, 15 Sep 2026 18:22:53 GMT
x-amzn-Remapped-Server:
- nginx/1.22.0
- nginx/1.30.4
x-amzn-RequestId:
- 8dce4dbf-eea9-4179-848c-74af94b67c99
- c215a783-4895-4b9f-a1d5-315514a819cc
status:
code: 201
message: Created
Expand Down
48 changes: 0 additions & 48 deletions tests/resources/cassettes/test_clabe_retrieve.yaml

This file was deleted.

22 changes: 10 additions & 12 deletions tests/resources/test_clabes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@

from cuenca import Clabe

LEGAL_PERSON_ID = 'USmI9NnHJXTKi9ILP1aaWjlQ'
ALLOWED_CURP_RFC = 'LOPJ900101XXX'


@pytest.mark.vcr
def test_clabe_create():
clabe = Clabe.create()
assert clabe
clabe = Clabe.create(LEGAL_PERSON_ID, ALLOWED_CURP_RFC)
assert clabe.id
assert clabe.clabe


@pytest.mark.vcr
def test_clabe_retrieve():
clabe_id = 'CLD_zg463BQ6-yEjg8UE0jgQ'
clabe = Clabe.retrieve(clabe_id)
assert clabe
assert clabe.id == clabe_id
assert clabe.clabe
assert clabe.user_id == LEGAL_PERSON_ID
assert clabe.allowed_curp_rfc == ALLOWED_CURP_RFC
assert clabe.is_default is False


@pytest.mark.vcr
def test_clabe_all():
clabes = list(Clabe.all())
clabes = list(Clabe.all(allowed_curp_rfc=ALLOWED_CURP_RFC))
assert clabes
assert clabes[0].allowed_curp_rfc == ALLOWED_CURP_RFC
assert clabes[0].is_default is False
Loading