@@ -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 )
0 commit comments