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

from __future__ import annotations
from documenso_sdk import utils
from documenso_sdk.types import BaseModel, Nullable, UNSET_SENTINEL
from enum import Enum
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, TypedDict


class TemplateMoveTemplateToTeamRequestBodyTypedDict(TypedDict):
    template_id: float
    r"""The ID of the template to move to."""
    team_id: float
    r"""The ID of the team to move the template to."""


class TemplateMoveTemplateToTeamRequestBody(BaseModel):
    template_id: Annotated[float, pydantic.Field(alias="templateId")]
    r"""The ID of the template to move to."""

    team_id: Annotated[float, pydantic.Field(alias="teamId")]
    r"""The ID of the team to move the template to."""


class TemplateMoveTemplateToTeamTemplatesIssuesTypedDict(TypedDict):
    message: str


class TemplateMoveTemplateToTeamTemplatesIssues(BaseModel):
    message: str


class TemplateMoveTemplateToTeamTemplatesResponseResponseBodyData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateMoveTemplateToTeamTemplatesIssues]] = None


class TemplateMoveTemplateToTeamTemplatesResponseResponseBody(Exception):
    r"""Internal server error"""

    data: TemplateMoveTemplateToTeamTemplatesResponseResponseBodyData

    def __init__(
        self, data: TemplateMoveTemplateToTeamTemplatesResponseResponseBodyData
    ):
        self.data = data

    def __str__(self) -> str:
        return utils.marshal_json(
            self.data, TemplateMoveTemplateToTeamTemplatesResponseResponseBodyData
        )


class TemplateMoveTemplateToTeamIssuesTypedDict(TypedDict):
    message: str


class TemplateMoveTemplateToTeamIssues(BaseModel):
    message: str


class TemplateMoveTemplateToTeamTemplatesResponseBodyData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateMoveTemplateToTeamIssues]] = None


class TemplateMoveTemplateToTeamTemplatesResponseBody(Exception):
    r"""Invalid input data"""

    data: TemplateMoveTemplateToTeamTemplatesResponseBodyData

    def __init__(self, data: TemplateMoveTemplateToTeamTemplatesResponseBodyData):
        self.data = data

    def __str__(self) -> str:
        return utils.marshal_json(
            self.data, TemplateMoveTemplateToTeamTemplatesResponseBodyData
        )


class TemplateMoveTemplateToTeamType(str, Enum):
    PUBLIC = "PUBLIC"
    PRIVATE = "PRIVATE"


class TemplateMoveTemplateToTeamVisibility(str, Enum):
    EVERYONE = "EVERYONE"
    MANAGER_AND_ABOVE = "MANAGER_AND_ABOVE"
    ADMIN = "ADMIN"


class TemplateMoveTemplateToTeamGlobalAccessAuth(str, Enum):
    r"""The type of authentication required for the recipient to access the document."""

    ACCOUNT = "ACCOUNT"


class TemplateMoveTemplateToTeamGlobalActionAuth(str, Enum):
    r"""The type of authentication required for the recipient to sign the document. This field is restricted to Enterprise plan users only."""

    ACCOUNT = "ACCOUNT"
    PASSKEY = "PASSKEY"
    TWO_FACTOR_AUTH = "TWO_FACTOR_AUTH"


class TemplateMoveTemplateToTeamAuthOptionsTypedDict(TypedDict):
    global_access_auth: Nullable[TemplateMoveTemplateToTeamGlobalAccessAuth]
    r"""The type of authentication required for the recipient to access the document."""
    global_action_auth: Nullable[TemplateMoveTemplateToTeamGlobalActionAuth]
    r"""The type of authentication required for the recipient to sign the document. This field is restricted to Enterprise plan users only."""


class TemplateMoveTemplateToTeamAuthOptions(BaseModel):
    global_access_auth: Annotated[
        Nullable[TemplateMoveTemplateToTeamGlobalAccessAuth],
        pydantic.Field(alias="globalAccessAuth"),
    ]
    r"""The type of authentication required for the recipient to access the document."""

    global_action_auth: Annotated[
        Nullable[TemplateMoveTemplateToTeamGlobalActionAuth],
        pydantic.Field(alias="globalActionAuth"),
    ]
    r"""The type of authentication required for the recipient to sign the document. This field is restricted to Enterprise plan users only."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = ["globalAccessAuth", "globalActionAuth"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

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

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class TemplateMoveTemplateToTeamResponseBodyTypedDict(TypedDict):
    r"""Successful response"""

    type: TemplateMoveTemplateToTeamType
    visibility: TemplateMoveTemplateToTeamVisibility
    id: int
    external_id: Nullable[str]
    title: str
    user_id: int
    team_id: Nullable[int]
    auth_options: Nullable[TemplateMoveTemplateToTeamAuthOptionsTypedDict]
    template_document_data_id: str
    created_at: str
    updated_at: str
    public_title: str
    public_description: str


class TemplateMoveTemplateToTeamResponseBody(BaseModel):
    r"""Successful response"""

    type: TemplateMoveTemplateToTeamType

    visibility: TemplateMoveTemplateToTeamVisibility

    id: int

    external_id: Annotated[Nullable[str], pydantic.Field(alias="externalId")]

    title: str

    user_id: Annotated[int, pydantic.Field(alias="userId")]

    team_id: Annotated[Nullable[int], pydantic.Field(alias="teamId")]

    auth_options: Annotated[
        Nullable[TemplateMoveTemplateToTeamAuthOptions],
        pydantic.Field(alias="authOptions"),
    ]

    template_document_data_id: Annotated[
        str, pydantic.Field(alias="templateDocumentDataId")
    ]

    created_at: Annotated[str, pydantic.Field(alias="createdAt")]

    updated_at: Annotated[str, pydantic.Field(alias="updatedAt")]

    public_title: Annotated[str, pydantic.Field(alias="publicTitle")]

    public_description: Annotated[str, pydantic.Field(alias="publicDescription")]

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = ["externalId", "teamId", "authOptions"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

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

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m
