from datetime import datetime

from pydantic import BaseModel, ConfigDict, Field


class ActivityCreate(BaseModel):
    activity_type: str = Field(..., max_length=20)
    subject: str = Field(..., min_length=1, max_length=255)
    description: str | None = None
    status: str = Field("pending", max_length=20)
    due_date: datetime | None = None
    account_id: int | None = None
    contact_id: int | None = None
    lead_id: int | None = None
    opportunity_id: int | None = None
    owner_user_id: str | None = Field(None, max_length=64)


class ActivityUpdate(BaseModel):
    activity_type: str | None = Field(None, max_length=20)
    subject: str | None = Field(None, min_length=1, max_length=255)
    description: str | None = None
    status: str | None = Field(None, max_length=20)
    due_date: datetime | None = None
    completed_at: datetime | None = None
    account_id: int | None = None
    contact_id: int | None = None
    lead_id: int | None = None
    opportunity_id: int | None = None
    owner_user_id: str | None = Field(None, max_length=64)


class ActivityResponse(BaseModel):
    model_config = ConfigDict(from_attributes=True)

    id: int
    activity_type: str
    subject: str
    description: str | None
    status: str
    due_date: datetime | None
    completed_at: datetime | None
    account_id: int | None
    contact_id: int | None
    lead_id: int | None
    opportunity_id: int | None
    owner_user_id: str | None
    tenant_id: int
    company_id: int
    created_at: datetime
    updated_at: datetime
