"""Pricing query handlers — Phase 10.4."""
from __future__ import annotations

from uuid import UUID

from sqlalchemy.ext.asyncio import AsyncSession

from app.services.pricing import BundleService, CapabilityService, PricingRuleService
from app.specifications.pricing import (
    BundleListSpec,
    CapabilityListSpec,
    PricingRuleListSpec,
)


class PricingQueries:
    def __init__(self, session: AsyncSession) -> None:
        self.rules = PricingRuleService(session)
        self.capabilities = CapabilityService(session)
        self.bundles = BundleService(session)

    async def get_rule(self, tenant_id: UUID, rule_id: UUID):
        return await self.rules.get(tenant_id, rule_id)

    async def list_rules(
        self, tenant_id: UUID, *, offset: int, limit: int, spec: PricingRuleListSpec | None
    ):
        return await self.rules.list(tenant_id, offset=offset, limit=limit, spec=spec)

    async def get_capability(self, tenant_id: UUID, cap_id: UUID):
        return await self.capabilities.get(tenant_id, cap_id)

    async def list_capabilities(
        self, tenant_id: UUID, *, offset: int, limit: int, spec: CapabilityListSpec | None
    ):
        return await self.capabilities.list(tenant_id, offset=offset, limit=limit, spec=spec)

    async def get_bundle(self, tenant_id: UUID, bundle_id: UUID):
        return await self.bundles.get(tenant_id, bundle_id)

    async def list_bundles(
        self, tenant_id: UUID, *, offset: int, limit: int, spec: BundleListSpec | None
    ):
        return await self.bundles.list(tenant_id, offset=offset, limit=limit, spec=spec)
