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

import typing
from ..core.client_wrapper import SyncClientWrapper
from .raw_client import RawTeamClient
from ..core.request_options import RequestOptions
from ..types.list_jobs_response import ListJobsResponse
from ..requests.job import JobParams
from ..types.create_job_response import CreateJobResponse
from ..types.retrieve_job_response import RetrieveJobResponse
from ..types.update_job_response import UpdateJobResponse
from ..core.client_wrapper import AsyncClientWrapper
from .raw_client import AsyncRawTeamClient

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


class TeamClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawTeamClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawTeamClient
        """
        return self._raw_client

    def list_jobs(
        self, *, cursor: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> ListJobsResponse:
        """
        Lists jobs in a seller account. Results are sorted by title in ascending order.

        Parameters
        ----------
        cursor : typing.Optional[str]
            The pagination cursor returned by the previous call to this endpoint. Provide this
            cursor to retrieve the next page of results for your original request. For more information,
            see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).

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

        Returns
        -------
        ListJobsResponse
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        client.team.list_jobs()
        """
        response = self._raw_client.list_jobs(cursor=cursor, request_options=request_options)
        return response.data

    def create_job(
        self, *, job: JobParams, idempotency_key: str, request_options: typing.Optional[RequestOptions] = None
    ) -> CreateJobResponse:
        """
        Creates a job in a seller account. A job defines a title and tip eligibility. Note that
        compensation is defined in a [job assignment](entity:JobAssignment) in a team member's wage setting.

        Parameters
        ----------
        job : JobParams
            The job to create. The `title` field is required and `is_tip_eligible` defaults to true.

        idempotency_key : str
            A unique identifier for the `CreateJob` request. Keys can be any valid string,
            but must be unique for each request. For more information, see
            [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).

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

        Returns
        -------
        CreateJobResponse
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        client.team.create_job(
            job={"title": "Cashier", "is_tip_eligible": True},
            idempotency_key="idempotency-key-0",
        )
        """
        response = self._raw_client.create_job(
            job=job, idempotency_key=idempotency_key, request_options=request_options
        )
        return response.data

    def retrieve_job(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> RetrieveJobResponse:
        """
        Retrieves a specified job.

        Parameters
        ----------
        job_id : str
            The ID of the job to retrieve.

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

        Returns
        -------
        RetrieveJobResponse
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        client.team.retrieve_job(
            job_id="job_id",
        )
        """
        response = self._raw_client.retrieve_job(job_id, request_options=request_options)
        return response.data

    def update_job(
        self, job_id: str, *, job: JobParams, request_options: typing.Optional[RequestOptions] = None
    ) -> UpdateJobResponse:
        """
        Updates the title or tip eligibility of a job. Changes to the title propagate to all
        `JobAssignment`, `Shift`, and `TeamMemberWage` objects that reference the job ID. Changes to
        tip eligibility propagate to all `TeamMemberWage` objects that reference the job ID.

        Parameters
        ----------
        job_id : str
            The ID of the job to update.

        job : JobParams
            The job with the updated fields, either `title`, `is_tip_eligible`, or both. Only changed fields need
            to be included in the request. Optionally include `version` to enable optimistic concurrency control.

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

        Returns
        -------
        UpdateJobResponse
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        client.team.update_job(
            job_id="job_id",
            job={"title": "Cashier 1", "is_tip_eligible": True},
        )
        """
        response = self._raw_client.update_job(job_id, job=job, request_options=request_options)
        return response.data


class AsyncTeamClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawTeamClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawTeamClient
        """
        return self._raw_client

    async def list_jobs(
        self, *, cursor: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> ListJobsResponse:
        """
        Lists jobs in a seller account. Results are sorted by title in ascending order.

        Parameters
        ----------
        cursor : typing.Optional[str]
            The pagination cursor returned by the previous call to this endpoint. Provide this
            cursor to retrieve the next page of results for your original request. For more information,
            see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).

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

        Returns
        -------
        ListJobsResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.team.list_jobs()


        asyncio.run(main())
        """
        response = await self._raw_client.list_jobs(cursor=cursor, request_options=request_options)
        return response.data

    async def create_job(
        self, *, job: JobParams, idempotency_key: str, request_options: typing.Optional[RequestOptions] = None
    ) -> CreateJobResponse:
        """
        Creates a job in a seller account. A job defines a title and tip eligibility. Note that
        compensation is defined in a [job assignment](entity:JobAssignment) in a team member's wage setting.

        Parameters
        ----------
        job : JobParams
            The job to create. The `title` field is required and `is_tip_eligible` defaults to true.

        idempotency_key : str
            A unique identifier for the `CreateJob` request. Keys can be any valid string,
            but must be unique for each request. For more information, see
            [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).

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

        Returns
        -------
        CreateJobResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.team.create_job(
                job={"title": "Cashier", "is_tip_eligible": True},
                idempotency_key="idempotency-key-0",
            )


        asyncio.run(main())
        """
        response = await self._raw_client.create_job(
            job=job, idempotency_key=idempotency_key, request_options=request_options
        )
        return response.data

    async def retrieve_job(
        self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> RetrieveJobResponse:
        """
        Retrieves a specified job.

        Parameters
        ----------
        job_id : str
            The ID of the job to retrieve.

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

        Returns
        -------
        RetrieveJobResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.team.retrieve_job(
                job_id="job_id",
            )


        asyncio.run(main())
        """
        response = await self._raw_client.retrieve_job(job_id, request_options=request_options)
        return response.data

    async def update_job(
        self, job_id: str, *, job: JobParams, request_options: typing.Optional[RequestOptions] = None
    ) -> UpdateJobResponse:
        """
        Updates the title or tip eligibility of a job. Changes to the title propagate to all
        `JobAssignment`, `Shift`, and `TeamMemberWage` objects that reference the job ID. Changes to
        tip eligibility propagate to all `TeamMemberWage` objects that reference the job ID.

        Parameters
        ----------
        job_id : str
            The ID of the job to update.

        job : JobParams
            The job with the updated fields, either `title`, `is_tip_eligible`, or both. Only changed fields need
            to be included in the request. Optionally include `version` to enable optimistic concurrency control.

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

        Returns
        -------
        UpdateJobResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.team.update_job(
                job_id="job_id",
                job={"title": "Cashier 1", "is_tip_eligible": True},
            )


        asyncio.run(main())
        """
        response = await self._raw_client.update_job(job_id, job=job, request_options=request_options)
        return response.data
