service_man/api/application/usecase/company/create_company.py

21 lines
823 B
Python
Raw Normal View History

from api.application.abstractions.transaction import TransactionContextManager
2024-04-21 23:46:17 +03:00
from api.application.contracts.company.company_request import CreateNewCompany
from api.application.contracts.company.company_response import \
CompanyBaseResponse
2024-04-21 23:46:17 +03:00
from api.domain.company.repository import CompanyRepository
class CreateCompany:
def __init__(
self,
transaction: TransactionContextManager,
company_repository: CompanyRepository,
) -> None:
2024-04-21 23:46:17 +03:00
self.company_repository = company_repository
self.transaction = transaction
2024-04-21 23:46:17 +03:00
async def execute(self, request: CreateNewCompany) -> CompanyBaseResponse:
async with self.transaction as tr:
# companies = await self.company_repository.
return CompanyBaseResponse(name=request.name, email=request.email)