from typing import Optional, Any

from pydantic import BaseModel

from fastapi import Form

# Shared properties
class ArticleBase(BaseModel):
    title: Optional[str] = None
    link: Optional[str] = None
    content: Optional[str] = None

# Properties to receive on video creation
class ArticleCreate(ArticleBase):
    title: str

    @classmethod
    def as_form(
        cls,
        title: str = Form(...),
        link: str = Form(None),
        content: str = Form(None)
    ) -> Any:
        return cls(title=title, link=link, content=content)
    
# Properties to receive via API on update
class ArticleUpdate(ArticleBase):
    pass