fix cdek client
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user