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

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from .raw_client import AsyncRawLinkClient, RawLinkClient
from .types.link_response import LinkResponse
from .types.site import Site

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class LinkClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawLinkClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawLinkClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawLinkClient
        """
        return self._raw_client

    def extract(self, *, url: str, request_options: typing.Optional[RequestOptions] = None) -> LinkResponse:
        """
        Parameters
        ----------
        url : str
            URL to extract a downloadable link from. This link must originate from a supported site. You can use the get supported sites endpoint to get a list of supported sites.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        LinkResponse

        Examples
        --------
        from soferai import SoferAI

        client = SoferAI(
            api_key="YOUR_API_KEY",
        )
        client.link.extract(
            url="url",
        )
        """
        _response = self._raw_client.extract(url=url, request_options=request_options)
        return _response.data

    def get_supported_sites(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Site]:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[Site]

        Examples
        --------
        from soferai import SoferAI

        client = SoferAI(
            api_key="YOUR_API_KEY",
        )
        client.link.get_supported_sites()
        """
        _response = self._raw_client.get_supported_sites(request_options=request_options)
        return _response.data


class AsyncLinkClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawLinkClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawLinkClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawLinkClient
        """
        return self._raw_client

    async def extract(self, *, url: str, request_options: typing.Optional[RequestOptions] = None) -> LinkResponse:
        """
        Parameters
        ----------
        url : str
            URL to extract a downloadable link from. This link must originate from a supported site. You can use the get supported sites endpoint to get a list of supported sites.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        LinkResponse

        Examples
        --------
        import asyncio

        from soferai import AsyncSoferAI

        client = AsyncSoferAI(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.link.extract(
                url="url",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.extract(url=url, request_options=request_options)
        return _response.data

    async def get_supported_sites(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[Site]:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[Site]

        Examples
        --------
        import asyncio

        from soferai import AsyncSoferAI

        client = AsyncSoferAI(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.link.get_supported_sites()


        asyncio.run(main())
        """
        _response = await self._raw_client.get_supported_sites(request_options=request_options)
        return _response.data
