# 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.custom_plan_config import CustomPlanConfig
from ..types.ordered_plans_in_group import OrderedPlansInGroup
from .raw_client import AsyncRawPlangroupsClient, RawPlangroupsClient
from .types.create_plan_group_response import CreatePlanGroupResponse
from .types.get_plan_group_response import GetPlanGroupResponse
from .types.update_plan_group_response import UpdatePlanGroupResponse

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


class PlangroupsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawPlangroupsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawPlangroupsClient
        """
        return self._raw_client

    def get_plan_group(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetPlanGroupResponse:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetPlanGroupResponse
            OK

        Examples
        --------
        from schematic import Schematic

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plangroups.get_plan_group()
        """
        _response = self._raw_client.get_plan_group(request_options=request_options)
        return _response.data

    def create_plan_group(
        self,
        *,
        add_on_ids: typing.Sequence[str],
        ordered_plans: typing.Sequence[OrderedPlansInGroup],
        custom_plan_config: typing.Optional[CustomPlanConfig] = OMIT,
        custom_plan_id: typing.Optional[str] = OMIT,
        default_plan_id: typing.Optional[str] = OMIT,
        trial_days: typing.Optional[int] = OMIT,
        trial_payment_method_required: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreatePlanGroupResponse:
        """
        Parameters
        ----------
        add_on_ids : typing.Sequence[str]

        ordered_plans : typing.Sequence[OrderedPlansInGroup]

        custom_plan_config : typing.Optional[CustomPlanConfig]

        custom_plan_id : typing.Optional[str]

        default_plan_id : typing.Optional[str]

        trial_days : typing.Optional[int]

        trial_payment_method_required : typing.Optional[bool]

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

        Returns
        -------
        CreatePlanGroupResponse
            Created

        Examples
        --------
        from schematic import OrderedPlansInGroup, Schematic

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plangroups.create_plan_group(
            add_on_ids=["add_on_ids"],
            ordered_plans=[
                OrderedPlansInGroup(
                    plan_id="plan_id",
                )
            ],
        )
        """
        _response = self._raw_client.create_plan_group(
            add_on_ids=add_on_ids,
            ordered_plans=ordered_plans,
            custom_plan_config=custom_plan_config,
            custom_plan_id=custom_plan_id,
            default_plan_id=default_plan_id,
            trial_days=trial_days,
            trial_payment_method_required=trial_payment_method_required,
            request_options=request_options,
        )
        return _response.data

    def update_plan_group(
        self,
        plan_group_id: str,
        *,
        add_on_ids: typing.Sequence[str],
        ordered_plans: typing.Sequence[OrderedPlansInGroup],
        custom_plan_config: typing.Optional[CustomPlanConfig] = OMIT,
        custom_plan_id: typing.Optional[str] = OMIT,
        default_plan_id: typing.Optional[str] = OMIT,
        trial_days: typing.Optional[int] = OMIT,
        trial_payment_method_required: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdatePlanGroupResponse:
        """
        Parameters
        ----------
        plan_group_id : str
            plan_group_id

        add_on_ids : typing.Sequence[str]

        ordered_plans : typing.Sequence[OrderedPlansInGroup]

        custom_plan_config : typing.Optional[CustomPlanConfig]

        custom_plan_id : typing.Optional[str]

        default_plan_id : typing.Optional[str]

        trial_days : typing.Optional[int]

        trial_payment_method_required : typing.Optional[bool]

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

        Returns
        -------
        UpdatePlanGroupResponse
            OK

        Examples
        --------
        from schematic import OrderedPlansInGroup, Schematic

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plangroups.update_plan_group(
            plan_group_id="plan_group_id",
            add_on_ids=["add_on_ids"],
            ordered_plans=[
                OrderedPlansInGroup(
                    plan_id="plan_id",
                )
            ],
        )
        """
        _response = self._raw_client.update_plan_group(
            plan_group_id,
            add_on_ids=add_on_ids,
            ordered_plans=ordered_plans,
            custom_plan_config=custom_plan_config,
            custom_plan_id=custom_plan_id,
            default_plan_id=default_plan_id,
            trial_days=trial_days,
            trial_payment_method_required=trial_payment_method_required,
            request_options=request_options,
        )
        return _response.data


class AsyncPlangroupsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawPlangroupsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawPlangroupsClient
        """
        return self._raw_client

    async def get_plan_group(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetPlanGroupResponse:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetPlanGroupResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plangroups.get_plan_group()


        asyncio.run(main())
        """
        _response = await self._raw_client.get_plan_group(request_options=request_options)
        return _response.data

    async def create_plan_group(
        self,
        *,
        add_on_ids: typing.Sequence[str],
        ordered_plans: typing.Sequence[OrderedPlansInGroup],
        custom_plan_config: typing.Optional[CustomPlanConfig] = OMIT,
        custom_plan_id: typing.Optional[str] = OMIT,
        default_plan_id: typing.Optional[str] = OMIT,
        trial_days: typing.Optional[int] = OMIT,
        trial_payment_method_required: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreatePlanGroupResponse:
        """
        Parameters
        ----------
        add_on_ids : typing.Sequence[str]

        ordered_plans : typing.Sequence[OrderedPlansInGroup]

        custom_plan_config : typing.Optional[CustomPlanConfig]

        custom_plan_id : typing.Optional[str]

        default_plan_id : typing.Optional[str]

        trial_days : typing.Optional[int]

        trial_payment_method_required : typing.Optional[bool]

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

        Returns
        -------
        CreatePlanGroupResponse
            Created

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic, OrderedPlansInGroup

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plangroups.create_plan_group(
                add_on_ids=["add_on_ids"],
                ordered_plans=[
                    OrderedPlansInGroup(
                        plan_id="plan_id",
                    )
                ],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_plan_group(
            add_on_ids=add_on_ids,
            ordered_plans=ordered_plans,
            custom_plan_config=custom_plan_config,
            custom_plan_id=custom_plan_id,
            default_plan_id=default_plan_id,
            trial_days=trial_days,
            trial_payment_method_required=trial_payment_method_required,
            request_options=request_options,
        )
        return _response.data

    async def update_plan_group(
        self,
        plan_group_id: str,
        *,
        add_on_ids: typing.Sequence[str],
        ordered_plans: typing.Sequence[OrderedPlansInGroup],
        custom_plan_config: typing.Optional[CustomPlanConfig] = OMIT,
        custom_plan_id: typing.Optional[str] = OMIT,
        default_plan_id: typing.Optional[str] = OMIT,
        trial_days: typing.Optional[int] = OMIT,
        trial_payment_method_required: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdatePlanGroupResponse:
        """
        Parameters
        ----------
        plan_group_id : str
            plan_group_id

        add_on_ids : typing.Sequence[str]

        ordered_plans : typing.Sequence[OrderedPlansInGroup]

        custom_plan_config : typing.Optional[CustomPlanConfig]

        custom_plan_id : typing.Optional[str]

        default_plan_id : typing.Optional[str]

        trial_days : typing.Optional[int]

        trial_payment_method_required : typing.Optional[bool]

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

        Returns
        -------
        UpdatePlanGroupResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic, OrderedPlansInGroup

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plangroups.update_plan_group(
                plan_group_id="plan_group_id",
                add_on_ids=["add_on_ids"],
                ordered_plans=[
                    OrderedPlansInGroup(
                        plan_id="plan_id",
                    )
                ],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_plan_group(
            plan_group_id,
            add_on_ids=add_on_ids,
            ordered_plans=ordered_plans,
            custom_plan_config=custom_plan_config,
            custom_plan_id=custom_plan_id,
            default_plan_id=default_plan_id,
            trial_days=trial_days,
            trial_payment_method_required=trial_payment_method_required,
            request_options=request_options,
        )
        return _response.data
