fix cdek client

This commit is contained in:
Раис Юсупалиев
2026-03-08 23:35:04 +03:00
parent f799f2ba03
commit 2d68aff34d
7 changed files with 105 additions and 8 deletions
+13 -1
View File
@@ -8,7 +8,11 @@ from app.controllers.http_client import build_controller_http_client
from app.repositories.cache.redis_cache import PriceCache
from app.schemas.request import DeliveryRequest
from app.schemas.response import DeliveryPrice
from app.services.aggregator import AggregatorService, AggregatorServiceError
from app.services.aggregator import (
AggregatorService,
AggregatorServiceError,
InvalidDeliveryRequestError,
)
router = APIRouter(prefix="/delivery", tags=["delivery"])
@@ -56,6 +60,14 @@ async def get_delivery_price(
) -> list[DeliveryPrice]:
try:
return await service.get_all_prices(delivery_request)
except InvalidDeliveryRequestError as exc:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail={
"code": "invalid_delivery_request",
"message": "Delivery request contains unknown or unsupported location.",
},
) from exc
except AggregatorServiceError as exc:
raise HTTPException(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,