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

from __future__ import annotations
from .onev1_1oauth2_1token_post_x_components_authorizationcodetokenrequest import (
    Onev11oauth21tokenPostXComponentsAuthorizationCodeTokenRequest,
    Onev11oauth21tokenPostXComponentsAuthorizationCodeTokenRequestTypedDict,
)
from .onev1_1oauth2_1token_post_x_components_refreshtokenrequest import (
    Onev11oauth21tokenPostXComponentsRefreshTokenRequest,
    Onev11oauth21tokenPostXComponentsRefreshTokenRequestTypedDict,
)
from polar_sdk.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union
from typing_extensions import Annotated, TypeAliasType


Oauth2RequestTokenRequestBodyTypedDict = TypeAliasType(
    "Oauth2RequestTokenRequestBodyTypedDict",
    Union[
        Onev11oauth21tokenPostXComponentsRefreshTokenRequestTypedDict,
        Onev11oauth21tokenPostXComponentsAuthorizationCodeTokenRequestTypedDict,
    ],
)


Oauth2RequestTokenRequestBody = Annotated[
    Union[
        Annotated[
            Onev11oauth21tokenPostXComponentsAuthorizationCodeTokenRequest,
            Tag("authorization_code"),
        ],
        Annotated[
            Onev11oauth21tokenPostXComponentsRefreshTokenRequest, Tag("refresh_token")
        ],
    ],
    Discriminator(lambda m: get_discriminator(m, "grant_type", "grant_type")),
]
