From f43555a444ce1ca034e3ce39364869c4a8106dfd Mon Sep 17 00:00:00 2001 From: Manuel Avalos Tovar Date: Wed, 14 Sep 2022 16:26:21 -0500 Subject: [PATCH] Events in endpoints update (#312) * adding events to endpoints update * version * tests --- cuenca/resources/endpoints.py | 5 +++- cuenca/version.py | 2 +- .../cassettes/test_endpoint_update.yaml | 27 ++++++++++--------- tests/resources/test_endpoints.py | 7 +++-- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/cuenca/resources/endpoints.py b/cuenca/resources/endpoints.py index 5f41e367..43fb79c9 100644 --- a/cuenca/resources/endpoints.py +++ b/cuenca/resources/endpoints.py @@ -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, @@ -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) diff --git a/cuenca/version.py b/cuenca/version.py index eef242d1..2ef6a9ef 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '0.14.2' +__version__ = '0.14.3' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' diff --git a/tests/resources/cassettes/test_endpoint_update.yaml b/tests/resources/cassettes/test_endpoint_update.yaml index 826f53bd..a5fd8a01 100644 --- a/tests/resources/cassettes/test_endpoint_update.yaml +++ b/tests/resources/cassettes/test_endpoint_update.yaml @@ -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: - '*/*' @@ -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 diff --git a/tests/resources/test_endpoints.py b/tests/resources/test_endpoints.py index 05ea19a8..4317b9ff 100644 --- a/tests/resources/test_endpoints.py +++ b/tests/resources/test_endpoints.py @@ -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