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

from __future__ import annotations
from moovio_sdk.models.components import (
    termsofservicetoken as components_termsofservicetoken,
)
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
from moovio_sdk.utils import FieldMetadata, HeaderMetadata
from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class GetTermsOfServiceTokenRequestTypedDict(TypedDict):
    origin: NotRequired[str]
    r"""Indicates the domain from which the request originated. Required if referer header is not present."""
    referer: NotRequired[str]
    r"""Specifies the URL of the resource from which the request originated. Required if origin header is not present."""


class GetTermsOfServiceTokenRequest(BaseModel):
    origin: Annotated[
        Optional[str],
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ] = None
    r"""Indicates the domain from which the request originated. Required if referer header is not present."""

    referer: Annotated[
        Optional[str],
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ] = None
    r"""Specifies the URL of the resource from which the request originated. Required if origin header is not present."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["origin", "referer"])
        serialized = handler(self)
        m = {}

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

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

        return m


class GetTermsOfServiceTokenResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: components_termsofservicetoken.TermsOfServiceTokenTypedDict


class GetTermsOfServiceTokenResponse(BaseModel):
    headers: Dict[str, List[str]]

    result: components_termsofservicetoken.TermsOfServiceToken
