"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

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


class CreateDomainRequestBodyTypedDict(TypedDict):
    slug: str
    r"""Name of the domain."""
    expired_url: NotRequired[Nullable[str]]
    r"""Redirect users to a specific URL when any link under this domain has expired."""
    not_found_url: NotRequired[Nullable[str]]
    r"""Redirect users to a specific URL when a link under this domain doesn't exist."""
    archived: NotRequired[bool]
    r"""Whether to archive this domain. `false` will unarchive a previously archived domain."""
    placeholder: NotRequired[Nullable[str]]
    r"""Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened."""
    logo: NotRequired[Nullable[str]]
    r"""The logo of the domain."""
    asset_links: NotRequired[Nullable[str]]
    r"""assetLinks.json configuration file (for deep link support on Android)."""
    apple_app_site_association: NotRequired[Nullable[str]]
    r"""apple-app-site-association configuration file (for deep link support on iOS)."""


class CreateDomainRequestBody(BaseModel):
    slug: str
    r"""Name of the domain."""

    expired_url: Annotated[
        OptionalNullable[str], pydantic.Field(alias="expiredUrl")
    ] = UNSET
    r"""Redirect users to a specific URL when any link under this domain has expired."""

    not_found_url: Annotated[
        OptionalNullable[str], pydantic.Field(alias="notFoundUrl")
    ] = UNSET
    r"""Redirect users to a specific URL when a link under this domain doesn't exist."""

    archived: Optional[bool] = False
    r"""Whether to archive this domain. `false` will unarchive a previously archived domain."""

    placeholder: OptionalNullable[str] = UNSET
    r"""Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened."""

    logo: OptionalNullable[str] = UNSET
    r"""The logo of the domain."""

    asset_links: Annotated[
        OptionalNullable[str], pydantic.Field(alias="assetLinks")
    ] = UNSET
    r"""assetLinks.json configuration file (for deep link support on Android)."""

    apple_app_site_association: Annotated[
        OptionalNullable[str], pydantic.Field(alias="appleAppSiteAssociation")
    ] = UNSET
    r"""apple-app-site-association configuration file (for deep link support on iOS)."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "expiredUrl",
                "notFoundUrl",
                "archived",
                "placeholder",
                "logo",
                "assetLinks",
                "appleAppSiteAssociation",
            ]
        )
        nullable_fields = set(
            [
                "expiredUrl",
                "notFoundUrl",
                "placeholder",
                "logo",
                "assetLinks",
                "appleAppSiteAssociation",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m
