"""/api/stripe-activity — the Stripe "All Activity" paste -> Wave CSV tool.

Thin HTTP layer: the parse, the fee split and the permission gate all live in
services/stripe_activity.py (04-architecture). STATELESS by design — the
transform is deterministic, so there is nothing worth persisting; re-pasting
reproduces the same CSV exactly.
"""

from __future__ import annotations

from fastapi import APIRouter
from pydantic import BaseModel

from app.routers.deps import ActorDep, ApiError
from app.services import stripe_activity as svc
from app.services.errors import ServiceError

router = APIRouter()


class ActivityPaste(BaseModel):
    paste: str = ""


@router.post("/api/stripe-activity/parse")
def parse_paste(actor: ActorDep, body: ActivityPaste) -> dict:
    try:
        return svc.build_export(actor, body.paste)
    except ServiceError as exc:
        raise ApiError(exc.status, exc.code, exc.summary, exc.detail) from exc
