Skip to content

Commit

Permalink
Events in endpoints update (#312)
Browse files Browse the repository at this point in the history
* adding events to endpoints update

* version

* tests
  • Loading branch information
chiqeen03 authored Sep 14, 2022
1 parent 0b43e88 commit f43555a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
5 changes: 4 additions & 1 deletion cuenca/resources/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def update(
cls,
endpoint_id: str,
url: Optional[HttpUrl] = None,
events: Optional[List[WebhookEvent]] = None,
is_enable: Optional[bool] = None,
*,
session: Session = global_session,
Expand All @@ -92,6 +93,8 @@ def update(
:param session
:return: Updated endpoint object
"""
req = EndpointUpdateRequest(url=url, is_enable=is_enable)
req = EndpointUpdateRequest(
url=url, is_enable=is_enable, events=events
)
resp = cls._update(endpoint_id, session=session, **req.dict())
return cast('Endpoint', resp)
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.14.2'
__version__ = '0.14.3'
CLIENT_VERSION = __version__
API_VERSION = '2020-03-19'
27 changes: 15 additions & 12 deletions tests/resources/cassettes/test_endpoint_update.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
interactions:
- request:
body: '{"url": "https://url.io", "is_active": false}'
body: '{"url": "https://url.io", "is_enable": false, "events": ["user.create",
"cash_deposit.create"]}'
headers:
Accept:
- '*/*'
Expand All @@ -11,41 +12,43 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '45'
- '95'
Content-Type:
- application/json
User-Agent:
- cuenca-python/0.7.13
- cuenca-python/0.14.3
X-Cuenca-Api-Version:
- '2020-03-19'
X-Cuenca-LoginId:
- ULev1mLmNST6ie3wcket7c-w
method: PATCH
uri: https://sandbox.cuenca.com/endpoints/EN02
response:
body:
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"]}'
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}'
headers:
Connection:
- keep-alive
Content-Length:
- '303'
- '262'
Content-Type:
- application/json
Date:
- Wed, 09 Feb 2022 19:12:09 GMT
- Wed, 14 Sep 2022 21:22:00 GMT
X-Request-Time:
- 'value: 0.144'
- 'value: 0.168'
x-amz-apigw-id:
- NSfBbFICiYcFzfA=
- Yd_exHKQIAMF6kA=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '303'
- '262'
x-amzn-Remapped-Date:
- Wed, 09 Feb 2022 19:12:09 GMT
- Wed, 14 Sep 2022 21:22:00 GMT
x-amzn-Remapped-Server:
- nginx/1.20.2
- nginx/1.22.0
x-amzn-RequestId:
- f6ec4a97-3e7b-44c4-b632-ee24feef8976
- 6f27c80d-6e86-43ac-8d31-ed02cc64bd01
status:
code: 200
message: OK
Expand Down
7 changes: 5 additions & 2 deletions tests/resources/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ def test_endpoint_create_another():
def test_endpoint_update():
id_endpoint = 'EN02'
endpoint: Endpoint = Endpoint.update(
endpoint_id=id_endpoint, url='https://url.io', is_enable=False
endpoint_id=id_endpoint,
url='https://url.io',
is_enable=False,
events=['user.create', 'cash_deposit.create'],
)
assert endpoint.id == id_endpoint
assert endpoint.events
assert len(endpoint.events) == 2
assert endpoint.url == 'https://url.io'
assert not endpoint.is_enable
assert endpoint.is_active
Expand Down

0 comments on commit f43555a

Please sign in to comment.