Files
marquiz-metrics/app/api/v1/schemas/goal.py
13orlov c207d49a5c
All checks were successful
continuous-integration/drone/push Build is passing
feat(goals): Add endpoints to get and create custom goals
2025-08-25 18:47:23 +01:00

31 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from pydantic import BaseModel, Field
from typing import List
# Схема для ОДНОЙ цели в списке (для GET запроса)
class Goal(BaseModel):
id: int
name: str
type: str
# Схема для ответа со списком целей
class GoalListResponse(BaseModel):
goals: List[Goal]
# --- ИЗМЕНЕНИЯ ЗДЕСЬ ---
# Схема для ОДНОЙ кастомной цели в запросе на создание (для POST)
class CustomGoalIn(BaseModel):
identifier: str = Field(..., description="Уникальный идентификатор JS-события")
name: str = Field(..., max_length=255, description="Название цели, которое будет видно в Метрике")
# Обновленная схема запроса на создание целей
class GoalCreateRequest(BaseModel):
goals: List[CustomGoalIn]
# Схема для ОДНОЙ созданной цели в ответе
class CreatedGoal(BaseModel):
id: int
name: str
# Схема ответа после создания целей
class GoalCreateResponse(BaseModel):
created_goals: List[CreatedGoal]