# 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 AsyncRawAccountsClient, RawAccountsClient
from .types.get_accounts_id_companies_response import GetAccountsIdCompaniesResponse
from .types.get_accounts_id_locations_response import GetAccountsIdLocationsResponse
from .types.get_accounts_root_response import GetAccountsRootResponse


class AccountsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAccountsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawAccountsClient
        """
        return self._raw_client

    def get_accounts_root(
        self,
        *,
        search: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        page: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetAccountsRootResponse:
        """
        Returns a paginated list of Ottimate accounts that the authenticated user has access to, based on partner associations linked to the OAuth client credentials.

        Parameters
        ----------
        search : typing.Optional[str]
            Search term to filter accounts by name

        limit : typing.Optional[int]
            Number of items per page

        page : typing.Optional[int]
            Page number for pagination

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

        Returns
        -------
        GetAccountsRootResponse
            Successful response with paginated account list

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

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.accounts.get_accounts_root(
            limit=50,
            page=0,
        )
        """
        _response = self._raw_client.get_accounts_root(
            search=search, limit=limit, page=page, request_options=request_options
        )
        return _response.data

    def get_accounts_id_companies(
        self,
        id: str,
        *,
        search: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        page: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetAccountsIdCompaniesResponse:
        """
        Returns a paginated list of companies associated with the specified account.

        Parameters
        ----------
        id : str
            Account ID

        search : typing.Optional[str]
            Search term for company name

        limit : typing.Optional[int]
            Number of items per page

        page : typing.Optional[int]
            Page number for pagination

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

        Returns
        -------
        GetAccountsIdCompaniesResponse
            Successful response with paginated company list

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

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.accounts.get_accounts_id_companies(
            id="racc_90832490382904802384",
            limit=50,
            page=0,
        )
        """
        _response = self._raw_client.get_accounts_id_companies(
            id, search=search, limit=limit, page=page, request_options=request_options
        )
        return _response.data

    def get_accounts_id_locations(
        self,
        id: str,
        *,
        search: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        page: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetAccountsIdLocationsResponse:
        """
        Returns a paginated list of locations associated with the specified account.

        Parameters
        ----------
        id : str
            Account ID

        search : typing.Optional[str]
            Search term for location name

        limit : typing.Optional[int]
            Number of items per page

        page : typing.Optional[int]
            Page number for pagination

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

        Returns
        -------
        GetAccountsIdLocationsResponse
            Successful response with paginated location list

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

        client = Ottimate(
            api_key="YOUR_API_KEY",
            api_version="YOUR_API_VERSION",
            api_key="YOUR_API_KEY",
        )
        client.accounts.get_accounts_id_locations(
            id="racc_90832490382904802384",
            limit=50,
            page=0,
        )
        """
        _response = self._raw_client.get_accounts_id_locations(
            id, search=search, limit=limit, page=page, request_options=request_options
        )
        return _response.data


class AsyncAccountsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAccountsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawAccountsClient
        """
        return self._raw_client

    async def get_accounts_root(
        self,
        *,
        search: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        page: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetAccountsRootResponse:
        """
        Returns a paginated list of Ottimate accounts that the authenticated user has access to, based on partner associations linked to the OAuth client credentials.

        Parameters
        ----------
        search : typing.Optional[str]
            Search term to filter accounts by name

        limit : typing.Optional[int]
            Number of items per page

        page : typing.Optional[int]
            Page number for pagination

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

        Returns
        -------
        GetAccountsRootResponse
            Successful response with paginated account list

        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.accounts.get_accounts_root(
                limit=50,
                page=0,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_accounts_root(
            search=search, limit=limit, page=page, request_options=request_options
        )
        return _response.data

    async def get_accounts_id_companies(
        self,
        id: str,
        *,
        search: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        page: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetAccountsIdCompaniesResponse:
        """
        Returns a paginated list of companies associated with the specified account.

        Parameters
        ----------
        id : str
            Account ID

        search : typing.Optional[str]
            Search term for company name

        limit : typing.Optional[int]
            Number of items per page

        page : typing.Optional[int]
            Page number for pagination

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

        Returns
        -------
        GetAccountsIdCompaniesResponse
            Successful response with paginated company list

        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.accounts.get_accounts_id_companies(
                id="racc_90832490382904802384",
                limit=50,
                page=0,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_accounts_id_companies(
            id, search=search, limit=limit, page=page, request_options=request_options
        )
        return _response.data

    async def get_accounts_id_locations(
        self,
        id: str,
        *,
        search: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        page: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetAccountsIdLocationsResponse:
        """
        Returns a paginated list of locations associated with the specified account.

        Parameters
        ----------
        id : str
            Account ID

        search : typing.Optional[str]
            Search term for location name

        limit : typing.Optional[int]
            Number of items per page

        page : typing.Optional[int]
            Page number for pagination

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

        Returns
        -------
        GetAccountsIdLocationsResponse
            Successful response with paginated location list

        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.accounts.get_accounts_id_locations(
                id="racc_90832490382904802384",
                limit=50,
                page=0,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_accounts_id_locations(
            id, search=search, limit=limit, page=page, request_options=request_options
        )
        return _response.data
