maxapi-python 1.2.4__py3-none-any.whl → 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maxapi_python-2.0.0.dist-info/METADATA +217 -0
- maxapi_python-2.0.0.dist-info/RECORD +140 -0
- {maxapi_python-1.2.4.dist-info → maxapi_python-2.0.0.dist-info}/WHEEL +1 -1
- pymax/__init__.py +50 -105
- pymax/api/__init__.py +17 -0
- pymax/api/auth/__init__.py +1 -0
- pymax/api/auth/enums.py +17 -0
- pymax/api/auth/payloads.py +129 -0
- pymax/api/auth/service.py +313 -0
- pymax/api/auth/types.py +13 -0
- pymax/api/chats/__init__.py +8 -0
- pymax/api/chats/enums.py +27 -0
- pymax/api/chats/payloads.py +103 -0
- pymax/api/chats/service.py +277 -0
- pymax/api/facade.py +32 -0
- pymax/api/messages/__init__.py +1 -0
- pymax/api/messages/enums.py +17 -0
- pymax/api/messages/payloads.py +92 -0
- pymax/api/messages/service.py +337 -0
- pymax/api/models.py +13 -0
- pymax/api/response.py +123 -0
- pymax/api/self/__init__.py +2 -0
- pymax/api/self/enums.py +11 -0
- pymax/api/self/payloads.py +41 -0
- pymax/api/self/service.py +142 -0
- pymax/api/session/__init__.py +1 -0
- pymax/api/session/enums.py +10 -0
- pymax/api/session/payloads.py +76 -0
- pymax/api/session/service.py +72 -0
- pymax/api/uploads/__init__.py +1 -0
- pymax/api/uploads/models.py +49 -0
- pymax/api/uploads/payloads.py +25 -0
- pymax/api/uploads/service.py +458 -0
- pymax/api/users/__init__.py +2 -0
- pymax/api/users/enums.py +12 -0
- pymax/api/users/payloads.py +16 -0
- pymax/api/users/service.py +124 -0
- pymax/app.py +273 -0
- pymax/auth/__init__.py +25 -0
- pymax/auth/base.py +37 -0
- pymax/auth/email.py +0 -0
- pymax/auth/models.py +5 -0
- pymax/auth/providers.py +127 -0
- pymax/auth/qr.py +135 -0
- pymax/auth/service.py +25 -0
- pymax/auth/sms.py +122 -0
- pymax/base.py +204 -0
- pymax/client.py +106 -0
- pymax/client_web.py +83 -0
- pymax/config.py +215 -0
- pymax/connection/__init__.py +1 -0
- pymax/connection/connection.py +205 -0
- pymax/connection/pending.py +46 -0
- pymax/connection/readers/__init__.py +2 -0
- pymax/connection/readers/base.py +6 -0
- pymax/connection/readers/tcp.py +29 -0
- pymax/connection/readers/ws.py +14 -0
- pymax/dispatch/__init__.py +10 -0
- pymax/dispatch/dispatcher.py +222 -0
- pymax/dispatch/enums.py +12 -0
- pymax/dispatch/mapping.py +73 -0
- pymax/dispatch/resolvers.py +52 -0
- pymax/dispatch/router.py +216 -0
- pymax/exceptions.py +22 -89
- pymax/files/__init__.py +9 -0
- pymax/files/base.py +82 -0
- pymax/files/file.py +76 -0
- pymax/files/photo.py +108 -0
- pymax/files/static.py +10 -0
- pymax/files/video.py +74 -0
- pymax/formatting/__init__.py +0 -0
- pymax/formatting/markdown.py +217 -0
- pymax/infra/__init__.py +1 -0
- pymax/infra/auth.py +55 -0
- pymax/infra/base.py +15 -0
- pymax/infra/chat.py +240 -0
- pymax/infra/message.py +252 -0
- pymax/infra/protocol.py +9 -0
- pymax/infra/self.py +139 -0
- pymax/infra/user.py +107 -0
- pymax/logging.py +129 -0
- pymax/protocol/__init__.py +11 -0
- pymax/protocol/base.py +13 -0
- pymax/{static/enum.py → protocol/enums.py} +36 -79
- pymax/protocol/models.py +33 -0
- pymax/protocol/tcp/__init__.py +1 -0
- pymax/protocol/tcp/compression.py +97 -0
- pymax/protocol/tcp/framing.py +68 -0
- pymax/protocol/tcp/payload.py +127 -0
- pymax/protocol/tcp/protocol.py +68 -0
- pymax/protocol/ws/__init__.py +1 -0
- pymax/protocol/ws/protocol.py +27 -0
- pymax/py.typed +0 -0
- pymax/routers.py +8 -0
- pymax/session/__init__.py +3 -0
- pymax/session/models.py +11 -0
- pymax/session/protocol.py +14 -0
- pymax/session/store.py +232 -0
- pymax/telemetry/__init__.py +3 -0
- pymax/telemetry/navigation.py +181 -0
- pymax/telemetry/payloads.py +142 -0
- pymax/telemetry/service.py +225 -0
- pymax/transport/__init__.py +0 -0
- pymax/transport/base.py +14 -0
- pymax/transport/tcp.py +93 -0
- pymax/transport/websocket.py +50 -0
- pymax/types/__init__.py +2 -0
- pymax/types/domain/__init__.py +11 -0
- pymax/types/domain/attachments/__init__.py +11 -0
- pymax/types/domain/attachments/audio.py +35 -0
- pymax/types/domain/attachments/call.py +26 -0
- pymax/types/domain/attachments/contact.py +32 -0
- pymax/types/domain/attachments/control.py +20 -0
- pymax/types/domain/attachments/enums.py +27 -0
- pymax/types/domain/attachments/file.py +56 -0
- pymax/types/domain/attachments/keyboards/__init__.py +1 -0
- pymax/types/domain/attachments/keyboards/inline.py +19 -0
- pymax/types/domain/attachments/photo.py +45 -0
- pymax/types/domain/attachments/share.py +29 -0
- pymax/types/domain/attachments/sticker.py +50 -0
- pymax/types/domain/attachments/video.py +90 -0
- pymax/types/domain/auth.py +161 -0
- pymax/types/domain/base.py +17 -0
- pymax/types/domain/chat.py +426 -0
- pymax/types/domain/element.py +24 -0
- pymax/types/domain/enums.py +24 -0
- pymax/types/domain/error.py +20 -0
- pymax/types/domain/folder.py +74 -0
- pymax/types/domain/login.py +35 -0
- pymax/types/domain/message.py +378 -0
- pymax/types/domain/name.py +20 -0
- pymax/types/domain/profile.py +15 -0
- pymax/types/domain/session.py +52 -0
- pymax/types/domain/sync.py +80 -0
- pymax/types/domain/user.py +117 -0
- pymax/types/events/__init__.py +3 -0
- pymax/types/events/file.py +5 -0
- pymax/types/events/message.py +37 -0
- pymax/types/events/video.py +5 -0
- maxapi_python-1.2.4.dist-info/METADATA +0 -205
- maxapi_python-1.2.4.dist-info/RECORD +0 -33
- pymax/core.py +0 -390
- pymax/crud.py +0 -96
- pymax/files.py +0 -138
- pymax/filters.py +0 -164
- pymax/formatter.py +0 -31
- pymax/formatting.py +0 -74
- pymax/interfaces.py +0 -552
- pymax/mixins/__init__.py +0 -40
- pymax/mixins/auth.py +0 -368
- pymax/mixins/channel.py +0 -130
- pymax/mixins/group.py +0 -458
- pymax/mixins/handler.py +0 -285
- pymax/mixins/message.py +0 -879
- pymax/mixins/scheduler.py +0 -28
- pymax/mixins/self.py +0 -259
- pymax/mixins/socket.py +0 -297
- pymax/mixins/telemetry.py +0 -112
- pymax/mixins/user.py +0 -219
- pymax/mixins/websocket.py +0 -142
- pymax/models.py +0 -8
- pymax/navigation.py +0 -187
- pymax/payloads.py +0 -367
- pymax/protocols.py +0 -123
- pymax/static/constant.py +0 -89
- pymax/types.py +0 -1220
- pymax/utils.py +0 -90
- {maxapi_python-1.2.4.dist-info → maxapi_python-2.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AttachmentType(str, Enum):
|
|
5
|
+
"""Тип вложения сообщения."""
|
|
6
|
+
|
|
7
|
+
PHOTO = "PHOTO"
|
|
8
|
+
VIDEO = "VIDEO"
|
|
9
|
+
FILE = "FILE"
|
|
10
|
+
STICKER = "STICKER"
|
|
11
|
+
AUDIO = "AUDIO"
|
|
12
|
+
CONTROL = "CONTROL"
|
|
13
|
+
CONTACT = "CONTACT"
|
|
14
|
+
CALL = "CALL"
|
|
15
|
+
SHARE = "SHARE"
|
|
16
|
+
INLINE_KEYBOARD = "INLINE_KEYBOARD"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class TranscriptionStatus(str, Enum):
|
|
20
|
+
"""Статус транскрибации аудио."""
|
|
21
|
+
|
|
22
|
+
FAILED = "FAILED"
|
|
23
|
+
MEDIA_NOT_READY = "MEDIA_NOT_READY"
|
|
24
|
+
NOT_SUPPORTED = "NOT_SUPPORTED"
|
|
25
|
+
PROCESSING = "PROCESSING"
|
|
26
|
+
SUCCESS = "SUCCESS"
|
|
27
|
+
UNKNOWN = "UNKNOWN"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from pymax.types.domain.base import CamelModel
|
|
6
|
+
|
|
7
|
+
from .enums import AttachmentType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class FileAttachment(CamelModel):
|
|
11
|
+
"""Файловое вложение сообщения.
|
|
12
|
+
|
|
13
|
+
Используйте этот тип для входящих файлов в ``Message.attaches``. Временный
|
|
14
|
+
URL для скачивания можно получить через ``client.get_file_by_id``.
|
|
15
|
+
|
|
16
|
+
Example:
|
|
17
|
+
.. code-block:: python
|
|
18
|
+
|
|
19
|
+
for attach in message.attaches:
|
|
20
|
+
if isinstance(attach, FileAttachment):
|
|
21
|
+
file = await client.get_file_by_id(
|
|
22
|
+
message.chat_id,
|
|
23
|
+
message.id,
|
|
24
|
+
attach.file_id,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
:ivar file_id: ID файла.
|
|
28
|
+
:vartype file_id: int
|
|
29
|
+
:ivar name: Имя файла.
|
|
30
|
+
:vartype name: str
|
|
31
|
+
:ivar size: Размер файла в байтах.
|
|
32
|
+
:vartype size: int
|
|
33
|
+
:ivar token: Токен файла.
|
|
34
|
+
:vartype token: str
|
|
35
|
+
:ivar type: Тип вложения.
|
|
36
|
+
:vartype type: Literal[AttachmentType.FILE]
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
file_id: int
|
|
40
|
+
name: str
|
|
41
|
+
size: int
|
|
42
|
+
token: str
|
|
43
|
+
type: Literal[AttachmentType.FILE] = Field(alias="_type")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class FileRequest(CamelModel):
|
|
47
|
+
"""Данные для скачивания файлового вложения.
|
|
48
|
+
|
|
49
|
+
:ivar unsafe: Помечен ли файл как небезопасный.
|
|
50
|
+
:vartype unsafe: bool
|
|
51
|
+
:ivar url: URL файла.
|
|
52
|
+
:vartype url: str
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
unsafe: bool
|
|
56
|
+
url: str
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .inline import InlineKeyboardAttachment
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from typing import Any, Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from pymax.types.domain.attachments import AttachmentType
|
|
6
|
+
from pymax.types.domain.base import CamelModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class InlineKeyboardAttachment(CamelModel):
|
|
10
|
+
"""Вложение inline-клавиатуры.
|
|
11
|
+
|
|
12
|
+
:ivar type: Тип вложения.
|
|
13
|
+
:vartype type: Literal[AttachmentType.INLINE_KEYBOARD]
|
|
14
|
+
:ivar keyboard: Данные inline-клавиатуры.
|
|
15
|
+
:vartype keyboard: dict[str, Any]
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
type: Literal[AttachmentType.INLINE_KEYBOARD] = Field(alias="_type")
|
|
19
|
+
keyboard: dict[str, Any]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from pymax.types.domain.base import CamelModel
|
|
6
|
+
|
|
7
|
+
from .enums import AttachmentType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PhotoAttachment(CamelModel):
|
|
11
|
+
"""Фото-вложение сообщения.
|
|
12
|
+
|
|
13
|
+
Используйте этот тип для входящих фото в ``Message.attaches``. Для отправки
|
|
14
|
+
нового фото используйте ``pymax.Photo`` из ``pymax.files``.
|
|
15
|
+
|
|
16
|
+
Example:
|
|
17
|
+
.. code-block:: python
|
|
18
|
+
|
|
19
|
+
for attach in message.attaches:
|
|
20
|
+
if isinstance(attach, PhotoAttachment):
|
|
21
|
+
print(attach.photo_id, attach.base_url)
|
|
22
|
+
|
|
23
|
+
:ivar base_url: URL фотографии.
|
|
24
|
+
:vartype base_url: str
|
|
25
|
+
:ivar height: Высота изображения.
|
|
26
|
+
:vartype height: int
|
|
27
|
+
:ivar width: Ширина изображения.
|
|
28
|
+
:vartype width: int
|
|
29
|
+
:ivar photo_id: ID фотографии.
|
|
30
|
+
:vartype photo_id: int
|
|
31
|
+
:ivar photo_token: Токен фотографии.
|
|
32
|
+
:vartype photo_token: str
|
|
33
|
+
:ivar preview_data: Данные превью.
|
|
34
|
+
:vartype preview_data: bytes | None
|
|
35
|
+
:ivar type: Тип вложения.
|
|
36
|
+
:vartype type: Literal[AttachmentType.PHOTO]
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
base_url: str
|
|
40
|
+
height: int
|
|
41
|
+
width: int
|
|
42
|
+
photo_id: int
|
|
43
|
+
photo_token: str
|
|
44
|
+
preview_data: bytes | None = None
|
|
45
|
+
type: Literal[AttachmentType.PHOTO] = Field(alias="_type")
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from typing import Any, Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from pymax.types.domain.base import CamelModel
|
|
6
|
+
|
|
7
|
+
from .enums import AttachmentType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ShareAttachment(CamelModel):
|
|
11
|
+
"""Вложение предпросмотра ссылки.
|
|
12
|
+
|
|
13
|
+
:ivar type: Тип вложения.
|
|
14
|
+
:vartype type: Literal[AttachmentType.SHARE]
|
|
15
|
+
:ivar url: URL ссылки.
|
|
16
|
+
:vartype url: str | None
|
|
17
|
+
:ivar title: Заголовок предпросмотра.
|
|
18
|
+
:vartype title: str | None
|
|
19
|
+
:ivar description: Описание предпросмотра.
|
|
20
|
+
:vartype description: str | None
|
|
21
|
+
:ivar image: Данные изображения предпросмотра.
|
|
22
|
+
:vartype image: dict[str, Any] | None
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
type: Literal[AttachmentType.SHARE] = Field(alias="_type")
|
|
26
|
+
url: str | None = None
|
|
27
|
+
title: str | None = None
|
|
28
|
+
description: str | None = None
|
|
29
|
+
image: dict[str, Any] | None = None
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from pymax.types.domain.base import CamelModel
|
|
6
|
+
|
|
7
|
+
from .enums import AttachmentType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class StickerAttachment(CamelModel):
|
|
11
|
+
"""Стикер-вложение сообщения.
|
|
12
|
+
|
|
13
|
+
:ivar author_type: Тип автора стикера, если Max его прислал.
|
|
14
|
+
:vartype author_type: str | None
|
|
15
|
+
:ivar lottie_url: URL Lottie-анимации.
|
|
16
|
+
:vartype lottie_url: str | None
|
|
17
|
+
:ivar url: URL стикера.
|
|
18
|
+
:vartype url: str
|
|
19
|
+
:ivar sticker_id: ID стикера.
|
|
20
|
+
:vartype sticker_id: int
|
|
21
|
+
:ivar tags: Теги стикера.
|
|
22
|
+
:vartype tags: list[str] | None
|
|
23
|
+
:ivar width: Ширина стикера.
|
|
24
|
+
:vartype width: int
|
|
25
|
+
:ivar set_id: ID набора стикеров.
|
|
26
|
+
:vartype set_id: int
|
|
27
|
+
:ivar time: Время или версия стикера в данных Max.
|
|
28
|
+
:vartype time: int
|
|
29
|
+
:ivar sticker_type: Тип стикера.
|
|
30
|
+
:vartype sticker_type: str
|
|
31
|
+
:ivar audio: Есть ли аудио.
|
|
32
|
+
:vartype audio: bool
|
|
33
|
+
:ivar height: Высота стикера.
|
|
34
|
+
:vartype height: int
|
|
35
|
+
:ivar type: Тип вложения.
|
|
36
|
+
:vartype type: Literal[AttachmentType.STICKER]
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
author_type: str | None = None
|
|
40
|
+
lottie_url: str | None = None
|
|
41
|
+
url: str
|
|
42
|
+
sticker_id: int
|
|
43
|
+
tags: list[str] | None = None
|
|
44
|
+
width: int
|
|
45
|
+
set_id: int
|
|
46
|
+
time: int
|
|
47
|
+
sticker_type: str
|
|
48
|
+
audio: bool
|
|
49
|
+
height: int
|
|
50
|
+
type: Literal[AttachmentType.STICKER] = Field(alias="_type")
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from typing import Any, Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field, model_validator
|
|
4
|
+
|
|
5
|
+
from pymax.types.domain.base import CamelModel
|
|
6
|
+
|
|
7
|
+
from .enums import AttachmentType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class VideoAttachment(CamelModel):
|
|
11
|
+
"""Видео-вложение сообщения.
|
|
12
|
+
|
|
13
|
+
Используйте этот тип для входящих видео в ``Message.attaches``. Временный
|
|
14
|
+
URL для просмотра можно получить через ``client.get_video_by_id``.
|
|
15
|
+
|
|
16
|
+
Example:
|
|
17
|
+
.. code-block:: python
|
|
18
|
+
|
|
19
|
+
for attach in message.attaches:
|
|
20
|
+
if isinstance(attach, VideoAttachment):
|
|
21
|
+
video = await client.get_video_by_id(
|
|
22
|
+
message.chat_id,
|
|
23
|
+
message.id,
|
|
24
|
+
attach.video_id,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
:ivar height: Высота видео.
|
|
28
|
+
:vartype height: int
|
|
29
|
+
:ivar width: Ширина видео.
|
|
30
|
+
:vartype width: int
|
|
31
|
+
:ivar video_id: ID видео.
|
|
32
|
+
:vartype video_id: int
|
|
33
|
+
:ivar duration: Длительность видео.
|
|
34
|
+
:vartype duration: int
|
|
35
|
+
:ivar preview_data: Данные превью.
|
|
36
|
+
:vartype preview_data: bytes
|
|
37
|
+
:ivar type: Тип вложения.
|
|
38
|
+
:vartype type: Literal[AttachmentType.VIDEO]
|
|
39
|
+
:ivar thumbnail: URL миниатюры.
|
|
40
|
+
:vartype thumbnail: str
|
|
41
|
+
:ivar token: Токен видео.
|
|
42
|
+
:vartype token: str
|
|
43
|
+
:ivar video_type: Код типа видео в Max.
|
|
44
|
+
:vartype video_type: int
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
height: int
|
|
48
|
+
width: int
|
|
49
|
+
video_id: int
|
|
50
|
+
duration: int
|
|
51
|
+
preview_data: bytes
|
|
52
|
+
type: Literal[AttachmentType.VIDEO] = Field(alias="_type")
|
|
53
|
+
thumbnail: str
|
|
54
|
+
token: str
|
|
55
|
+
video_type: int
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class VideoRequest(CamelModel):
|
|
59
|
+
"""Данные для просмотра видео-вложения.
|
|
60
|
+
|
|
61
|
+
:ivar external: Признак или URL внешнего источника видео.
|
|
62
|
+
:vartype external: str | bool | None
|
|
63
|
+
:ivar cache: Использовать ли кеш.
|
|
64
|
+
:vartype cache: bool
|
|
65
|
+
:ivar url: URL видео.
|
|
66
|
+
:vartype url: str
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
external: str | bool | None = Field(default=None, alias="EXTERNAL")
|
|
70
|
+
cache: bool
|
|
71
|
+
url: str
|
|
72
|
+
|
|
73
|
+
@model_validator(mode="before")
|
|
74
|
+
@classmethod
|
|
75
|
+
def unwrap_dynamic_url(cls, value: Any) -> Any:
|
|
76
|
+
"""Нормализует динамический ключ URL в поле ``url``.
|
|
77
|
+
|
|
78
|
+
:param value: Значение, переданное в валидатор модели.
|
|
79
|
+
:type value: Any
|
|
80
|
+
:returns: Данные запроса видео или исходное значение.
|
|
81
|
+
:rtype: Any
|
|
82
|
+
"""
|
|
83
|
+
if not isinstance(value, dict) or "url" in value:
|
|
84
|
+
return value
|
|
85
|
+
|
|
86
|
+
for key, url in value.items():
|
|
87
|
+
if key not in ("EXTERNAL", "cache"):
|
|
88
|
+
return {**value, "url": url}
|
|
89
|
+
|
|
90
|
+
return value
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
|
|
3
|
+
from pymax.api.models import CamelModel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class StartAuthResponse(CamelModel):
|
|
7
|
+
"""Ответ на начало авторизации.
|
|
8
|
+
|
|
9
|
+
:ivar token: Токен авторизационного запроса.
|
|
10
|
+
:vartype token: str
|
|
11
|
+
:ivar code_length: Длина кода подтверждения.
|
|
12
|
+
:vartype code_length: int
|
|
13
|
+
:ivar request_max_duration: Максимальное время ожидания запроса кода.
|
|
14
|
+
:vartype request_max_duration: int
|
|
15
|
+
:ivar request_count_left: Количество оставшихся запросов кода.
|
|
16
|
+
:vartype request_count_left: int
|
|
17
|
+
:ivar alt_action_duration: Время до доступности альтернативного действия.
|
|
18
|
+
:vartype alt_action_duration: int
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
token: str
|
|
22
|
+
code_length: int
|
|
23
|
+
request_max_duration: int
|
|
24
|
+
request_count_left: int
|
|
25
|
+
alt_action_duration: int
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class Token(CamelModel):
|
|
29
|
+
"""Токен авторизации или регистрации.
|
|
30
|
+
|
|
31
|
+
:ivar token: Значение токена.
|
|
32
|
+
:vartype token: str
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
token: str
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class TokenAttrs(BaseModel):
|
|
39
|
+
"""Набор токенов, возвращенных после проверки кода или пароля.
|
|
40
|
+
|
|
41
|
+
:ivar login: Токен входа.
|
|
42
|
+
:vartype login: Token | None
|
|
43
|
+
:ivar register_token: Токен регистрации.
|
|
44
|
+
:vartype register_token: Token | None
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
login: Token | None = Field(None, alias="LOGIN")
|
|
48
|
+
register_token: Token | None = Field(None, alias="REGISTER")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class PasswordChallenge(CamelModel):
|
|
52
|
+
"""Запрос дополнительной проверки паролем.
|
|
53
|
+
|
|
54
|
+
:ivar track_id: ID проверки.
|
|
55
|
+
:vartype track_id: str
|
|
56
|
+
:ivar hint: Подсказка пароля.
|
|
57
|
+
:vartype hint: str | None
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
track_id: str
|
|
61
|
+
hint: str | None = None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class CheckCodeResponse(CamelModel):
|
|
65
|
+
"""Ответ на проверку кода подтверждения.
|
|
66
|
+
|
|
67
|
+
:ivar token_attrs: Токены, доступные после проверки.
|
|
68
|
+
:vartype token_attrs: TokenAttrs
|
|
69
|
+
:ivar password_challenge: Данные проверки паролем, если она нужна.
|
|
70
|
+
:vartype password_challenge: PasswordChallenge | None
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
token_attrs: TokenAttrs = Field(default_factory=TokenAttrs)
|
|
74
|
+
password_challenge: PasswordChallenge | None = None
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def login_token(self) -> str | None:
|
|
78
|
+
"""Возвращает токен входа.
|
|
79
|
+
|
|
80
|
+
:returns: Токен входа или ``None``, если сервер его не вернул.
|
|
81
|
+
:rtype: str | None
|
|
82
|
+
"""
|
|
83
|
+
return self.token_attrs.login.token if self.token_attrs.login else None
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def register_token(self) -> str | None:
|
|
87
|
+
"""Возвращает токен регистрации.
|
|
88
|
+
|
|
89
|
+
:returns: Токен регистрации или ``None``, если сервер его не вернул.
|
|
90
|
+
:rtype: str | None
|
|
91
|
+
"""
|
|
92
|
+
if not self.token_attrs.register_token:
|
|
93
|
+
return None
|
|
94
|
+
return self.token_attrs.register_token.token
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class CheckPasswordResponse(CamelModel):
|
|
98
|
+
"""Ответ на проверку пароля.
|
|
99
|
+
|
|
100
|
+
:ivar token_attrs: Токены, доступные после проверки.
|
|
101
|
+
:vartype token_attrs: TokenAttrs
|
|
102
|
+
:ivar error: Ошибка проверки.
|
|
103
|
+
:vartype error: str | None
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
token_attrs: TokenAttrs = Field(default_factory=TokenAttrs)
|
|
107
|
+
error: str | None = None
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def login_token(self) -> str | None:
|
|
111
|
+
"""Возвращает токен входа.
|
|
112
|
+
|
|
113
|
+
:returns: Токен входа или ``None``, если сервер его не вернул.
|
|
114
|
+
:rtype: str | None
|
|
115
|
+
"""
|
|
116
|
+
return self.token_attrs.login.token if self.token_attrs.login else None
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class RequestQrResponse(CamelModel):
|
|
120
|
+
"""Ответ на запрос QR-авторизации.
|
|
121
|
+
|
|
122
|
+
:ivar expires_at: Время истечения QR-кода в формате Unix time.
|
|
123
|
+
:vartype expires_at: int
|
|
124
|
+
:ivar polling_interval: Интервал проверки статуса.
|
|
125
|
+
:vartype polling_interval: int
|
|
126
|
+
:ivar qr_link: Ссылка для QR-кода.
|
|
127
|
+
:vartype qr_link: str
|
|
128
|
+
:ivar track_id: ID QR-авторизации.
|
|
129
|
+
:vartype track_id: str
|
|
130
|
+
:ivar ttl: Время жизни QR-кода.
|
|
131
|
+
:vartype ttl: int
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
expires_at: int
|
|
135
|
+
polling_interval: int
|
|
136
|
+
qr_link: str
|
|
137
|
+
track_id: str
|
|
138
|
+
ttl: int
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class QrStatus(CamelModel):
|
|
142
|
+
"""Статус QR-авторизации.
|
|
143
|
+
|
|
144
|
+
:ivar expires_at: Время истечения QR-кода в формате Unix time.
|
|
145
|
+
:vartype expires_at: int
|
|
146
|
+
:ivar login_available: Доступен ли вход.
|
|
147
|
+
:vartype login_available: bool | None
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
expires_at: int
|
|
151
|
+
login_available: bool | None = None
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
class CheckQrResponse(CamelModel):
|
|
155
|
+
"""Ответ на проверку статуса QR-авторизации.
|
|
156
|
+
|
|
157
|
+
:ivar status: Статус QR-авторизации.
|
|
158
|
+
:vartype status: QrStatus
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
status: QrStatus
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from pydantic import BaseModel, ConfigDict
|
|
2
|
+
from pydantic.alias_generators import to_camel
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class CamelModel(BaseModel):
|
|
6
|
+
"""Базовая модель с поддержкой camelCase alias-имен.
|
|
7
|
+
|
|
8
|
+
Модель разрешает заполнение полей как по Python-именам, так и по alias,
|
|
9
|
+
автоматически строит camelCase alias и допускает дополнительные поля.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
model_config = ConfigDict(
|
|
13
|
+
alias_generator=to_camel,
|
|
14
|
+
populate_by_name=True,
|
|
15
|
+
arbitrary_types_allowed=True,
|
|
16
|
+
extra="allow",
|
|
17
|
+
)
|