from __future__ import annotations

from urllib.parse import quote
from uuid import UUID

from .base import SubclientBase
from ..schemas import CatalogItemTypeResponse


class CatalogClient(SubclientBase):
    async def map_item_type(self, key: str) -> CatalogItemTypeResponse:
        if not key:
            raise ValueError("Path key must be a non-empty string")
        response = await self._client.get(
            self._client.path(f"/catalog/item-types/path/{quote(key)}")
        )
        return self._client.parse(response, CatalogItemTypeResponse)

    async def map_item_type_id(self, key: str) -> UUID:
        response = await self.map_item_type(key)
        return response.item_type_id
