diff --git a/cuenca/resources/endpoints.py b/cuenca/resources/endpoints.py index fc138ff6..70942e18 100644 --- a/cuenca/resources/endpoints.py +++ b/cuenca/resources/endpoints.py @@ -19,6 +19,40 @@ class Endpoint(Creatable, Deactivable, Retrievable, Queryable, Updateable): is_enable: bool events: List[WebhookEvent] + class Config: + fields = { + 'url': {'description': 'HTTPS url to send webhooks'}, + 'secret': { + 'description': 'token to verify the webhook is sent by Cuenca' + }, + 'is_enable': { + 'description': 'Allows user to turn-off the endpoint ' + 'without the need of deleting it' + }, + 'events': { + 'description': 'list of enabled events. If None, ' + 'all events will be enabled for this Endpoint' + }, + } + schema_extra = { + 'example': { + "_id": "ENxxne2Z5VSTKZm_w8Hzffcw", + "platform_id": "PTZoPrrPT6Ts-9myamq5h1bA", + "created_at": {"$date": {"$numberLong": "1645752962234"}}, + "updated_at": {"$date": {"$numberLong": "1645752962234"}}, + "secret": "1234", + "url": "https://webhook.site/714ed1d8", + "events": [ + "transaction.create", + "transaction.update", + "user.create", + "user.update", + "user.delete", + ], + "is_enable": True, + } + } + @classmethod def create( cls, @@ -27,16 +61,6 @@ def create( *, session: Session = global_session, ) -> 'Endpoint': - """ - Creates and Endpoint, allowing to recieve Webhooks with the specified - events. - - :param url: HTTPS url to send webhooks - :param events: list of enabled events. If None, all events will be - enabled for this Endpoint - :param session: - :return: New active endpoint - """ req = EndpointRequest(url=url, events=events) return cast('Endpoint', cls._create(session=session, **req.dict())) @@ -49,16 +73,6 @@ def update( *, session: Session = global_session, ) -> 'Endpoint': - """ - Updates endpoint properties. It allows reconfigure properties - like url and is_active. - - :param endpoint_id: existing endpoint_id - :param url - :param is_enable - :param session - :return: Updated endpoint object - """ req = EndpointUpdateRequest(url=url, is_enable=is_enable) resp = cls._update(endpoint_id, session=session, **req.dict()) return cast('Endpoint', resp) diff --git a/cuenca/resources/webhooks.py b/cuenca/resources/webhooks.py index 64a7a1a0..257e8b68 100644 --- a/cuenca/resources/webhooks.py +++ b/cuenca/resources/webhooks.py @@ -10,3 +10,9 @@ class Webhook(Retrievable, Queryable): payload: Dict[str, Any] event: WebhookEvent + + class Config: + fields = { + 'payload': {'description': 'object sent by the webhook'}, + 'event': {'description': 'type of event being reported'}, + } diff --git a/cuenca/version.py b/cuenca/version.py index c7e73560..bd89a011 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '0.13.2' +__version__ = '0.13.6.dev0' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19'