feat: creatives and external channels
This commit is contained in:
@@ -1,3 +1,62 @@
|
||||
__all__ = ('GetUserInput', 'GetUserOutput')
|
||||
__all__ = (
|
||||
'UpdateTargetChanPermissionsInput',
|
||||
'GetUserTargetChansInput',
|
||||
'GetUserTargetChansOutput',
|
||||
'DisconnectTargetChanInput',
|
||||
'DisconnectTargetChanByTgIdInput',
|
||||
'ConnectTargetChanInput',
|
||||
'ConnectTargetChanOutput',
|
||||
'ValidateLoginTokenInput',
|
||||
'ValidateLoginTokenOutput',
|
||||
'TelegramLoginInput',
|
||||
'ChannelBotPermissions',
|
||||
'ExternalChannelOutput',
|
||||
'GetExternalChannelsInput',
|
||||
'GetExternalChannelsOutput',
|
||||
'CreateExternalChannelInput',
|
||||
'DeleteExternalChannelInput',
|
||||
'UpdateExternalChannelLinksInput',
|
||||
'ImportExternalChannelsInput',
|
||||
'ImportExternalChannelsOutput',
|
||||
'CreativeOutput',
|
||||
'GetCreativesInput',
|
||||
'GetCreativesOutput',
|
||||
'GetCreativeInput',
|
||||
'CreateCreativeInput',
|
||||
'UpdateCreativeInput',
|
||||
'ArchiveCreativeInput',
|
||||
'DeleteCreativeInput',
|
||||
)
|
||||
|
||||
from .get_user import GetUserInput, GetUserOutput
|
||||
from .creative import (
|
||||
ArchiveCreativeInput,
|
||||
CreateCreativeInput,
|
||||
CreativeOutput,
|
||||
DeleteCreativeInput,
|
||||
GetCreativeInput,
|
||||
GetCreativesInput,
|
||||
GetCreativesOutput,
|
||||
UpdateCreativeInput,
|
||||
)
|
||||
from .external_channel import (
|
||||
CreateExternalChannelInput,
|
||||
DeleteExternalChannelInput,
|
||||
ExternalChannelOutput,
|
||||
GetExternalChannelsInput,
|
||||
GetExternalChannelsOutput,
|
||||
ImportExternalChannelsInput,
|
||||
ImportExternalChannelsOutput,
|
||||
UpdateExternalChannelLinksInput,
|
||||
)
|
||||
from .target_channel import (
|
||||
ChannelBotPermissions,
|
||||
ConnectTargetChanInput,
|
||||
ConnectTargetChanOutput,
|
||||
DisconnectTargetChanByTgIdInput,
|
||||
DisconnectTargetChanInput,
|
||||
GetUserTargetChansInput,
|
||||
GetUserTargetChansOutput,
|
||||
UpdateTargetChanPermissionsInput,
|
||||
)
|
||||
from .telegram_login import TelegramLoginInput
|
||||
from .validate_login_token import ValidateLoginTokenInput, ValidateLoginTokenOutput
|
||||
|
||||
48
src/dto/creative.py
Normal file
48
src/dto/creative.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
import pydantic
|
||||
|
||||
from src import domain
|
||||
|
||||
|
||||
class CreativeOutput(pydantic.BaseModel):
|
||||
id: uuid.UUID
|
||||
name: str
|
||||
text: str
|
||||
target_channel_id: uuid.UUID
|
||||
target_channel_title: str
|
||||
created_at: datetime.datetime
|
||||
status: domain.CreativeStatus
|
||||
purchases_count: int
|
||||
|
||||
|
||||
class GetCreativesInput(pydantic.BaseModel):
|
||||
user_id: uuid.UUID
|
||||
target_channel_id: uuid.UUID | None = None
|
||||
include_archived: bool = False
|
||||
|
||||
|
||||
class GetCreativesOutput(pydantic.BaseModel):
|
||||
creatives: list[CreativeOutput]
|
||||
|
||||
|
||||
class GetCreativeInput(pydantic.BaseModel):
|
||||
creative_id: uuid.UUID
|
||||
user_id: uuid.UUID
|
||||
|
||||
|
||||
class CreateCreativeInput(pydantic.BaseModel):
|
||||
name: str
|
||||
text: str
|
||||
target_channel_id: uuid.UUID
|
||||
|
||||
|
||||
class UpdateCreativeInput(pydantic.BaseModel):
|
||||
name: str | None = None
|
||||
text: str | None = None
|
||||
|
||||
|
||||
class DeleteCreativeInput(pydantic.BaseModel):
|
||||
creative_id: uuid.UUID
|
||||
user_id: uuid.UUID
|
||||
54
src/dto/external_channel.py
Normal file
54
src/dto/external_channel.py
Normal file
@@ -0,0 +1,54 @@
|
||||
import uuid
|
||||
|
||||
import pydantic
|
||||
|
||||
|
||||
class ExternalChannelOutput(pydantic.BaseModel):
|
||||
id: uuid.UUID
|
||||
telegram_id: int
|
||||
title: str
|
||||
username: str | None
|
||||
description: str | None
|
||||
subscribers_count: int | None
|
||||
|
||||
|
||||
class GetExternalChannelsInput(pydantic.BaseModel):
|
||||
target_channel_id: uuid.UUID
|
||||
user_id: uuid.UUID
|
||||
|
||||
|
||||
class GetExternalChannelsOutput(pydantic.BaseModel):
|
||||
external_channels: list[ExternalChannelOutput]
|
||||
|
||||
|
||||
class CreateExternalChannelInput(pydantic.BaseModel):
|
||||
telegram_id: int
|
||||
title: str
|
||||
username: str | None = None
|
||||
description: str | None = None
|
||||
subscribers_count: int | None = None
|
||||
target_channel_ids: list[uuid.UUID]
|
||||
|
||||
|
||||
class DeleteExternalChannelInput(pydantic.BaseModel):
|
||||
channel_id: uuid.UUID
|
||||
user_id: uuid.UUID
|
||||
|
||||
|
||||
class UpdateExternalChannelLinksInput(pydantic.BaseModel):
|
||||
"""Request body for PATCH endpoint - links to add or remove."""
|
||||
|
||||
add_target_channel_ids: list[uuid.UUID] = []
|
||||
remove_target_channel_ids: list[uuid.UUID] = []
|
||||
|
||||
|
||||
class ImportExternalChannelsInput(pydantic.BaseModel):
|
||||
target_channel_id: uuid.UUID
|
||||
user_id: uuid.UUID
|
||||
file_content: bytes # Excel file content
|
||||
|
||||
|
||||
class ImportExternalChannelsOutput(pydantic.BaseModel):
|
||||
created_count: int
|
||||
skipped_count: int
|
||||
errors: list[str]
|
||||
@@ -1,12 +0,0 @@
|
||||
import uuid
|
||||
|
||||
import pydantic
|
||||
|
||||
|
||||
class GetUserInput(pydantic.BaseModel):
|
||||
user_id: uuid.UUID
|
||||
|
||||
|
||||
class GetUserOutput(pydantic.BaseModel):
|
||||
user_id: uuid.UUID
|
||||
name: str
|
||||
56
src/dto/target_channel.py
Normal file
56
src/dto/target_channel.py
Normal file
@@ -0,0 +1,56 @@
|
||||
import uuid
|
||||
|
||||
import pydantic
|
||||
|
||||
|
||||
class ChannelBotPermissions(pydantic.BaseModel):
|
||||
is_admin: bool
|
||||
can_invite_users: bool
|
||||
can_restrict_members: bool
|
||||
can_manage_chat: bool | None = None
|
||||
can_delete_messages: bool | None = None
|
||||
can_manage_video_chats: bool | None = None
|
||||
can_post_messages: bool | None = None
|
||||
can_edit_messages: bool | None = None
|
||||
can_pin_messages: bool | None = None
|
||||
|
||||
|
||||
class ConnectTargetChanInput(pydantic.BaseModel):
|
||||
telegram_id: int
|
||||
title: str
|
||||
username: str | None
|
||||
user_telegram_id: int
|
||||
bot_permissions: ChannelBotPermissions
|
||||
|
||||
|
||||
class ConnectTargetChanOutput(pydantic.BaseModel):
|
||||
id: uuid.UUID
|
||||
telegram_id: int
|
||||
title: str
|
||||
username: str | None
|
||||
is_active: bool
|
||||
|
||||
|
||||
class GetUserTargetChansInput(pydantic.BaseModel):
|
||||
user_id: uuid.UUID
|
||||
|
||||
|
||||
class GetUserTargetChansOutput(pydantic.BaseModel):
|
||||
target_channels: list[ConnectTargetChanOutput]
|
||||
|
||||
|
||||
class DisconnectTargetChanInput(pydantic.BaseModel):
|
||||
channel_id: uuid.UUID
|
||||
user_id: uuid.UUID
|
||||
|
||||
|
||||
class DisconnectTargetChanByTgIdInput(pydantic.BaseModel):
|
||||
telegram_id: int
|
||||
user_id: uuid.UUID
|
||||
|
||||
|
||||
class UpdateTargetChanPermissionsInput(pydantic.BaseModel):
|
||||
telegram_id: int
|
||||
permissions: ChannelBotPermissions
|
||||
chat_title: str
|
||||
user_telegram_id: int
|
||||
7
src/dto/telegram_login.py
Normal file
7
src/dto/telegram_login.py
Normal file
@@ -0,0 +1,7 @@
|
||||
import pydantic
|
||||
|
||||
|
||||
class TelegramLoginInput(pydantic.BaseModel):
|
||||
telegram_id: int
|
||||
username: str | None
|
||||
chat_id: int
|
||||
9
src/dto/validate_login_token.py
Normal file
9
src/dto/validate_login_token.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import pydantic
|
||||
|
||||
|
||||
class ValidateLoginTokenInput(pydantic.BaseModel):
|
||||
token: str
|
||||
|
||||
|
||||
class ValidateLoginTokenOutput(pydantic.BaseModel):
|
||||
access_token: str
|
||||
Reference in New Issue
Block a user