Skip to content

Commit 9cef15f

Browse files
committed
Add service events route scaffold
1 parent 4d498b4 commit 9cef15f

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from fastapi import APIRouter
2+
from pydantic import BaseModel, Field
3+
from typing import Dict, Optional
4+
from uuid import uuid4
5+
6+
router = APIRouter(prefix="/api/service-events", tags=["service-events"])
7+
8+
9+
class ServiceEventRequest(BaseModel):
10+
event_type: str = Field(..., description="billing.event, service.activated, service.completed, etc.")
11+
product_code: str
12+
customer_reference: str
13+
service_receipt_id: Optional[str] = None
14+
metadata: Dict = Field(default_factory=dict)
15+
16+
17+
class ServiceEventResponse(BaseModel):
18+
event_id: str
19+
status: str
20+
service_receipt_id: Optional[str] = None
21+
22+
23+
@router.post("/publish", response_model=ServiceEventResponse)
24+
def publish_service_event(request: ServiceEventRequest) -> ServiceEventResponse:
25+
event_id = f"evt_{uuid4().hex}"
26+
return ServiceEventResponse(
27+
event_id=event_id,
28+
status="accepted",
29+
service_receipt_id=request.service_receipt_id,
30+
)

0 commit comments

Comments
 (0)