Skip to content

Commit

Permalink
Adding docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chiqeen03 committed Jun 28, 2022
1 parent 9b35427 commit 55236ed
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
54 changes: 34 additions & 20 deletions cuenca/resources/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()))

Expand All @@ -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)
6 changes: 6 additions & 0 deletions cuenca/resources/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
}
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.13.2'
__version__ = '0.13.6.dev0'
CLIENT_VERSION = __version__
API_VERSION = '2020-03-19'

0 comments on commit 55236ed

Please sign in to comment.