"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""

from __future__ import annotations
from dub.types import BaseModel, Nullable
import pydantic
from pydantic import model_serializer
from typing import Optional, TypedDict
from typing_extensions import Annotated, NotRequired


class DomainSchemaTypedDict(TypedDict):
    id: str
    r"""The unique identifier of the domain."""
    slug: str
    r"""The domain name."""
    expired_url: Nullable[str]
    r"""The URL to redirect to when a link under this domain has expired."""
    created_at: str
    r"""The date the domain was created."""
    updated_at: str
    r"""The date the domain was last updated."""
    verified: NotRequired[bool]
    r"""Whether the domain is verified."""
    primary: NotRequired[bool]
    r"""Whether the domain is the primary domain for the workspace."""
    archived: NotRequired[bool]
    r"""Whether the domain is archived."""
    placeholder: NotRequired[str]
    r"""Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened."""
    

class DomainSchema(BaseModel):
    id: str
    r"""The unique identifier of the domain."""
    slug: str
    r"""The domain name."""
    expired_url: Annotated[Nullable[str], pydantic.Field(alias="expiredUrl")]
    r"""The URL to redirect to when a link under this domain has expired."""
    created_at: Annotated[str, pydantic.Field(alias="createdAt")]
    r"""The date the domain was created."""
    updated_at: Annotated[str, pydantic.Field(alias="updatedAt")]
    r"""The date the domain was last updated."""
    verified: Optional[bool] = False
    r"""Whether the domain is verified."""
    primary: Optional[bool] = False
    r"""Whether the domain is the primary domain for the workspace."""
    archived: Optional[bool] = False
    r"""Whether the domain is archived."""
    placeholder: Optional[str] = "https://dub.co/help/article/what-is-dub"
    r"""Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened."""
    
    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["verified", "primary", "archived", "placeholder"]
        nullable_fields = ["expiredUrl"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val is not None:
                m[k] = val
            elif not k in optional_fields or (
                    k in optional_fields
                    and k in nullable_fields
                    and (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
                ):
                m[k] = val

        return m
        
