"""Base interface for delivery providers.""" from abc import ABC, abstractmethod from typing import Protocol, runtime_checkable from app.schemas.payment import InitPaymentRequest from app.schemas.request import DeliveryCalculationRequest from app.schemas.response import DeliveryPrice class DeliveryProvider(ABC): name: str @abstractmethod async def get_prices( self, request: DeliveryCalculationRequest ) -> list[DeliveryPrice]: """Fetch provider tariffs for a delivery request.""" raise NotImplementedError @runtime_checkable class PaymentPriceValidationProvider(Protocol): name: str async def get_payment_price( self, request: InitPaymentRequest, ) -> DeliveryPrice | None: ... @runtime_checkable class OrderRegistrationProvider(Protocol): name: str async def register_order( self, request: InitPaymentRequest, order_uuid: str, ) -> object: ... class ProviderClientError(RuntimeError): """Raised when a provider call fails for temporary or provider-side reasons.""" class ProviderRequestError(RuntimeError): """Raised when a provider rejects input request data."""