# This file was auto-generated by Fern from our API Definition.

import typing

import httpx

from .http_client import AsyncHttpClient, HttpClient


class BaseClientWrapper:
    def __init__(
        self,
        *,
        authorization: typing.Optional[str] = None,
        index_id: typing.Optional[str] = None,
        api_key: typing.Union[str, typing.Callable[[], str]],
        base_url: str,
        timeout: typing.Optional[float] = None,
    ):
        self._authorization = authorization
        self._index_id = index_id
        self._api_key = api_key
        self._base_url = base_url
        self._timeout = timeout

    def get_headers(self) -> typing.Dict[str, str]:
        headers: typing.Dict[str, str] = {
            "X-Fern-Language": "Python",
            "X-Fern-SDK-Name": "mixpeek",
            "X-Fern-SDK-Version": "0.6.7",
        }
        if self._authorization is not None:
            headers["Authorization"] = self._authorization
        if self._index_id is not None:
            headers["index-id"] = self._index_id
        headers["Authorization"] = f"Bearer {self._get_api_key()}"
        return headers

    def _get_api_key(self) -> str:
        if isinstance(self._api_key, str):
            return self._api_key
        else:
            return self._api_key()

    def get_base_url(self) -> str:
        return self._base_url

    def get_timeout(self) -> typing.Optional[float]:
        return self._timeout


class SyncClientWrapper(BaseClientWrapper):
    def __init__(
        self,
        *,
        authorization: typing.Optional[str] = None,
        index_id: typing.Optional[str] = None,
        api_key: typing.Union[str, typing.Callable[[], str]],
        base_url: str,
        timeout: typing.Optional[float] = None,
        httpx_client: httpx.Client,
    ):
        super().__init__(
            authorization=authorization, index_id=index_id, api_key=api_key, base_url=base_url, timeout=timeout
        )
        self.httpx_client = HttpClient(httpx_client=httpx_client)


class AsyncClientWrapper(BaseClientWrapper):
    def __init__(
        self,
        *,
        authorization: typing.Optional[str] = None,
        index_id: typing.Optional[str] = None,
        api_key: typing.Union[str, typing.Callable[[], str]],
        base_url: str,
        timeout: typing.Optional[float] = None,
        httpx_client: httpx.AsyncClient,
    ):
        super().__init__(
            authorization=authorization, index_id=index_id, api_key=api_key, base_url=base_url, timeout=timeout
        )
        self.httpx_client = AsyncHttpClient(httpx_client=httpx_client)
