"""
Base resource class for API endpoints.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Generic, TypeVar

from pydantic import BaseModel

if TYPE_CHECKING:
    from ..client.base import BaseClient

T = TypeVar("T", bound=BaseModel)


class BaseResource(Generic[T]):
    """
    Base class for API resources.

    Provides access to the HTTP client and common patterns
    for API resource implementations.
    """

    def __init__(self, client: "BaseClient") -> None:
        """
        Initialize the resource.

        Args:
            client: The Late API client instance
        """
        self._client = client

    def _build_params(self, **kwargs: Any) -> dict[str, Any]:
        """
        Build query parameters, filtering out None values.

        Args:
            **kwargs: Parameter key-value pairs

        Returns:
            Dictionary with non-None values
        """
        return {k: v for k, v in kwargs.items() if v is not None}
