# Generated by smithplates HTTP codegen. Do not edit.

from __future__ import annotations

from urllib.parse import quote

import httpx
from pydantic import Field  # noqa: F401

from generated.petstore.api.category_not_found import CategoryNotFound
from generated.petstore.api.get_category_output import GetCategoryOutput
from generated.petstore.api.petstore.client.client_response import parse_client_response
from generated.petstore.api.petstore.client.operation_bindings import OPERATION_HTTP_BINDINGS


def _encode_path_label(value: object, *, greedy: bool = False) -> str:
    return quote(str(value), safe="/" if greedy else "")


class CategoriesApiClient:
    def __init__(self, client: httpx.AsyncClient, base_url: str) -> None:
        self._client = client
        self._base_url = base_url.rstrip("/")

    async def get_category(
        self,
        category_id: str,
    ) -> GetCategoryOutput | CategoryNotFound:
        headers: dict[str, str] | None = None
        _encoded_category_id = _encode_path_label(category_id)
        request_url = f"{self._base_url}/categories/{_encoded_category_id}"
        response = await self._client.request(
            "GET",
            request_url,
            headers=headers,
        )
        return parse_client_response(
            response,
            OPERATION_HTTP_BINDINGS["get_category"],
        )
