diff --git a/passageidentity/__init__.py b/passageidentity/__init__.py index 285cf1d..817bd2a 100644 --- a/passageidentity/__init__.py +++ b/passageidentity/__init__.py @@ -1,9 +1,12 @@ """Initializes the Passage identity package.""" from .errors import PassageError +from .models import MagicLinkArgs, MagicLinkOptions from .passage import Passage __all__ = [ + "MagicLinkArgs", + "MagicLinkOptions", "Passage", "PassageError", ] diff --git a/passageidentity/auth.py b/passageidentity/auth.py index 959a876..f93a9d4 100644 --- a/passageidentity/auth.py +++ b/passageidentity/auth.py @@ -2,58 +2,21 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import TYPE_CHECKING import jwt import jwt.algorithms from passageidentity.errors import PassageError from passageidentity.helper import fetch_app +from passageidentity.models.magic_link_args import MagicLinkWithEmailArgs, MagicLinkWithPhoneArgs, MagicLinkWithUserArgs from passageidentity.openapi_client.api.magic_links_api import MagicLinksApi from passageidentity.openapi_client.exceptions import ApiException if TYPE_CHECKING: + from passageidentity.models.magic_link_args import MagicLinkArgs + from passageidentity.models.magic_link_options import MagicLinkOptions from passageidentity.openapi_client.models.magic_link import MagicLink - from passageidentity.openapi_client.models.magic_link_channel import MagicLinkChannel - from passageidentity.openapi_client.models.magic_link_type import MagicLinkType - - -class MagicLinkArgsBase: - """Base class for MagicLinkArgs.""" - - type: MagicLinkType - send: bool - - -class MagicLinkWithEmailArgs(MagicLinkArgsBase): - """Arguments for creating a Magic Link with an email.""" - - email: str - - -class MagicLinkWithPhoneArgs(MagicLinkArgsBase): - """Arguments for creating a Magic Link with a phone number.""" - - phone: str - - -class MagicLinkWithUserArgs(MagicLinkArgsBase): - """Arguments for creating a Magic Link with a user ID.""" - - user_id: str - channel: MagicLinkChannel - - -MagicLinkArgs = Union[MagicLinkWithEmailArgs, MagicLinkWithPhoneArgs, MagicLinkWithUserArgs] - - -class MagicLinkOptions: - """Options for creating a Magic Link.""" - - language: str | None - magic_link_path: str | None - redirect_url: str | None - ttl: int | None class Auth: diff --git a/passageidentity/models/__init__.py b/passageidentity/models/__init__.py index c9de38b..2b773cc 100644 --- a/passageidentity/models/__init__.py +++ b/passageidentity/models/__init__.py @@ -19,3 +19,5 @@ ) from passageidentity.models.update_passkey_auth_method import UpdatePasskeysAuthMethod from passageidentity.models.update_otp_auth_method import UpdateOtpAuthMethod +from passageidentity.models.magic_link_args import MagicLinkArgs +from passageidentity.models.magic_link_options import MagicLinkOptions diff --git a/passageidentity/models/magic_link_args.py b/passageidentity/models/magic_link_args.py new file mode 100644 index 0000000..6cd12c2 --- /dev/null +++ b/passageidentity/models/magic_link_args.py @@ -0,0 +1,35 @@ +"""Defines required arguments for creating a Magic Link.""" + +from typing import Union + +from passageidentity.openapi_client.models.magic_link_channel import MagicLinkChannel +from passageidentity.openapi_client.models.magic_link_type import MagicLinkType + + +class MagicLinkArgsBase: + """Base class for MagicLinkArgs.""" + + type: MagicLinkType + send: bool + + +class MagicLinkWithEmailArgs(MagicLinkArgsBase): + """Arguments for creating a Magic Link with an email.""" + + email: str + + +class MagicLinkWithPhoneArgs(MagicLinkArgsBase): + """Arguments for creating a Magic Link with a phone number.""" + + phone: str + + +class MagicLinkWithUserArgs(MagicLinkArgsBase): + """Arguments for creating a Magic Link with a user ID.""" + + user_id: str + channel: MagicLinkChannel + + +MagicLinkArgs = Union[MagicLinkWithEmailArgs, MagicLinkWithPhoneArgs, MagicLinkWithUserArgs] diff --git a/passageidentity/models/magic_link_options.py b/passageidentity/models/magic_link_options.py new file mode 100644 index 0000000..88787cf --- /dev/null +++ b/passageidentity/models/magic_link_options.py @@ -0,0 +1,12 @@ +"""Defines options for creating a Magic Link.""" + +from __future__ import annotations + + +class MagicLinkOptions: + """Options for creating a Magic Link.""" + + language: str | None + magic_link_path: str | None + redirect_url: str | None + ttl: int | None diff --git a/passageidentity/passage.py b/passageidentity/passage.py index eff3c7c..ed04bb6 100644 --- a/passageidentity/passage.py +++ b/passageidentity/passage.py @@ -6,15 +6,11 @@ import typing_extensions -from passageidentity.auth import ( - Auth, - MagicLinkOptions, - MagicLinkWithEmailArgs, - MagicLinkWithPhoneArgs, - MagicLinkWithUserArgs, -) +from passageidentity.auth import Auth from passageidentity.errors import PassageError from passageidentity.helper import get_auth_token_from_request +from passageidentity.models.magic_link_args import MagicLinkWithEmailArgs, MagicLinkWithPhoneArgs, MagicLinkWithUserArgs +from passageidentity.models.magic_link_options import MagicLinkOptions from passageidentity.openapi_client.models.magic_link_channel import MagicLinkChannel from passageidentity.user import User