# 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 AsyncRawImdbClient, RawImdbClient
from .types.movie import Movie
from .types.movie_id import MovieId

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


class ImdbClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawImdbClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawImdbClient
        """
        return self._raw_client

    def create_movie(
        self, *, title: str, rating: float, request_options: typing.Optional[RequestOptions] = None
    ) -> MovieId:
        """
        Add a movie to the database

        Parameters
        ----------
        title : str

        rating : float

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

        Returns
        -------
        MovieId

        Examples
        --------
        from devintest import MyClientNameDevin

        client = MyClientNameDevin(
            base_url="https://yourhost.com/path/to/api",
        )
        client.imdb.create_movie(
            title="title",
            rating=1.1,
        )
        """
        _response = self._raw_client.create_movie(title=title, rating=rating, request_options=request_options)
        return _response.data

    def get_movie(self, id: MovieId, *, request_options: typing.Optional[RequestOptions] = None) -> Movie:
        """
        Retrieve a movie from the database based on the ID

        Parameters
        ----------
        id : MovieId

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

        Returns
        -------
        Movie

        Examples
        --------
        from devintest import MyClientNameDevin

        client = MyClientNameDevin(
            base_url="https://yourhost.com/path/to/api",
        )
        client.imdb.get_movie(
            id="tt0111161",
        )
        """
        _response = self._raw_client.get_movie(id, request_options=request_options)
        return _response.data


class AsyncImdbClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawImdbClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawImdbClient
        """
        return self._raw_client

    async def create_movie(
        self, *, title: str, rating: float, request_options: typing.Optional[RequestOptions] = None
    ) -> MovieId:
        """
        Add a movie to the database

        Parameters
        ----------
        title : str

        rating : float

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

        Returns
        -------
        MovieId

        Examples
        --------
        import asyncio

        from devintest import AsyncMyClientNameDevin

        client = AsyncMyClientNameDevin(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.imdb.create_movie(
                title="title",
                rating=1.1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_movie(title=title, rating=rating, request_options=request_options)
        return _response.data

    async def get_movie(self, id: MovieId, *, request_options: typing.Optional[RequestOptions] = None) -> Movie:
        """
        Retrieve a movie from the database based on the ID

        Parameters
        ----------
        id : MovieId

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

        Returns
        -------
        Movie

        Examples
        --------
        import asyncio

        from devintest import AsyncMyClientNameDevin

        client = AsyncMyClientNameDevin(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.imdb.get_movie(
                id="tt0111161",
            )


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