# 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 ..types.channel import Channel
from ..types.integration import Integration
from .raw_client import AsyncRawIntegrationsClient, RawIntegrationsClient


class IntegrationsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawIntegrationsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawIntegrationsClient
        """
        return self._raw_client

    def list(
        self,
        service: str,
        *,
        fetch_icons: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Integration]:
        """
        List all OAuth integrations for the organization

        If service is 'all', returns integrations for all services.

        Parameters
        ----------
        service : str

        fetch_icons : typing.Optional[bool]

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

        Returns
        -------
        typing.List[Integration]
            Successful Response

        Examples
        --------
        from scoutos import Scout

        client = Scout(
            api_key="YOUR_API_KEY",
        )
        client.integrations.list(
            service="service",
        )
        """
        _response = self._raw_client.list(service, fetch_icons=fetch_icons, request_options=request_options)
        return _response.data

    def list_channels(
        self, team_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[Channel]:
        """
        List all channels for a specific Slack workspace

        Parameters
        ----------
        team_id : str

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

        Returns
        -------
        typing.List[Channel]
            Successful Response

        Examples
        --------
        from scoutos import Scout

        client = Scout(
            api_key="YOUR_API_KEY",
        )
        client.integrations.list_channels(
            team_id="team_id",
        )
        """
        _response = self._raw_client.list_channels(team_id, request_options=request_options)
        return _response.data


class AsyncIntegrationsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawIntegrationsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawIntegrationsClient
        """
        return self._raw_client

    async def list(
        self,
        service: str,
        *,
        fetch_icons: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Integration]:
        """
        List all OAuth integrations for the organization

        If service is 'all', returns integrations for all services.

        Parameters
        ----------
        service : str

        fetch_icons : typing.Optional[bool]

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

        Returns
        -------
        typing.List[Integration]
            Successful Response

        Examples
        --------
        import asyncio

        from scoutos import AsyncScout

        client = AsyncScout(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.integrations.list(
                service="service",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list(service, fetch_icons=fetch_icons, request_options=request_options)
        return _response.data

    async def list_channels(
        self, team_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[Channel]:
        """
        List all channels for a specific Slack workspace

        Parameters
        ----------
        team_id : str

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

        Returns
        -------
        typing.List[Channel]
            Successful Response

        Examples
        --------
        import asyncio

        from scoutos import AsyncScout

        client = AsyncScout(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.integrations.list_channels(
                team_id="team_id",
            )


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