netsware-sdk 1.0.0__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: netsware-sdk
3
- Version: 1.0.0
3
+ Version: 2.0.0
4
4
  Summary: Official Netsware SDK — Business Hours + Scheduled Jobs APIs
5
5
  Author: Netsware Systems LLP
6
6
  License: MIT
@@ -235,10 +235,45 @@ class _Webhooks:
235
235
  def __init__(self, http: _Http):
236
236
  self._http = http
237
237
 
238
+ # ── Endpoints (recommended): one URL subscribes to many events ──────────
239
+
240
+ def register_endpoint(self, url: str, events: list) -> dict:
241
+ """Register an endpoint (one URL) for many events. ``events`` is a list of
242
+ ``{"product": ..., "event": ...}`` dicts. The response includes a signing
243
+ ``secret``, shown once."""
244
+ return self._http.request("POST", "/v1/webhooks/endpoints",
245
+ body={"url": url, "events": events})
246
+
247
+ def list_endpoints(self) -> dict:
248
+ return self._http.request("GET", "/v1/webhooks/endpoints")
249
+
250
+ def update_endpoint(self, endpoint_id: str, *, url: str = None,
251
+ is_active: bool = None, events: list = None) -> dict:
252
+ """Edit an endpoint in place. The URL and signing secret are preserved;
253
+ ``events`` (when given) fully replaces the endpoint's event set."""
254
+ body = {}
255
+ if url is not None:
256
+ body["url"] = url
257
+ if is_active is not None:
258
+ body["is_active"] = is_active
259
+ if events is not None:
260
+ body["events"] = events
261
+ return self._http.request("PATCH", f"/v1/webhooks/endpoints/{endpoint_id}", body=body)
262
+
263
+ def delete_endpoint(self, endpoint_id: str) -> dict:
264
+ return self._http.request("DELETE", f"/v1/webhooks/endpoints/{endpoint_id}")
265
+
266
+ def test_endpoint(self, endpoint_id: str) -> dict:
267
+ return self._http.request("POST", f"/v1/webhooks/endpoints/{endpoint_id}/test")
268
+
269
+ def endpoint_deliveries(self, endpoint_id: str) -> dict:
270
+ return self._http.request("GET", f"/v1/webhooks/endpoints/{endpoint_id}/deliveries")
271
+
272
+ # ── Single-event (legacy): kept for back-compat; prefer endpoints ───────
273
+
238
274
  def register(self, product: str, event: str, url: str) -> dict:
239
- """Register a webhook. ``product`` = ``scheduled_jobs``|``business_hours``;
240
- ``event`` is a single event name (register again for more). The response
241
- includes a signing ``secret``, shown once."""
275
+ """Deprecated: prefer ``register_endpoint``. Register a single-event webhook.
276
+ The response includes a signing ``secret``, shown once."""
242
277
  return self._http.request("POST", "/v1/webhooks",
243
278
  body={"product": product, "event": event, "url": url})
244
279
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: netsware-sdk
3
- Version: 1.0.0
3
+ Version: 2.0.0
4
4
  Summary: Official Netsware SDK — Business Hours + Scheduled Jobs APIs
5
5
  Author: Netsware Systems LLP
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "netsware-sdk"
7
- version = "1.0.0"
7
+ version = "2.0.0"
8
8
  description = "Official Netsware SDK — Business Hours + Scheduled Jobs APIs"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
File without changes
File without changes