Skip to content

Commit f43555a

Browse files
authored
Events in endpoints update (#312)
* adding events to endpoints update * version * tests
1 parent 0b43e88 commit f43555a

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

cuenca/resources/endpoints.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def update(
7979
cls,
8080
endpoint_id: str,
8181
url: Optional[HttpUrl] = None,
82+
events: Optional[List[WebhookEvent]] = None,
8283
is_enable: Optional[bool] = None,
8384
*,
8485
session: Session = global_session,
@@ -92,6 +93,8 @@ def update(
9293
:param session
9394
:return: Updated endpoint object
9495
"""
95-
req = EndpointUpdateRequest(url=url, is_enable=is_enable)
96+
req = EndpointUpdateRequest(
97+
url=url, is_enable=is_enable, events=events
98+
)
9699
resp = cls._update(endpoint_id, session=session, **req.dict())
97100
return cast('Endpoint', resp)

cuenca/version.py

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

tests/resources/cassettes/test_endpoint_update.yaml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
interactions:
22
- request:
3-
body: '{"url": "https://url.io", "is_active": false}'
3+
body: '{"url": "https://url.io", "is_enable": false, "events": ["user.create",
4+
"cash_deposit.create"]}'
45
headers:
56
Accept:
67
- '*/*'
@@ -11,41 +12,43 @@ interactions:
1112
Connection:
1213
- keep-alive
1314
Content-Length:
14-
- '45'
15+
- '95'
1516
Content-Type:
1617
- application/json
1718
User-Agent:
18-
- cuenca-python/0.7.13
19+
- cuenca-python/0.14.3
1920
X-Cuenca-Api-Version:
2021
- '2020-03-19'
22+
X-Cuenca-LoginId:
23+
- ULev1mLmNST6ie3wcket7c-w
2124
method: PATCH
2225
uri: https://sandbox.cuenca.com/endpoints/EN02
2326
response:
2427
body:
25-
string: '{"id":"EN02","created_at":"2022-02-09T19:06:44.109000","updated_at":"2022-02-09T19:06:44.109000","deactivated_at":null,"secret":"********","is_enable":false,"url":"https://url.io","events":["user.create","user.update","user.delete","transaction.create","transaction.update"]}'
28+
string: '{"id":"EN02","created_at":"2022-09-14T21:12:30.710000","updated_at":"2022-09-14T21:12:30.710000","deactivated_at":null,"secret":"********","is_enable":false,"url":"https://url.io","events":["user.create","cash_deposit.create"],"user_id":null}'
2629
headers:
2730
Connection:
2831
- keep-alive
2932
Content-Length:
30-
- '303'
33+
- '262'
3134
Content-Type:
3235
- application/json
3336
Date:
34-
- Wed, 09 Feb 2022 19:12:09 GMT
37+
- Wed, 14 Sep 2022 21:22:00 GMT
3538
X-Request-Time:
36-
- 'value: 0.144'
39+
- 'value: 0.168'
3740
x-amz-apigw-id:
38-
- NSfBbFICiYcFzfA=
41+
- Yd_exHKQIAMF6kA=
3942
x-amzn-Remapped-Connection:
4043
- keep-alive
4144
x-amzn-Remapped-Content-Length:
42-
- '303'
45+
- '262'
4346
x-amzn-Remapped-Date:
44-
- Wed, 09 Feb 2022 19:12:09 GMT
47+
- Wed, 14 Sep 2022 21:22:00 GMT
4548
x-amzn-Remapped-Server:
46-
- nginx/1.20.2
49+
- nginx/1.22.0
4750
x-amzn-RequestId:
48-
- f6ec4a97-3e7b-44c4-b632-ee24feef8976
51+
- 6f27c80d-6e86-43ac-8d31-ed02cc64bd01
4952
status:
5053
code: 200
5154
message: OK

tests/resources/test_endpoints.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ def test_endpoint_create_another():
3636
def test_endpoint_update():
3737
id_endpoint = 'EN02'
3838
endpoint: Endpoint = Endpoint.update(
39-
endpoint_id=id_endpoint, url='https://url.io', is_enable=False
39+
endpoint_id=id_endpoint,
40+
url='https://url.io',
41+
is_enable=False,
42+
events=['user.create', 'cash_deposit.create'],
4043
)
4144
assert endpoint.id == id_endpoint
42-
assert endpoint.events
45+
assert len(endpoint.events) == 2
4346
assert endpoint.url == 'https://url.io'
4447
assert not endpoint.is_enable
4548
assert endpoint.is_active

0 commit comments

Comments
 (0)