feat: creatives and external channels
This commit is contained in:
29
src/usecase/creative/get_creatives.py
Normal file
29
src/usecase/creative/get_creatives.py
Normal file
@@ -0,0 +1,29 @@
|
||||
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:
|
||||
async with self.database.transaction():
|
||||
creatives = await self.database.get_user_creatives(
|
||||
input.user_id, target_channel_id=input.target_channel_id, include_archived=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,
|
||||
purchases_count=creative.purchases_count,
|
||||
)
|
||||
for creative in creatives
|
||||
]
|
||||
)
|
||||
Reference in New Issue
Block a user