"""Investment-goal collection and goal-book review endpoints.""" from typing import Any from fastapi import APIRouter, Depends, Header, status from app.api.dependencies.auth import build_request_context from app.api.dependencies.rate_limit import enforce_rate_limit from app.api.schemas.investment_goals import ( InvestmentGoalBookPublish, InvestmentGoalBookReview, InvestmentGoalConfirmation, InvestmentGoalCreate, ) from app.core.contracts import RequestContext from app.service.advisor_rollout_service import enforce_advisor_rollout from app.service.investment_goal_service import InvestmentGoalService router = APIRouter( prefix="/api/v1/advisor", tags=["advisor-investment-goals"], dependencies=[Depends(enforce_rate_limit), Depends(enforce_advisor_rollout)], ) @router.post("/investment-goals", status_code=status.HTTP_201_CREATED) async def create_investment_goal( payload: InvestmentGoalCreate, context: RequestContext = Depends(build_request_context), # noqa: B008 key: str | None = Header(default=None, alias="Idempotency-Key"), ) -> dict[str, object]: return await InvestmentGoalService().create(payload, context, key) @router.get("/investment-goals/current") async def current_own_investment_goal( context: RequestContext = Depends(build_request_context), # noqa: B008 ) -> dict[str, object]: return await InvestmentGoalService().current(int(context.user_id), context) @router.get("/customers/{customer_id}/investment-goals/current") async def current_customer_investment_goal( customer_id: int, context: RequestContext = Depends(build_request_context), # noqa: B008 ) -> dict[str, object]: return await InvestmentGoalService().current(customer_id, context) @router.post("/investment-goals/{goal_no}/confirmations") async def confirm_investment_goal( goal_no: str, payload: InvestmentGoalConfirmation, context: RequestContext = Depends(build_request_context), # noqa: B008 key: str | None = Header(default=None, alias="Idempotency-Key"), ) -> dict[str, object]: return await InvestmentGoalService().confirm(goal_no, context, key) @router.get("/investment-goals/{goal_no}/goal-book") async def investment_goal_book( goal_no: str, context: RequestContext = Depends(build_request_context), # noqa: B008 ) -> dict[str, Any]: return await InvestmentGoalService().goal_book(goal_no, context) @router.post("/investment-goals/{goal_no}/goal-book/reviews") async def review_investment_goal_book( goal_no: str, payload: InvestmentGoalBookReview, context: RequestContext = Depends(build_request_context), # noqa: B008 key: str | None = Header(default=None, alias="Idempotency-Key"), ) -> dict[str, object]: return await InvestmentGoalService().review_book(goal_no, payload, context, key) @router.post("/investment-goals/{goal_no}/goal-book/publications") async def publish_investment_goal_book( goal_no: str, payload: InvestmentGoalBookPublish, context: RequestContext = Depends(build_request_context), # noqa: B008 key: str | None = Header(default=None, alias="Idempotency-Key"), ) -> dict[str, object]: return await InvestmentGoalService().publish_book(goal_no, payload, context, key)