Skip to content

Commit 55236ed

Browse files
committed
Adding docs
1 parent 9b35427 commit 55236ed

File tree

3 files changed

+41
-21
lines changed

3 files changed

+41
-21
lines changed

cuenca/resources/endpoints.py

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,40 @@ class Endpoint(Creatable, Deactivable, Retrievable, Queryable, Updateable):
1919
is_enable: bool
2020
events: List[WebhookEvent]
2121

22+
class Config:
23+
fields = {
24+
'url': {'description': 'HTTPS url to send webhooks'},
25+
'secret': {
26+
'description': 'token to verify the webhook is sent by Cuenca'
27+
},
28+
'is_enable': {
29+
'description': 'Allows user to turn-off the endpoint '
30+
'without the need of deleting it'
31+
},
32+
'events': {
33+
'description': 'list of enabled events. If None, '
34+
'all events will be enabled for this Endpoint'
35+
},
36+
}
37+
schema_extra = {
38+
'example': {
39+
"_id": "ENxxne2Z5VSTKZm_w8Hzffcw",
40+
"platform_id": "PTZoPrrPT6Ts-9myamq5h1bA",
41+
"created_at": {"$date": {"$numberLong": "1645752962234"}},
42+
"updated_at": {"$date": {"$numberLong": "1645752962234"}},
43+
"secret": "1234",
44+
"url": "https://webhook.site/714ed1d8",
45+
"events": [
46+
"transaction.create",
47+
"transaction.update",
48+
"user.create",
49+
"user.update",
50+
"user.delete",
51+
],
52+
"is_enable": True,
53+
}
54+
}
55+
2256
@classmethod
2357
def create(
2458
cls,
@@ -27,16 +61,6 @@ def create(
2761
*,
2862
session: Session = global_session,
2963
) -> 'Endpoint':
30-
"""
31-
Creates and Endpoint, allowing to recieve Webhooks with the specified
32-
events.
33-
34-
:param url: HTTPS url to send webhooks
35-
:param events: list of enabled events. If None, all events will be
36-
enabled for this Endpoint
37-
:param session:
38-
:return: New active endpoint
39-
"""
4064
req = EndpointRequest(url=url, events=events)
4165
return cast('Endpoint', cls._create(session=session, **req.dict()))
4266

@@ -49,16 +73,6 @@ def update(
4973
*,
5074
session: Session = global_session,
5175
) -> 'Endpoint':
52-
"""
53-
Updates endpoint properties. It allows reconfigure properties
54-
like url and is_active.
55-
56-
:param endpoint_id: existing endpoint_id
57-
:param url
58-
:param is_enable
59-
:param session
60-
:return: Updated endpoint object
61-
"""
6276
req = EndpointUpdateRequest(url=url, is_enable=is_enable)
6377
resp = cls._update(endpoint_id, session=session, **req.dict())
6478
return cast('Endpoint', resp)

cuenca/resources/webhooks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ class Webhook(Retrievable, Queryable):
1010

1111
payload: Dict[str, Any]
1212
event: WebhookEvent
13+
14+
class Config:
15+
fields = {
16+
'payload': {'description': 'object sent by the webhook'},
17+
'event': {'description': 'type of event being reported'},
18+
}

cuenca/version.py

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

0 commit comments

Comments
 (0)