56 lines
2.1 KiB
Python
56 lines
2.1 KiB
Python
"""Advisory investment-goal collection and draft goal-book endpoints."""
|
|
|
|
from typing import Any
|
|
|
|
from fastapi import APIRouter, Depends, Header, status
|
|
|
|
from app.api.dependencies.auth import build_request_context
|
|
from app.api.schemas.investment_goals import InvestmentGoalConfirmation, InvestmentGoalCreate
|
|
from app.core.contracts import RequestContext
|
|
from app.service.investment_goal_service import InvestmentGoalService
|
|
|
|
router = APIRouter(prefix="/api/v1/advisor", tags=["advisor-investment-goals"])
|
|
|
|
|
|
@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]:
|
|
del payload
|
|
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)
|