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

import typing
from ...core.client_wrapper import SyncClientWrapper
from .raw_client import RawWageSettingClient
from ...core.request_options import RequestOptions
from ...types.get_wage_setting_response import GetWageSettingResponse
from ...requests.wage_setting import WageSettingParams
from ...types.update_wage_setting_response import UpdateWageSettingResponse
from ...core.client_wrapper import AsyncClientWrapper
from .raw_client import AsyncRawWageSettingClient

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


class WageSettingClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawWageSettingClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawWageSettingClient
        """
        return self._raw_client

    def get(
        self, team_member_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetWageSettingResponse:
        """
        Retrieves a `WageSetting` object for a team member specified
        by `TeamMember.id`. For more information, see
        [Troubleshooting the Team API](https://developer.squareup.com/docs/team/troubleshooting#retrievewagesetting).

        Square recommends using [RetrieveTeamMember](api-endpoint:Team-RetrieveTeamMember) or [SearchTeamMembers](api-endpoint:Team-SearchTeamMembers)
        to get this information directly from the `TeamMember.wage_setting` field.

        Parameters
        ----------
        team_member_id : str
            The ID of the team member for which to retrieve the wage setting.

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

        Returns
        -------
        GetWageSettingResponse
            Success

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

        client = Square(
            token="YOUR_TOKEN",
        )
        client.team_members.wage_setting.get(
            team_member_id="team_member_id",
        )
        """
        response = self._raw_client.get(team_member_id, request_options=request_options)
        return response.data

    def update(
        self,
        team_member_id: str,
        *,
        wage_setting: WageSettingParams,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateWageSettingResponse:
        """
        Creates or updates a `WageSetting` object. The object is created if a
        `WageSetting` with the specified `team_member_id` doesn't exist. Otherwise,
        it fully replaces the `WageSetting` object for the team member.
        The `WageSetting` is returned on a successful update. For more information, see
        [Troubleshooting the Team API](https://developer.squareup.com/docs/team/troubleshooting#create-or-update-a-wage-setting).

        Square recommends using [CreateTeamMember](api-endpoint:Team-CreateTeamMember) or [UpdateTeamMember](api-endpoint:Team-UpdateTeamMember)
        to manage the `TeamMember.wage_setting` field directly.

        Parameters
        ----------
        team_member_id : str
            The ID of the team member for which to update the `WageSetting` object.

        wage_setting : WageSettingParams
            The complete `WageSetting` object. For all job assignments, specify one of the following:
            - `job_id` (recommended) - If needed, call [ListJobs](api-endpoint:Team-ListJobs) to get a list of all jobs.
            Requires Square API version 2024-12-18 or later.
            - `job_title` - Use the exact, case-sensitive spelling of an existing title unless you want to create a new job.
            This value is ignored if `job_id` is also provided.

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

        Returns
        -------
        UpdateWageSettingResponse
            Success

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

        client = Square(
            token="YOUR_TOKEN",
        )
        client.team_members.wage_setting.update(
            team_member_id="team_member_id",
            wage_setting={
                "job_assignments": [
                    {
                        "job_title": "Manager",
                        "pay_type": "SALARY",
                        "annual_rate": {"amount": 3000000, "currency": "USD"},
                        "weekly_hours": 40,
                    },
                    {
                        "job_title": "Cashier",
                        "pay_type": "HOURLY",
                        "hourly_rate": {"amount": 2000, "currency": "USD"},
                    },
                ],
                "is_overtime_exempt": True,
            },
        )
        """
        response = self._raw_client.update(team_member_id, wage_setting=wage_setting, request_options=request_options)
        return response.data


class AsyncWageSettingClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawWageSettingClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawWageSettingClient
        """
        return self._raw_client

    async def get(
        self, team_member_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetWageSettingResponse:
        """
        Retrieves a `WageSetting` object for a team member specified
        by `TeamMember.id`. For more information, see
        [Troubleshooting the Team API](https://developer.squareup.com/docs/team/troubleshooting#retrievewagesetting).

        Square recommends using [RetrieveTeamMember](api-endpoint:Team-RetrieveTeamMember) or [SearchTeamMembers](api-endpoint:Team-SearchTeamMembers)
        to get this information directly from the `TeamMember.wage_setting` field.

        Parameters
        ----------
        team_member_id : str
            The ID of the team member for which to retrieve the wage setting.

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

        Returns
        -------
        GetWageSettingResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.team_members.wage_setting.get(
                team_member_id="team_member_id",
            )


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

    async def update(
        self,
        team_member_id: str,
        *,
        wage_setting: WageSettingParams,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateWageSettingResponse:
        """
        Creates or updates a `WageSetting` object. The object is created if a
        `WageSetting` with the specified `team_member_id` doesn't exist. Otherwise,
        it fully replaces the `WageSetting` object for the team member.
        The `WageSetting` is returned on a successful update. For more information, see
        [Troubleshooting the Team API](https://developer.squareup.com/docs/team/troubleshooting#create-or-update-a-wage-setting).

        Square recommends using [CreateTeamMember](api-endpoint:Team-CreateTeamMember) or [UpdateTeamMember](api-endpoint:Team-UpdateTeamMember)
        to manage the `TeamMember.wage_setting` field directly.

        Parameters
        ----------
        team_member_id : str
            The ID of the team member for which to update the `WageSetting` object.

        wage_setting : WageSettingParams
            The complete `WageSetting` object. For all job assignments, specify one of the following:
            - `job_id` (recommended) - If needed, call [ListJobs](api-endpoint:Team-ListJobs) to get a list of all jobs.
            Requires Square API version 2024-12-18 or later.
            - `job_title` - Use the exact, case-sensitive spelling of an existing title unless you want to create a new job.
            This value is ignored if `job_id` is also provided.

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

        Returns
        -------
        UpdateWageSettingResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.team_members.wage_setting.update(
                team_member_id="team_member_id",
                wage_setting={
                    "job_assignments": [
                        {
                            "job_title": "Manager",
                            "pay_type": "SALARY",
                            "annual_rate": {"amount": 3000000, "currency": "USD"},
                            "weekly_hours": 40,
                        },
                        {
                            "job_title": "Cashier",
                            "pay_type": "HOURLY",
                            "hourly_rate": {"amount": 2000, "currency": "USD"},
                        },
                    ],
                    "is_overtime_exempt": True,
                },
            )


        asyncio.run(main())
        """
        response = await self._raw_client.update(
            team_member_id, wage_setting=wage_setting, request_options=request_options
        )
        return response.data
