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

import typing

import httpx

from ..environment import OctoAIEnvironment
from .http_client import AsyncHttpClient, HttpClient


class BaseClientWrapper:
    def __init__(
        self,
        *,
        api_key: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
        environment: OctoAIEnvironment,
        timeout: typing.Optional[float] = None,
    ):
        self._api_key = api_key
        self._environment = environment
        self._timeout = timeout

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

    def _get_api_key(self) -> typing.Optional[str]:
        if isinstance(self._api_key, str) or self._api_key is None:
            return self._api_key
        else:
            return self._api_key()

    def get_environment(self) -> OctoAIEnvironment:
        return self._environment

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


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


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