31 lines
956 B
Python
31 lines
956 B
Python
from typing import TYPE_CHECKING
|
|
|
|
from src import dto
|
|
|
|
if TYPE_CHECKING:
|
|
from .. import Usecase
|
|
|
|
|
|
async def get_creatives(self: 'Usecase', input: dto.GetCreativesInput) -> dto.GetCreativesOutput:
|
|
await self.ensure_workspace_access(input.workspace_id, input.user_id)
|
|
|
|
creatives = await self.database.get_workspace_creatives(
|
|
input.workspace_id, input.target_channel_id, input.include_archived
|
|
)
|
|
|
|
return dto.GetCreativesOutput(
|
|
creatives=[
|
|
dto.CreativeOutput(
|
|
id=creative.id,
|
|
name=creative.name,
|
|
text=creative.text,
|
|
target_channel_id=creative.target_channel_id,
|
|
target_channel_title=creative.target_channel.title,
|
|
created_at=creative.created_at,
|
|
status=creative.status,
|
|
placements_count=creative.placements_count,
|
|
)
|
|
for creative in creatives
|
|
]
|
|
)
|