Skip to content

Commit

Permalink
update urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev-Khant committed Feb 21, 2025
1 parent 9966f22 commit 5b9e45d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/api-reference/webhook/create-webhook.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 'Create Webhook'
openapi: post /api/v1/webhooks/get_or_create/{project_id}/
openapi: post /api/v1/webhooks/projects/{project_id}/
---

## Create Webhook
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/webhook/delete-webhook.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 'Delete Webhook'
openapi: delete /api/v1/webhooks/update_or_delete/{webhook_id}/
openapi: delete /api/v1/webhooks/{webhook_id}/
---

## Delete Webhook
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/webhook/get-webhook.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 'Get Webhook'
openapi: get /api/v1/webhooks/get_or_create/{project_id}/
openapi: get /api/v1/webhooks/projects/{project_id}/
---

## Get Webhook
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/webhook/update-webhook.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 'Update Webhook'
openapi: put /api/v1/webhooks/update_or_delete/{webhook_id}/
openapi: put /api/v1/webhooks/{webhook_id}/
---

## Update Webhook
Expand Down
4 changes: 2 additions & 2 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4141,7 +4141,7 @@
]
}
},
"/api/v1/webhooks/get_or_create/{project_id}/": {
"/api/v1/webhooks/projects/{project_id}/": {
"get": {
"tags": ["webhooks"],
"summary": "Get Project Webhooks",
Expand Down Expand Up @@ -4410,7 +4410,7 @@
]
}
},
"/api/v1/webhooks/update_or_delete/{webhook_id}/": {
"/api/v1/webhooks/{webhook_id}/": {
"put": {
"tags": ["webhooks"],
"summary": "Update Webhook",
Expand Down
34 changes: 18 additions & 16 deletions mem0/client/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def get_webhooks(self, project_id: str) -> Dict[str, Any]:
ValueError: If project_id is not set.
"""

response = self.client.get(f"api/v1/webhooks/get_or_create/{project_id}/")
response = self.client.get(f"api/v1/webhooks/projects/{project_id}/")
response.raise_for_status()
capture_client_event("client.get_webhook", self)
return response.json()
Expand All @@ -562,14 +562,18 @@ def create_webhook(self, url: str, name: str, project_id: str, event_types: List
"""

payload = {"url": url, "name": name, "event_types": event_types}
response = self.client.post(f"api/v1/webhooks/get_or_create/{project_id}/", json=payload)
response = self.client.post(f"api/v1/webhooks/projects/{project_id}/", json=payload)
response.raise_for_status()
capture_client_event("client.create_webhook", self)
return response.json()

@api_error_handler
def update_webhook(
self, webhook_id: int, name: Optional[str] = None, url: Optional[str] = None, event_types: Optional[List[str]] = None
self,
webhook_id: int,
name: Optional[str] = None,
url: Optional[str] = None,
event_types: Optional[List[str]] = None,
) -> Dict[str, Any]:
"""Update a webhook configuration.
Expand All @@ -587,7 +591,7 @@ def update_webhook(
"""

payload = {k: v for k, v in {"name": name, "url": url, "event_types": event_types}.items() if v is not None}
response = self.client.put(f"api/v1/webhooks/update_or_delete/{webhook_id}/", json=payload)
response = self.client.put(f"api/v1/webhooks/{webhook_id}/", json=payload)
response.raise_for_status()
capture_client_event("client.update_webhook", self, {"webhook_id": webhook_id})
return response.json()
Expand All @@ -606,7 +610,7 @@ def delete_webhook(self, webhook_id: int) -> Dict[str, str]:
APIError: If the API request fails.
"""

response = self.client.delete(f"api/v1/webhooks/update_or_delete/{webhook_id}/")
response = self.client.delete(f"api/v1/webhooks/{webhook_id}/")
response.raise_for_status()
capture_client_event("client.delete_webhook", self, {"webhook_id": webhook_id})
return response.json()
Expand Down Expand Up @@ -957,40 +961,38 @@ async def chat(self):

@api_error_handler
async def get_webhooks(self, project_id: str) -> Dict[str, Any]:

response = await self.async_client.get(
f"api/v1/webhooks/{project_id}/webhook/",
f"api/v1/webhooks/projects/{project_id}/",
)
response.raise_for_status()
capture_client_event("async_client.get_webhook", self.sync_client)
return response.json()

@api_error_handler
async def create_webhook(self, url: str, name: str, project_id: str, event_types: List[str]) -> Dict[str, Any]:

payload = {"url": url, "name": name, "event_types": event_types}
response = await self.async_client.post(
f"api/v1/webhooks/{project_id}/webhook/", json=payload
)
response = await self.async_client.post(f"api/v1/webhooks/projects/{project_id}/", json=payload)
response.raise_for_status()
capture_client_event("async_client.create_webhook", self.sync_client)
return response.json()

@api_error_handler
async def update_webhook(
self, webhook_id: int, name: Optional[str] = None, url: Optional[str] = None, event_types: Optional[List[str]] = None
self,
webhook_id: int,
name: Optional[str] = None,
url: Optional[str] = None,
event_types: Optional[List[str]] = None,
) -> Dict[str, Any]:

payload = {k: v for k, v in {"name": name, "url": url, "event_types": event_types}.items() if v is not None}
response = await self.async_client.put(f"api/v1/webhooks/{webhook_id}/webhook/", json=payload)
response = await self.async_client.put(f"api/v1/webhooks/{webhook_id}/", json=payload)
response.raise_for_status()
capture_client_event("async_client.update_webhook", self.sync_client, {"webhook_id": webhook_id})
return response.json()

@api_error_handler
async def delete_webhook(self, webhook_id: int) -> Dict[str, str]:

response = await self.async_client.delete(f"api/v1/webhooks/{webhook_id}/webhook/")
response = await self.async_client.delete(f"api/v1/webhooks/{webhook_id}/")
response.raise_for_status()
capture_client_event("async_client.delete_webhook", self.sync_client, {"webhook_id": webhook_id})
return response.json()

0 comments on commit 5b9e45d

Please sign in to comment.