class CampaignIn(BaseModel):
    name: str = Field(min_length=1, max_length=250)
    recipient_list_id: Optional[int] = None
    subject_set_ids: list = []
    template_ids: list = []
    message_type: str = "html"          # html|plain|both
    attach_mode: str = "none"           # none|pdf|file|image
    attach_pdf: bool = False
    attach_pdf_template_id: Optional[int] = None
    attachment_id: Optional[int] = None
    variable_config: dict = {}
    account_ids: list = []
    rotation_strategy: str = "sequential"
    rotation_weights: dict = {}
    subject_rotation: str = "round_robin"
    template_sequence_mode: str = "repeat"
    phone_selection: str = "round_robin"
    max_per_account: int = Field(default=200, ge=1, le=2000)
    send_interval_seconds: float = Field(default=1.0, ge=0.5, le=3600)
    rate_per_minute: int = Field(default=60, ge=1, le=600)
    max_retries: int = Field(default=3, ge=0, le=10)
    retry_delay_seconds: int = Field(default=60, ge=5, le=3600)
    unsubscribe_enabled: bool = True
    preview_sample_size: int = Field(default=5, ge=1, le=20)


VALID_ENUMS = {
    "message_type": MSG_TYPES,
    "attach_mode": {"none", "pdf", "file", "image"},
    "rotation_strategy": {"sequential", "weighted"},
    "subject_rotation": {"round_robin", "random", "fixed_first"},
    "template_sequence_mode": {"repeat", "stop", "random"},
    "phone_selection": {"round_robin", "random", "fixed"},
}


def _ser(c: Campaign) -> dict:
    return {
        "id": c.id, "name": c.name, "status": c.status,
        "recipient_list_id": c.recipient_list_id,
