Skip to content

Commit 896458c

Browse files
author
Keryc Diaz
authored
filter for accounts (#133)
* filter for accounts * test account * real transfer and tests * fix end * fix of format * rebase and new version
1 parent d363c4e commit 896458c

File tree

6 files changed

+191
-2
lines changed

6 files changed

+191
-2
lines changed

cuenca/resources/accounts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import ClassVar
22

3+
from cuenca_validations.types import AccountQuery
34
from pydantic.dataclasses import dataclass
45

56
from .base import Queryable, Retrievable
@@ -8,6 +9,7 @@
89
@dataclass
910
class Account(Retrievable, Queryable):
1011
_resource: ClassVar = 'accounts'
12+
_query_params: ClassVar = AccountQuery
1113

1214
name: str # legal name provided by institution
1315
account_number: str

cuenca/resources/transfers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Transfer(Transaction, Creatable):
3030
tracking_key: Optional[str] # clave rastreo if network is SPEI
3131

3232
@property # type: ignore
33-
def destination(self) -> Optional[Account]:
33+
def destination(self) -> Account:
3434
return cast(Account, retrieve_uri(self.destination_uri))
3535

3636
@classmethod

cuenca/version.py

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

tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@ def vcr_config():
1313
('X-Cuenca-Token', 'DUMMY'),
1414
]
1515
return config
16+
17+
18+
@pytest.fixture
19+
def transfer():
20+
yield cuenca.Transfer.create(
21+
account_number='646180157034181180',
22+
amount=10000,
23+
descriptor='first transfer',
24+
recipient_name='Frida Kahlo',
25+
)
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
interactions:
2+
- request:
3+
body: '{"recipient_name": "Frida Kahlo", "account_number": "646180157034181180",
4+
"amount": 10000, "descriptor": "first transfer", "idempotency_key": "2021-03-20:646180157034181180:10000"}'
5+
headers:
6+
Accept:
7+
- '*/*'
8+
Accept-Encoding:
9+
- gzip, deflate
10+
Authorization:
11+
- DUMMY
12+
Connection:
13+
- keep-alive
14+
Content-Length:
15+
- '180'
16+
Content-Type:
17+
- application/json
18+
User-Agent:
19+
- cuenca-python/0.7.1
20+
X-Cuenca-Api-Version:
21+
- '2020-03-19'
22+
X-Cuenca-LoginToken:
23+
- LTHFBUsQ--SRKYo09VXLuToQ
24+
method: POST
25+
uri: https://sandbox.cuenca.com/transfers
26+
response:
27+
body:
28+
string: '{"id":"TRqRHzmSg-S9OubPMyNbvO-A","created_at":"2021-03-20T00:03:00.747892","updated_at":"2021-03-20T00:03:01.539938","account_number":"646180157034181180","recipient_name":"Frida
29+
Kahlo","amount":10000,"descriptor":"first transfer","idempotency_key":"2021-03-20:646180157034181180:10000","status":"submitted","network":"internal","destination_uri":"/accounts/AC3sgb4ZIqUzCACOPNcL2QVw","tracking_key":null,"user_id":"US4PCNV8rLB2wqBfORzIAXUl","reference_number":null}'
30+
headers:
31+
Connection:
32+
- keep-alive
33+
Content-Length:
34+
- '465'
35+
Content-Type:
36+
- application/json
37+
Date:
38+
- Sat, 20 Mar 2021 00:03:01 GMT
39+
X-Amzn-Trace-Id:
40+
- Root=1-60553bb0-186e486a154c57f6624f2558;Sampled=0
41+
X-Request-Time:
42+
- 'value: 4.980'
43+
x-amz-apigw-id:
44+
- cdZDnFitCYcFs_w=
45+
x-amzn-Remapped-Connection:
46+
- keep-alive
47+
x-amzn-Remapped-Content-Length:
48+
- '465'
49+
x-amzn-Remapped-Date:
50+
- Sat, 20 Mar 2021 00:03:01 GMT
51+
x-amzn-Remapped-Server:
52+
- nginx/1.18.0
53+
x-amzn-Remapped-x-amzn-RequestId:
54+
- fe639ac8-6d4c-46c4-ab0c-8dfc83acbe6f
55+
x-amzn-RequestId:
56+
- 9ee0d853-f6c2-493f-a5c1-ce5557dfa683
57+
status:
58+
code: 201
59+
message: Created
60+
- request:
61+
body: null
62+
headers:
63+
Accept:
64+
- '*/*'
65+
Accept-Encoding:
66+
- gzip, deflate
67+
Authorization:
68+
- DUMMY
69+
Connection:
70+
- keep-alive
71+
User-Agent:
72+
- cuenca-python/0.7.1
73+
X-Cuenca-Api-Version:
74+
- '2020-03-19'
75+
X-Cuenca-LoginToken:
76+
- LTHFBUsQ--SRKYo09VXLuToQ
77+
method: GET
78+
uri: https://sandbox.cuenca.com/accounts?limit=2&account_number=646180157034181180
79+
response:
80+
body:
81+
string: '{"items":[{"id":"AC3sgb4ZIqUzCACOPNcL2QVw","created_at":"2021-03-20T00:03:01.072000","name":"Frida
82+
Kahlo","account_number":"646180157034181180","user_id":"US4PCNV8rLB2wqBfORzIAXUl","institution_name":"Cuenca"}],"next_page_uri":null}'
83+
headers:
84+
Connection:
85+
- keep-alive
86+
Content-Length:
87+
- '232'
88+
Content-Type:
89+
- application/json
90+
Date:
91+
- Sat, 20 Mar 2021 00:03:02 GMT
92+
X-Amzn-Trace-Id:
93+
- Root=1-60553bb5-393799840ea3e46a75052790;Sampled=0
94+
X-Request-Time:
95+
- 'value: 0.283'
96+
x-amz-apigw-id:
97+
- cdZEaGpjiYcFWbg=
98+
x-amzn-Remapped-Connection:
99+
- keep-alive
100+
x-amzn-Remapped-Content-Length:
101+
- '232'
102+
x-amzn-Remapped-Date:
103+
- Sat, 20 Mar 2021 00:03:02 GMT
104+
x-amzn-Remapped-Server:
105+
- nginx/1.18.0
106+
x-amzn-Remapped-x-amzn-RequestId:
107+
- 28c580ed-57e3-4f3f-ae1b-fcacc39c8318
108+
x-amzn-RequestId:
109+
- 29fab010-c42c-442c-8eea-2dad8021df7a
110+
status:
111+
code: 200
112+
message: OK
113+
- request:
114+
body: null
115+
headers:
116+
Accept:
117+
- '*/*'
118+
Accept-Encoding:
119+
- gzip, deflate
120+
Authorization:
121+
- DUMMY
122+
Connection:
123+
- keep-alive
124+
User-Agent:
125+
- cuenca-python/0.7.1
126+
X-Cuenca-Api-Version:
127+
- '2020-03-19'
128+
X-Cuenca-LoginToken:
129+
- LTHFBUsQ--SRKYo09VXLuToQ
130+
method: GET
131+
uri: https://sandbox.cuenca.com/accounts/AC3sgb4ZIqUzCACOPNcL2QVw
132+
response:
133+
body:
134+
string: '{"id":"AC3sgb4ZIqUzCACOPNcL2QVw","created_at":"2021-03-20T00:03:01.072000","name":"Frida
135+
Kahlo","account_number":"646180157034181180","user_id":"US4PCNV8rLB2wqBfORzIAXUl","institution_name":"Cuenca"}'
136+
headers:
137+
Connection:
138+
- keep-alive
139+
Content-Length:
140+
- '199'
141+
Content-Type:
142+
- application/json
143+
Date:
144+
- Sat, 20 Mar 2021 00:03:02 GMT
145+
X-Amzn-Trace-Id:
146+
- Root=1-60553bb6-048a62c56bf1b26422be9d01;Sampled=0
147+
X-Request-Time:
148+
- 'value: 0.231'
149+
x-amz-apigw-id:
150+
- cdZEfFUFCYcFtxg=
151+
x-amzn-Remapped-Connection:
152+
- keep-alive
153+
x-amzn-Remapped-Content-Length:
154+
- '199'
155+
x-amzn-Remapped-Date:
156+
- Sat, 20 Mar 2021 00:03:02 GMT
157+
x-amzn-Remapped-Server:
158+
- nginx/1.18.0
159+
x-amzn-Remapped-x-amzn-RequestId:
160+
- fd2fea56-93b3-431c-a187-8452be8c8405
161+
x-amzn-RequestId:
162+
- f08819df-0115-4171-95cf-f057bcf0b1f5
163+
status:
164+
code: 200
165+
message: OK
166+
version: 1

tests/resources/test_accounts.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
from cuenca import Account
4+
5+
6+
@pytest.mark.vcr
7+
def test_query_account(transfer):
8+
account: Account = Account.one(account_number=transfer.account_number)
9+
destination = transfer.destination
10+
assert account.id == destination.id
11+
assert account.account_number == destination.account_number

0 commit comments

Comments
 (0)