feat: add upload docs endpoint

This commit is contained in:
2026-06-25 23:09:58 +03:00
parent e85889eff8
commit bf8d778a9f
5 changed files with 33 additions and 7 deletions

View File

@@ -10,3 +10,6 @@ from src.application.commands.purchase_request_commands import (
GetPurchaseRequestCommand,
ListPurchaseRequestsCommand,
)
from src.application.commands.upload_docs_button import (
UploadDocsCommand,
)

View File

@@ -22,11 +22,9 @@ class UploadDocsCommand:
@transactional
async def __call__(
self,
user_id: str,
*,
comment: str | None = None,
) -> None:
legal_entity = await require_legal_entity(user_id, self._unit_of_work)
message_id = str(ULID())
now = datetime.now(timezone.utc).isoformat()
metadata = {
@@ -34,15 +32,13 @@ class UploadDocsCommand:
'timestamp': now,
'message_id': message_id,
}
payload = {
'id_client': legal_entity.id,
}
payload = {}
message = {
'event': 'docs_upload',
'payload': payload,
'metadata': metadata,
}
self._logger.info(f'Upload docs for organization_id={legal_entity.id}')
self._logger.info(f'New client uploaded docs, sending notification to telegram')
try:
await self._messanger.publish_to_queue(
queue=settings.RABBIT_TELEGRAM_NOTIFY_QUEUE,

View File

@@ -9,6 +9,7 @@ from src.application.commands import (
GetPurchaseRequestCommand,
ListOrganizationWalletsCommand,
ListPurchaseRequestsCommand,
UploadDocsCommand,
)
from src.application.contracts import ILogger, IQueueMessanger
from src.infrastructure.wallet_balances import WalletBalanceService
@@ -76,3 +77,10 @@ def get_get_organization_secret_keys_command(
unit_of_work: IUnitOfWork = Depends(get_unit_of_work),
) -> GetOrganizationSecretKeysCommand:
return GetOrganizationSecretKeysCommand(unit_of_work=unit_of_work, logger=logger)
def get_upload_docs_command(
logger: ILogger = Depends(get_logger),
unit_of_work: IUnitOfWork = Depends(get_unit_of_work),
messanger: IQueueMessanger = Depends(get_queue_messanger),
) -> UploadDocsCommand:
return UploadDocsCommand(unit_of_work=unit_of_work, logger=logger, messanger=messanger)

View File

@@ -2,8 +2,10 @@ from fastapi import APIRouter
from src.presentation.routing.organizations import organizations_router
from src.presentation.routing.purchase_requests import purchase_requests_router
from src.presentation.routing.documents import upload_docs_router
v1_router = APIRouter(prefix='/v1')
v1_router.include_router(organizations_router)
v1_router.include_router(upload_docs_router)
__all__ = ['purchase_requests_router', 'organizations_router', 'v1_router']
__all__ = ['purchase_requests_router', 'organizations_router', 'upload_docs_router', 'v1_router']

View File

@@ -0,0 +1,17 @@
from fastapi import APIRouter, Depends
from src.application.commands import (
UploadDocsCommand,
)
from src.presentation.dependencies.commands import (
get_upload_docs_command,
)
upload_docs_router = APIRouter(prefix='/upload-docs', tags=['upload-docs'])
@upload_docs_router.post('')
async def upload_docs(
command: UploadDocsCommand = Depends(get_upload_docs_command),
):
await command()
return {'message': 'Documents uploaded successfully.'}