# 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 AsyncRawOauthClient, RawOauthClient
from .types.post_oauth_token_response import PostOauthTokenResponse

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


class OauthClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawOauthClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawOauthClient
        """
        return self._raw_client

    def post_oauth_token(
        self,
        *,
        client_id: str,
        client_secret: str,
        scope: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostOauthTokenResponse:
        """
        Exchange credentials for an access token. Supports `client_credentials` grant type.

        Parameters
        ----------
        client_id : str
            The client ID issued to the client.

        client_secret : str
            The client secret issued to the client.

        scope : typing.Optional[str]
            The scope of the access request.

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

        Returns
        -------
        PostOauthTokenResponse
            Successful token response

        Examples
        --------
        from ottimate import Ottimate

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.oauth.post_oauth_token(
            client_id="example_client_id",
            client_secret="example_client_secret",
        )
        """
        _response = self._raw_client.post_oauth_token(
            client_id=client_id, client_secret=client_secret, scope=scope, request_options=request_options
        )
        return _response.data


class AsyncOauthClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawOauthClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawOauthClient
        """
        return self._raw_client

    async def post_oauth_token(
        self,
        *,
        client_id: str,
        client_secret: str,
        scope: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostOauthTokenResponse:
        """
        Exchange credentials for an access token. Supports `client_credentials` grant type.

        Parameters
        ----------
        client_id : str
            The client ID issued to the client.

        client_secret : str
            The client secret issued to the client.

        scope : typing.Optional[str]
            The scope of the access request.

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

        Returns
        -------
        PostOauthTokenResponse
            Successful token response

        Examples
        --------
        import asyncio

        from ottimate import AsyncOttimate

        client = AsyncOttimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.oauth.post_oauth_token(
                client_id="example_client_id",
                client_secret="example_client_secret",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.post_oauth_token(
            client_id=client_id, client_secret=client_secret, scope=scope, request_options=request_options
        )
        return _response.data
