From a0fab1f6de2ff4df6f9a273bf737a074a5dc1c09 Mon Sep 17 00:00:00 2001 From: Chaim Date: Sat, 16 May 2026 17:06:37 +0000 Subject: [PATCH] feat: add emit_case_status_webhook helper --- web/paperclip_api.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/web/paperclip_api.py b/web/paperclip_api.py index e14cb56..a16e03f 100644 --- a/web/paperclip_api.py +++ b/web/paperclip_api.py @@ -19,6 +19,7 @@ from __future__ import annotations import logging import os +from datetime import datetime from typing import Any import httpx @@ -81,3 +82,32 @@ async def pc_request( if raise_on_error: resp.raise_for_status() return resp + + +async def emit_case_status_webhook( + case_number: str, + old_status: str, + new_status: str, + company_id: str | None = None, + run_id: str | None = None, +) -> None: + """Notify the Paperclip plugin that a case status changed. + + Fire-and-forget: logs errors but never raises, so callers aren't blocked. + """ + try: + await pc_request( + "POST", + "/api/plugins/marcusgroup.legal-ai/webhooks/case-status", + json={ + "caseNumber": case_number, + "oldStatus": old_status, + "newStatus": new_status, + "companyId": company_id, + "timestamp": datetime.utcnow().isoformat() + "Z", + }, + run_id=run_id, + timeout=5.0, + ) + except Exception as exc: + logger.warning("emit_case_status_webhook failed: %s", exc)