# 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.create_or_update_condition_group_request_body import CreateOrUpdateConditionGroupRequestBody
from ..types.create_or_update_condition_request_body import CreateOrUpdateConditionRequestBody
from .raw_client import AsyncRawPlansClient, RawPlansClient
from .types.count_plan_traits_response import CountPlanTraitsResponse
from .types.count_plans_request_plan_type import CountPlansRequestPlanType
from .types.count_plans_response import CountPlansResponse
from .types.create_plan_request_body_plan_type import CreatePlanRequestBodyPlanType
from .types.create_plan_response import CreatePlanResponse
from .types.create_plan_trait_response import CreatePlanTraitResponse
from .types.delete_audience_response import DeleteAudienceResponse
from .types.delete_plan_response import DeletePlanResponse
from .types.delete_plan_trait_response import DeletePlanTraitResponse
from .types.get_audience_response import GetAudienceResponse
from .types.get_plan_response import GetPlanResponse
from .types.get_plan_trait_response import GetPlanTraitResponse
from .types.list_plan_traits_response import ListPlanTraitsResponse
from .types.list_plans_request_plan_type import ListPlansRequestPlanType
from .types.list_plans_response import ListPlansResponse
from .types.update_audience_response import UpdateAudienceResponse
from .types.update_company_plans_response import UpdateCompanyPlansResponse
from .types.update_plan_response import UpdatePlanResponse
from .types.update_plan_trait_response import UpdatePlanTraitResponse
from .types.upsert_billing_product_plan_response import UpsertBillingProductPlanResponse
from .types.upsert_billing_product_request_body_charge_type import UpsertBillingProductRequestBodyChargeType

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


class PlansClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawPlansClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawPlansClient
        """
        return self._raw_client

    def update_company_plans(
        self,
        company_plan_id: str,
        *,
        add_on_ids: typing.Sequence[str],
        base_plan_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateCompanyPlansResponse:
        """
        Parameters
        ----------
        company_plan_id : str
            company_plan_id

        add_on_ids : typing.Sequence[str]

        base_plan_id : typing.Optional[str]

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

        Returns
        -------
        UpdateCompanyPlansResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.update_company_plans(
            company_plan_id="company_plan_id",
            add_on_ids=["add_on_ids"],
        )
        """
        _response = self._raw_client.update_company_plans(
            company_plan_id, add_on_ids=add_on_ids, base_plan_id=base_plan_id, request_options=request_options
        )
        return _response.data

    def get_audience(
        self, plan_audience_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetAudienceResponse:
        """
        Parameters
        ----------
        plan_audience_id : str
            plan_audience_id

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

        Returns
        -------
        GetAudienceResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.get_audience(
            plan_audience_id="plan_audience_id",
        )
        """
        _response = self._raw_client.get_audience(plan_audience_id, request_options=request_options)
        return _response.data

    def update_audience(
        self,
        plan_audience_id: str,
        *,
        condition_groups: typing.Sequence[CreateOrUpdateConditionGroupRequestBody],
        conditions: typing.Sequence[CreateOrUpdateConditionRequestBody],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateAudienceResponse:
        """
        Parameters
        ----------
        plan_audience_id : str
            plan_audience_id

        condition_groups : typing.Sequence[CreateOrUpdateConditionGroupRequestBody]

        conditions : typing.Sequence[CreateOrUpdateConditionRequestBody]

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

        Returns
        -------
        UpdateAudienceResponse
            OK

        Examples
        --------
        from schematic import (
            CreateOrUpdateConditionGroupRequestBody,
            CreateOrUpdateConditionRequestBody,
            Schematic,
        )

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.update_audience(
            plan_audience_id="plan_audience_id",
            condition_groups=[
                CreateOrUpdateConditionGroupRequestBody(
                    conditions=[
                        CreateOrUpdateConditionRequestBody(
                            condition_type="company",
                            operator="eq",
                            resource_ids=["resource_ids"],
                        )
                    ],
                )
            ],
            conditions=[
                CreateOrUpdateConditionRequestBody(
                    condition_type="company",
                    operator="eq",
                    resource_ids=["resource_ids"],
                )
            ],
        )
        """
        _response = self._raw_client.update_audience(
            plan_audience_id, condition_groups=condition_groups, conditions=conditions, request_options=request_options
        )
        return _response.data

    def delete_audience(
        self, plan_audience_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteAudienceResponse:
        """
        Parameters
        ----------
        plan_audience_id : str
            plan_audience_id

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

        Returns
        -------
        DeleteAudienceResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.delete_audience(
            plan_audience_id="plan_audience_id",
        )
        """
        _response = self._raw_client.delete_audience(plan_audience_id, request_options=request_options)
        return _response.data

    def list_plan_traits(
        self,
        *,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        plan_id: typing.Optional[str] = None,
        trait_id: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListPlanTraitsResponse:
        """
        Parameters
        ----------
        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]

        plan_id : typing.Optional[str]

        trait_id : typing.Optional[str]

        limit : typing.Optional[int]
            Page limit (default 100)

        offset : typing.Optional[int]
            Page offset (default 0)

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

        Returns
        -------
        ListPlanTraitsResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.list_plan_traits()
        """
        _response = self._raw_client.list_plan_traits(
            ids=ids, plan_id=plan_id, trait_id=trait_id, limit=limit, offset=offset, request_options=request_options
        )
        return _response.data

    def create_plan_trait(
        self, *, plan_id: str, trait_id: str, trait_value: str, request_options: typing.Optional[RequestOptions] = None
    ) -> CreatePlanTraitResponse:
        """
        Parameters
        ----------
        plan_id : str

        trait_id : str

        trait_value : str

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

        Returns
        -------
        CreatePlanTraitResponse
            Created

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.create_plan_trait(
            plan_id="plan_id",
            trait_id="trait_id",
            trait_value="trait_value",
        )
        """
        _response = self._raw_client.create_plan_trait(
            plan_id=plan_id, trait_id=trait_id, trait_value=trait_value, request_options=request_options
        )
        return _response.data

    def get_plan_trait(
        self, plan_trait_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetPlanTraitResponse:
        """
        Parameters
        ----------
        plan_trait_id : str
            plan_trait_id

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

        Returns
        -------
        GetPlanTraitResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.get_plan_trait(
            plan_trait_id="plan_trait_id",
        )
        """
        _response = self._raw_client.get_plan_trait(plan_trait_id, request_options=request_options)
        return _response.data

    def update_plan_trait(
        self,
        plan_trait_id: str,
        *,
        plan_id: str,
        trait_value: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdatePlanTraitResponse:
        """
        Parameters
        ----------
        plan_trait_id : str
            plan_trait_id

        plan_id : str

        trait_value : str

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

        Returns
        -------
        UpdatePlanTraitResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.update_plan_trait(
            plan_trait_id="plan_trait_id",
            plan_id="plan_id",
            trait_value="trait_value",
        )
        """
        _response = self._raw_client.update_plan_trait(
            plan_trait_id, plan_id=plan_id, trait_value=trait_value, request_options=request_options
        )
        return _response.data

    def delete_plan_trait(
        self, plan_trait_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeletePlanTraitResponse:
        """
        Parameters
        ----------
        plan_trait_id : str
            plan_trait_id

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

        Returns
        -------
        DeletePlanTraitResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.delete_plan_trait(
            plan_trait_id="plan_trait_id",
        )
        """
        _response = self._raw_client.delete_plan_trait(plan_trait_id, request_options=request_options)
        return _response.data

    def count_plan_traits(
        self,
        *,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        plan_id: typing.Optional[str] = None,
        trait_id: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CountPlanTraitsResponse:
        """
        Parameters
        ----------
        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]

        plan_id : typing.Optional[str]

        trait_id : typing.Optional[str]

        limit : typing.Optional[int]
            Page limit (default 100)

        offset : typing.Optional[int]
            Page offset (default 0)

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

        Returns
        -------
        CountPlanTraitsResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.count_plan_traits()
        """
        _response = self._raw_client.count_plan_traits(
            ids=ids, plan_id=plan_id, trait_id=trait_id, limit=limit, offset=offset, request_options=request_options
        )
        return _response.data

    def list_plans(
        self,
        *,
        company_id: typing.Optional[str] = None,
        has_product_id: typing.Optional[bool] = None,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        plan_type: typing.Optional[ListPlansRequestPlanType] = None,
        q: typing.Optional[str] = None,
        without_entitlement_for: typing.Optional[str] = None,
        without_product_id: typing.Optional[bool] = None,
        without_paid_product_id: typing.Optional[bool] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListPlansResponse:
        """
        Parameters
        ----------
        company_id : typing.Optional[str]

        has_product_id : typing.Optional[bool]
            Filter out plans that do not have a billing product ID

        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]

        plan_type : typing.Optional[ListPlansRequestPlanType]
            Filter by plan type

        q : typing.Optional[str]

        without_entitlement_for : typing.Optional[str]
            Filter out plans that already have a plan entitlement for the specified feature ID

        without_product_id : typing.Optional[bool]
            Filter out plans that have a billing product ID

        without_paid_product_id : typing.Optional[bool]
            Filter out plans that have a paid billing product ID

        limit : typing.Optional[int]
            Page limit (default 100)

        offset : typing.Optional[int]
            Page offset (default 0)

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

        Returns
        -------
        ListPlansResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.list_plans()
        """
        _response = self._raw_client.list_plans(
            company_id=company_id,
            has_product_id=has_product_id,
            ids=ids,
            plan_type=plan_type,
            q=q,
            without_entitlement_for=without_entitlement_for,
            without_product_id=without_product_id,
            without_paid_product_id=without_paid_product_id,
            limit=limit,
            offset=offset,
            request_options=request_options,
        )
        return _response.data

    def create_plan(
        self,
        *,
        description: str,
        name: str,
        plan_type: CreatePlanRequestBodyPlanType,
        icon: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreatePlanResponse:
        """
        Parameters
        ----------
        description : str

        name : str

        plan_type : CreatePlanRequestBodyPlanType

        icon : typing.Optional[str]

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

        Returns
        -------
        CreatePlanResponse
            Created

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.create_plan(
            description="description",
            name="name",
            plan_type="plan",
        )
        """
        _response = self._raw_client.create_plan(
            description=description, name=name, plan_type=plan_type, icon=icon, request_options=request_options
        )
        return _response.data

    def get_plan(self, plan_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetPlanResponse:
        """
        Parameters
        ----------
        plan_id : str
            plan_id

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

        Returns
        -------
        GetPlanResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.get_plan(
            plan_id="plan_id",
        )
        """
        _response = self._raw_client.get_plan(plan_id, request_options=request_options)
        return _response.data

    def update_plan(
        self,
        plan_id: str,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        icon: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdatePlanResponse:
        """
        Parameters
        ----------
        plan_id : str
            plan_id

        name : str

        description : typing.Optional[str]

        icon : typing.Optional[str]

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

        Returns
        -------
        UpdatePlanResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.update_plan(
            plan_id="plan_id",
            name="name",
        )
        """
        _response = self._raw_client.update_plan(
            plan_id, name=name, description=description, icon=icon, request_options=request_options
        )
        return _response.data

    def delete_plan(
        self, plan_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeletePlanResponse:
        """
        Parameters
        ----------
        plan_id : str
            plan_id

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

        Returns
        -------
        DeletePlanResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.delete_plan(
            plan_id="plan_id",
        )
        """
        _response = self._raw_client.delete_plan(plan_id, request_options=request_options)
        return _response.data

    def upsert_billing_product_plan(
        self,
        plan_id: str,
        *,
        charge_type: UpsertBillingProductRequestBodyChargeType,
        is_trialable: bool,
        billing_product_id: typing.Optional[str] = OMIT,
        currency: typing.Optional[str] = OMIT,
        monthly_price: typing.Optional[int] = OMIT,
        monthly_price_id: typing.Optional[str] = OMIT,
        one_time_price: typing.Optional[int] = OMIT,
        one_time_price_id: typing.Optional[str] = OMIT,
        trial_days: typing.Optional[int] = OMIT,
        yearly_price: typing.Optional[int] = OMIT,
        yearly_price_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpsertBillingProductPlanResponse:
        """
        Parameters
        ----------
        plan_id : str
            plan_id

        charge_type : UpsertBillingProductRequestBodyChargeType

        is_trialable : bool

        billing_product_id : typing.Optional[str]

        currency : typing.Optional[str]

        monthly_price : typing.Optional[int]

        monthly_price_id : typing.Optional[str]

        one_time_price : typing.Optional[int]

        one_time_price_id : typing.Optional[str]

        trial_days : typing.Optional[int]

        yearly_price : typing.Optional[int]

        yearly_price_id : typing.Optional[str]

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

        Returns
        -------
        UpsertBillingProductPlanResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.upsert_billing_product_plan(
            plan_id="plan_id",
            charge_type="one_time",
            is_trialable=True,
        )
        """
        _response = self._raw_client.upsert_billing_product_plan(
            plan_id,
            charge_type=charge_type,
            is_trialable=is_trialable,
            billing_product_id=billing_product_id,
            currency=currency,
            monthly_price=monthly_price,
            monthly_price_id=monthly_price_id,
            one_time_price=one_time_price,
            one_time_price_id=one_time_price_id,
            trial_days=trial_days,
            yearly_price=yearly_price,
            yearly_price_id=yearly_price_id,
            request_options=request_options,
        )
        return _response.data

    def count_plans(
        self,
        *,
        company_id: typing.Optional[str] = None,
        has_product_id: typing.Optional[bool] = None,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        plan_type: typing.Optional[CountPlansRequestPlanType] = None,
        q: typing.Optional[str] = None,
        without_entitlement_for: typing.Optional[str] = None,
        without_product_id: typing.Optional[bool] = None,
        without_paid_product_id: typing.Optional[bool] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CountPlansResponse:
        """
        Parameters
        ----------
        company_id : typing.Optional[str]

        has_product_id : typing.Optional[bool]
            Filter out plans that do not have a billing product ID

        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]

        plan_type : typing.Optional[CountPlansRequestPlanType]
            Filter by plan type

        q : typing.Optional[str]

        without_entitlement_for : typing.Optional[str]
            Filter out plans that already have a plan entitlement for the specified feature ID

        without_product_id : typing.Optional[bool]
            Filter out plans that have a billing product ID

        without_paid_product_id : typing.Optional[bool]
            Filter out plans that have a paid billing product ID

        limit : typing.Optional[int]
            Page limit (default 100)

        offset : typing.Optional[int]
            Page offset (default 0)

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

        Returns
        -------
        CountPlansResponse
            OK

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

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.plans.count_plans()
        """
        _response = self._raw_client.count_plans(
            company_id=company_id,
            has_product_id=has_product_id,
            ids=ids,
            plan_type=plan_type,
            q=q,
            without_entitlement_for=without_entitlement_for,
            without_product_id=without_product_id,
            without_paid_product_id=without_paid_product_id,
            limit=limit,
            offset=offset,
            request_options=request_options,
        )
        return _response.data


class AsyncPlansClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawPlansClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawPlansClient
        """
        return self._raw_client

    async def update_company_plans(
        self,
        company_plan_id: str,
        *,
        add_on_ids: typing.Sequence[str],
        base_plan_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateCompanyPlansResponse:
        """
        Parameters
        ----------
        company_plan_id : str
            company_plan_id

        add_on_ids : typing.Sequence[str]

        base_plan_id : typing.Optional[str]

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

        Returns
        -------
        UpdateCompanyPlansResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.update_company_plans(
                company_plan_id="company_plan_id",
                add_on_ids=["add_on_ids"],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_company_plans(
            company_plan_id, add_on_ids=add_on_ids, base_plan_id=base_plan_id, request_options=request_options
        )
        return _response.data

    async def get_audience(
        self, plan_audience_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetAudienceResponse:
        """
        Parameters
        ----------
        plan_audience_id : str
            plan_audience_id

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

        Returns
        -------
        GetAudienceResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.get_audience(
                plan_audience_id="plan_audience_id",
            )


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

    async def update_audience(
        self,
        plan_audience_id: str,
        *,
        condition_groups: typing.Sequence[CreateOrUpdateConditionGroupRequestBody],
        conditions: typing.Sequence[CreateOrUpdateConditionRequestBody],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateAudienceResponse:
        """
        Parameters
        ----------
        plan_audience_id : str
            plan_audience_id

        condition_groups : typing.Sequence[CreateOrUpdateConditionGroupRequestBody]

        conditions : typing.Sequence[CreateOrUpdateConditionRequestBody]

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

        Returns
        -------
        UpdateAudienceResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import (
            AsyncSchematic,
            CreateOrUpdateConditionGroupRequestBody,
            CreateOrUpdateConditionRequestBody,
        )

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.update_audience(
                plan_audience_id="plan_audience_id",
                condition_groups=[
                    CreateOrUpdateConditionGroupRequestBody(
                        conditions=[
                            CreateOrUpdateConditionRequestBody(
                                condition_type="company",
                                operator="eq",
                                resource_ids=["resource_ids"],
                            )
                        ],
                    )
                ],
                conditions=[
                    CreateOrUpdateConditionRequestBody(
                        condition_type="company",
                        operator="eq",
                        resource_ids=["resource_ids"],
                    )
                ],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_audience(
            plan_audience_id, condition_groups=condition_groups, conditions=conditions, request_options=request_options
        )
        return _response.data

    async def delete_audience(
        self, plan_audience_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteAudienceResponse:
        """
        Parameters
        ----------
        plan_audience_id : str
            plan_audience_id

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

        Returns
        -------
        DeleteAudienceResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.delete_audience(
                plan_audience_id="plan_audience_id",
            )


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

    async def list_plan_traits(
        self,
        *,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        plan_id: typing.Optional[str] = None,
        trait_id: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListPlanTraitsResponse:
        """
        Parameters
        ----------
        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]

        plan_id : typing.Optional[str]

        trait_id : typing.Optional[str]

        limit : typing.Optional[int]
            Page limit (default 100)

        offset : typing.Optional[int]
            Page offset (default 0)

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

        Returns
        -------
        ListPlanTraitsResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.list_plan_traits()


        asyncio.run(main())
        """
        _response = await self._raw_client.list_plan_traits(
            ids=ids, plan_id=plan_id, trait_id=trait_id, limit=limit, offset=offset, request_options=request_options
        )
        return _response.data

    async def create_plan_trait(
        self, *, plan_id: str, trait_id: str, trait_value: str, request_options: typing.Optional[RequestOptions] = None
    ) -> CreatePlanTraitResponse:
        """
        Parameters
        ----------
        plan_id : str

        trait_id : str

        trait_value : str

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

        Returns
        -------
        CreatePlanTraitResponse
            Created

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.create_plan_trait(
                plan_id="plan_id",
                trait_id="trait_id",
                trait_value="trait_value",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_plan_trait(
            plan_id=plan_id, trait_id=trait_id, trait_value=trait_value, request_options=request_options
        )
        return _response.data

    async def get_plan_trait(
        self, plan_trait_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetPlanTraitResponse:
        """
        Parameters
        ----------
        plan_trait_id : str
            plan_trait_id

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

        Returns
        -------
        GetPlanTraitResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.get_plan_trait(
                plan_trait_id="plan_trait_id",
            )


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

    async def update_plan_trait(
        self,
        plan_trait_id: str,
        *,
        plan_id: str,
        trait_value: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdatePlanTraitResponse:
        """
        Parameters
        ----------
        plan_trait_id : str
            plan_trait_id

        plan_id : str

        trait_value : str

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

        Returns
        -------
        UpdatePlanTraitResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.update_plan_trait(
                plan_trait_id="plan_trait_id",
                plan_id="plan_id",
                trait_value="trait_value",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_plan_trait(
            plan_trait_id, plan_id=plan_id, trait_value=trait_value, request_options=request_options
        )
        return _response.data

    async def delete_plan_trait(
        self, plan_trait_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeletePlanTraitResponse:
        """
        Parameters
        ----------
        plan_trait_id : str
            plan_trait_id

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

        Returns
        -------
        DeletePlanTraitResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.delete_plan_trait(
                plan_trait_id="plan_trait_id",
            )


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

    async def count_plan_traits(
        self,
        *,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        plan_id: typing.Optional[str] = None,
        trait_id: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CountPlanTraitsResponse:
        """
        Parameters
        ----------
        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]

        plan_id : typing.Optional[str]

        trait_id : typing.Optional[str]

        limit : typing.Optional[int]
            Page limit (default 100)

        offset : typing.Optional[int]
            Page offset (default 0)

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

        Returns
        -------
        CountPlanTraitsResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.count_plan_traits()


        asyncio.run(main())
        """
        _response = await self._raw_client.count_plan_traits(
            ids=ids, plan_id=plan_id, trait_id=trait_id, limit=limit, offset=offset, request_options=request_options
        )
        return _response.data

    async def list_plans(
        self,
        *,
        company_id: typing.Optional[str] = None,
        has_product_id: typing.Optional[bool] = None,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        plan_type: typing.Optional[ListPlansRequestPlanType] = None,
        q: typing.Optional[str] = None,
        without_entitlement_for: typing.Optional[str] = None,
        without_product_id: typing.Optional[bool] = None,
        without_paid_product_id: typing.Optional[bool] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListPlansResponse:
        """
        Parameters
        ----------
        company_id : typing.Optional[str]

        has_product_id : typing.Optional[bool]
            Filter out plans that do not have a billing product ID

        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]

        plan_type : typing.Optional[ListPlansRequestPlanType]
            Filter by plan type

        q : typing.Optional[str]

        without_entitlement_for : typing.Optional[str]
            Filter out plans that already have a plan entitlement for the specified feature ID

        without_product_id : typing.Optional[bool]
            Filter out plans that have a billing product ID

        without_paid_product_id : typing.Optional[bool]
            Filter out plans that have a paid billing product ID

        limit : typing.Optional[int]
            Page limit (default 100)

        offset : typing.Optional[int]
            Page offset (default 0)

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

        Returns
        -------
        ListPlansResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.list_plans()


        asyncio.run(main())
        """
        _response = await self._raw_client.list_plans(
            company_id=company_id,
            has_product_id=has_product_id,
            ids=ids,
            plan_type=plan_type,
            q=q,
            without_entitlement_for=without_entitlement_for,
            without_product_id=without_product_id,
            without_paid_product_id=without_paid_product_id,
            limit=limit,
            offset=offset,
            request_options=request_options,
        )
        return _response.data

    async def create_plan(
        self,
        *,
        description: str,
        name: str,
        plan_type: CreatePlanRequestBodyPlanType,
        icon: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreatePlanResponse:
        """
        Parameters
        ----------
        description : str

        name : str

        plan_type : CreatePlanRequestBodyPlanType

        icon : typing.Optional[str]

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

        Returns
        -------
        CreatePlanResponse
            Created

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.create_plan(
                description="description",
                name="name",
                plan_type="plan",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_plan(
            description=description, name=name, plan_type=plan_type, icon=icon, request_options=request_options
        )
        return _response.data

    async def get_plan(
        self, plan_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetPlanResponse:
        """
        Parameters
        ----------
        plan_id : str
            plan_id

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

        Returns
        -------
        GetPlanResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.get_plan(
                plan_id="plan_id",
            )


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

    async def update_plan(
        self,
        plan_id: str,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        icon: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdatePlanResponse:
        """
        Parameters
        ----------
        plan_id : str
            plan_id

        name : str

        description : typing.Optional[str]

        icon : typing.Optional[str]

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

        Returns
        -------
        UpdatePlanResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.update_plan(
                plan_id="plan_id",
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_plan(
            plan_id, name=name, description=description, icon=icon, request_options=request_options
        )
        return _response.data

    async def delete_plan(
        self, plan_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeletePlanResponse:
        """
        Parameters
        ----------
        plan_id : str
            plan_id

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

        Returns
        -------
        DeletePlanResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.delete_plan(
                plan_id="plan_id",
            )


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

    async def upsert_billing_product_plan(
        self,
        plan_id: str,
        *,
        charge_type: UpsertBillingProductRequestBodyChargeType,
        is_trialable: bool,
        billing_product_id: typing.Optional[str] = OMIT,
        currency: typing.Optional[str] = OMIT,
        monthly_price: typing.Optional[int] = OMIT,
        monthly_price_id: typing.Optional[str] = OMIT,
        one_time_price: typing.Optional[int] = OMIT,
        one_time_price_id: typing.Optional[str] = OMIT,
        trial_days: typing.Optional[int] = OMIT,
        yearly_price: typing.Optional[int] = OMIT,
        yearly_price_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpsertBillingProductPlanResponse:
        """
        Parameters
        ----------
        plan_id : str
            plan_id

        charge_type : UpsertBillingProductRequestBodyChargeType

        is_trialable : bool

        billing_product_id : typing.Optional[str]

        currency : typing.Optional[str]

        monthly_price : typing.Optional[int]

        monthly_price_id : typing.Optional[str]

        one_time_price : typing.Optional[int]

        one_time_price_id : typing.Optional[str]

        trial_days : typing.Optional[int]

        yearly_price : typing.Optional[int]

        yearly_price_id : typing.Optional[str]

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

        Returns
        -------
        UpsertBillingProductPlanResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.upsert_billing_product_plan(
                plan_id="plan_id",
                charge_type="one_time",
                is_trialable=True,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.upsert_billing_product_plan(
            plan_id,
            charge_type=charge_type,
            is_trialable=is_trialable,
            billing_product_id=billing_product_id,
            currency=currency,
            monthly_price=monthly_price,
            monthly_price_id=monthly_price_id,
            one_time_price=one_time_price,
            one_time_price_id=one_time_price_id,
            trial_days=trial_days,
            yearly_price=yearly_price,
            yearly_price_id=yearly_price_id,
            request_options=request_options,
        )
        return _response.data

    async def count_plans(
        self,
        *,
        company_id: typing.Optional[str] = None,
        has_product_id: typing.Optional[bool] = None,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        plan_type: typing.Optional[CountPlansRequestPlanType] = None,
        q: typing.Optional[str] = None,
        without_entitlement_for: typing.Optional[str] = None,
        without_product_id: typing.Optional[bool] = None,
        without_paid_product_id: typing.Optional[bool] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CountPlansResponse:
        """
        Parameters
        ----------
        company_id : typing.Optional[str]

        has_product_id : typing.Optional[bool]
            Filter out plans that do not have a billing product ID

        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]

        plan_type : typing.Optional[CountPlansRequestPlanType]
            Filter by plan type

        q : typing.Optional[str]

        without_entitlement_for : typing.Optional[str]
            Filter out plans that already have a plan entitlement for the specified feature ID

        without_product_id : typing.Optional[bool]
            Filter out plans that have a billing product ID

        without_paid_product_id : typing.Optional[bool]
            Filter out plans that have a paid billing product ID

        limit : typing.Optional[int]
            Page limit (default 100)

        offset : typing.Optional[int]
            Page offset (default 0)

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

        Returns
        -------
        CountPlansResponse
            OK

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.plans.count_plans()


        asyncio.run(main())
        """
        _response = await self._raw_client.count_plans(
            company_id=company_id,
            has_product_id=has_product_id,
            ids=ids,
            plan_type=plan_type,
            q=q,
            without_entitlement_for=without_entitlement_for,
            without_product_id=without_product_id,
            without_paid_product_id=without_paid_product_id,
            limit=limit,
            offset=offset,
            request_options=request_options,
        )
        return _response.data
