# 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.campaign_submission_result import CampaignSubmissionResult
from ...types.campaign_validation_result import CampaignValidationResult
from ...types.message_volume_enum import MessageVolumeEnum
from ...types.toll_free_campaign_with_extended_brand_and_status import TollFreeCampaignWithExtendedBrandAndStatus
from .raw_client import AsyncRawTollFreeClient, RawTollFreeClient
from .types.toll_free_autofill_response import TollFreeAutofillResponse
from .types.toll_free_campaign_keywords import TollFreeCampaignKeywords
from .types.toll_free_campaign_links import TollFreeCampaignLinks
from .types.toll_free_campaign_opt_in import TollFreeCampaignOptIn
from .types.toll_free_campaign_options import TollFreeCampaignOptions
from .types.toll_free_campaign_use_case import TollFreeCampaignUseCase

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


class TollFreeClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawTollFreeClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawTollFreeClient
        """
        return self._raw_client

    def autofill(
        self,
        *,
        additional_info: typing.Optional[str] = OMIT,
        campaign_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TollFreeAutofillResponse:
        """
        Generate campaign details based off existing campaign and the brand it's connected to.

        Parameters
        ----------
        additional_info : typing.Optional[str]
            Any additional information you want to provide.

        campaign_id : typing.Optional[str]
            Unique identifier for the campaign.
            - When autofilling 10DLC campaigns, it must begin with the prefix `dlc_` (e.g., `dlc_1234567890`)
            - When autofilling Toll-Free campaigns, it must begin with the prefix `tf_` (e.g., `tf_1234567890`)
            - When autofilling RCS campaigns, it must begin with the prefix `rcs_` (e.g., `rcs_1234567890`)

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

        Returns
        -------
        TollFreeAutofillResponse
            Returns autofilled toll-free information.

        Examples
        --------
        from rcs import Pinnacle

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.campaigns.toll_free.autofill(
            additional_info="Please autofill missing campaign fields using my brand profile",
            campaign_id="dlc_1234567890",
        )
        """
        _response = self._raw_client.autofill(
            additional_info=additional_info, campaign_id=campaign_id, request_options=request_options
        )
        return _response.data

    def get(
        self, campaign_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> TollFreeCampaignWithExtendedBrandAndStatus:
        """
        Retrieve Toll-Free campaign.

        Parameters
        ----------
        campaign_id : str
            Unique identifier of toll-free campaign. Must begin with the prefix `tf_`.

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

        Returns
        -------
        TollFreeCampaignWithExtendedBrandAndStatus
            Successfully retrieved.

        Examples
        --------
        from rcs import Pinnacle

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.campaigns.toll_free.get(
            campaign_id="tf_1234567890",
        )
        """
        _response = self._raw_client.get(campaign_id, request_options=request_options)
        return _response.data

    def submit(
        self, campaign_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> CampaignSubmissionResult:
        """
        Submit your toll-free campaign for approval and activation with carriers.

        Parameters
        ----------
        campaign_id : str
            Unique identifier of the toll-free campaign to submit. Must begin with the prefix `tf_`.

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

        Returns
        -------
        CampaignSubmissionResult
            Successfully submitted toll-free campaign for approval.

        Examples
        --------
        from rcs import Pinnacle

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.campaigns.toll_free.submit(
            campaign_id="tf_1234567890",
        )
        """
        _response = self._raw_client.submit(campaign_id, request_options=request_options)
        return _response.data

    def upsert(
        self,
        *,
        brand: typing.Optional[str] = OMIT,
        campaign_id: typing.Optional[str] = OMIT,
        keywords: typing.Optional[TollFreeCampaignKeywords] = OMIT,
        links: typing.Optional[TollFreeCampaignLinks] = OMIT,
        monthly_volume: typing.Optional[MessageVolumeEnum] = OMIT,
        name: typing.Optional[str] = OMIT,
        opt_in: typing.Optional[TollFreeCampaignOptIn] = OMIT,
        options: typing.Optional[TollFreeCampaignOptions] = OMIT,
        production_message_content: typing.Optional[str] = OMIT,
        use_case: typing.Optional[TollFreeCampaignUseCase] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TollFreeCampaignWithExtendedBrandAndStatus:
        """
        Create a new toll-free campaign or update an existing one.

        <Note>
        **To create a new campaign:** Omit `campaignId` — one will be generated automatically.

        **Before you start:** Create a [brand](/api-reference/brands/upsert) first — you'll need its `id` for the [`brand`](#request.body.brand) field.

        All fields are **required** unless specified otherwise, and will be validated when [submitted](/api-reference/campaigns/toll-free/submit).

        **See the response for example values for each field.**
        </Note>

        Parameters
        ----------
        brand : typing.Optional[str]
            Brand id. This identifier is a string that always begins with the prefix `b_`, for example: `b_1234567890`.

        campaign_id : typing.Optional[str]
            Unique identifier for the campaign. This identifier is a string that always begins with the prefix `tf_`, for example: `tf_1234567890`.

        keywords : typing.Optional[TollFreeCampaignKeywords]
            Keyword response configuration.

        links : typing.Optional[TollFreeCampaignLinks]
            Legal documentation links.

        monthly_volume : typing.Optional[MessageVolumeEnum]

        name : typing.Optional[str]
            Display name of the campaign. This is not sent to carriers for approval and is only used for your reference on the Pinnacle dashboard.

        opt_in : typing.Optional[TollFreeCampaignOptIn]
            Opt-in method and workflow.

        options : typing.Optional[TollFreeCampaignOptions]
            Campaign configuration options.

        production_message_content : typing.Optional[str]
            Example message(s) that would be sent in production. Should reflect the actual content users will receive, including HELP/STOP disclosures. See the [Production Message Content](/guides/campaigns/opt-in-compliance#production-message-content) section for requirements.

        use_case : typing.Optional[TollFreeCampaignUseCase]
            Use case classification for the campaign.

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

        Returns
        -------
        TollFreeCampaignWithExtendedBrandAndStatus
            Successfully created or updated toll-free campaign.

        Examples
        --------
        from rcs import Pinnacle
        from rcs.campaigns.toll_free import (
            TollFreeCampaignHelpKeywords,
            TollFreeCampaignKeywords,
            TollFreeCampaignLinks,
            TollFreeCampaignOptIn,
            TollFreeCampaignOptInKeywords,
            TollFreeCampaignOptions,
            TollFreeCampaignUseCase,
        )

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.campaigns.toll_free.upsert(
            brand="b_1234567890",
            campaign_id="tf_1234567890",
            keywords=TollFreeCampaignKeywords(
                help=TollFreeCampaignHelpKeywords(
                    message="Pinnacle Software Development Inc.: For assistance, visit https://pinnacle.sh/support or email founders@trypinnacle.app. Msg&data rates may apply. Reply STOP to cancel.",
                ),
                opt_in=TollFreeCampaignOptInKeywords(
                    message="Pinnacle Software Development Inc.: You're enrolled in account & security alerts. Msg&data rates may apply. Message frequency varies. Reply HELP for help, STOP to cancel. Terms: https://pinnacle.sh/terms/ Privacy: https://pinnacle.sh/privacy/",
                    keywords=["START", "SUBSCRIBE"],
                ),
            ),
            links=TollFreeCampaignLinks(
                privacy_policy="https://www.pinnacle.sh/privacy",
                terms_of_service="https://www.pinnacle.sh/terms",
            ),
            monthly_volume="10,000",
            name="Pinnacle",
            opt_in=TollFreeCampaignOptIn(
                method="PAPER",
                url="https://www.pinnacle.sh/opt-in",
                workflow_description="End users opt-in when filling out the in-person intake forms where they will write their phone numbers and check a box indicating that they've opted in to messages. Link to paper form: https://www.pinnacle.sh/opt-in",
            ),
            options=TollFreeCampaignOptions(
                age_gated=False,
            ),
            production_message_content="Hi [First Name], your order #[Order ID] has shipped and will arrive [Date]. Track here: [URL]. Reply HELP for help or STOP to unsubscribe.",
            use_case=TollFreeCampaignUseCase(
                summary="Customers who have opted into text messages can interact with our automated SMS chatbot to receive transaction-driven notifications (order status, shipping updates, account alerts), ask support questions, share photos with friends, and manage their account details via simple, conversational text flows. All messages are transactional or interactive flows customers opt into. Users can send images (e.g., receipts) and get guided replies.",
                value="CHATBOT",
            ),
        )
        """
        _response = self._raw_client.upsert(
            brand=brand,
            campaign_id=campaign_id,
            keywords=keywords,
            links=links,
            monthly_volume=monthly_volume,
            name=name,
            opt_in=opt_in,
            options=options,
            production_message_content=production_message_content,
            use_case=use_case,
            request_options=request_options,
        )
        return _response.data

    def validate(
        self,
        *,
        campaign_id: str,
        additional_info: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CampaignValidationResult:
        """
        Validate your toll-free campaign configuration against carrier requirements and compliance rules.

        Parameters
        ----------
        campaign_id : str
            Unique identifier for the campaign.
            - When validating 10DLC campaigns, it must begin with the prefix `dlc_` (e.g., `dlc_1234567890`)
            - When validating toll-free campaigns, it must begin with the prefix `tf_` (e.g., `tf_1234567890`)
            - When validating RCS campaigns, it must begin with the prefix `rcs_` (e.g., `rcs_1234567890`)

        additional_info : typing.Optional[str]
            Any additional information you want to provide.

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

        Returns
        -------
        CampaignValidationResult
            Returns validation results.

        Examples
        --------
        from rcs import Pinnacle

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.campaigns.toll_free.validate(
            additional_info="Please validate this DLC campaign for 10DLC compliance",
            campaign_id="dlc_1234567890",
        )
        """
        _response = self._raw_client.validate(
            campaign_id=campaign_id, additional_info=additional_info, request_options=request_options
        )
        return _response.data


class AsyncTollFreeClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawTollFreeClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawTollFreeClient
        """
        return self._raw_client

    async def autofill(
        self,
        *,
        additional_info: typing.Optional[str] = OMIT,
        campaign_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TollFreeAutofillResponse:
        """
        Generate campaign details based off existing campaign and the brand it's connected to.

        Parameters
        ----------
        additional_info : typing.Optional[str]
            Any additional information you want to provide.

        campaign_id : typing.Optional[str]
            Unique identifier for the campaign.
            - When autofilling 10DLC campaigns, it must begin with the prefix `dlc_` (e.g., `dlc_1234567890`)
            - When autofilling Toll-Free campaigns, it must begin with the prefix `tf_` (e.g., `tf_1234567890`)
            - When autofilling RCS campaigns, it must begin with the prefix `rcs_` (e.g., `rcs_1234567890`)

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

        Returns
        -------
        TollFreeAutofillResponse
            Returns autofilled toll-free information.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.campaigns.toll_free.autofill(
                additional_info="Please autofill missing campaign fields using my brand profile",
                campaign_id="dlc_1234567890",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.autofill(
            additional_info=additional_info, campaign_id=campaign_id, request_options=request_options
        )
        return _response.data

    async def get(
        self, campaign_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> TollFreeCampaignWithExtendedBrandAndStatus:
        """
        Retrieve Toll-Free campaign.

        Parameters
        ----------
        campaign_id : str
            Unique identifier of toll-free campaign. Must begin with the prefix `tf_`.

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

        Returns
        -------
        TollFreeCampaignWithExtendedBrandAndStatus
            Successfully retrieved.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.campaigns.toll_free.get(
                campaign_id="tf_1234567890",
            )


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

    async def submit(
        self, campaign_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> CampaignSubmissionResult:
        """
        Submit your toll-free campaign for approval and activation with carriers.

        Parameters
        ----------
        campaign_id : str
            Unique identifier of the toll-free campaign to submit. Must begin with the prefix `tf_`.

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

        Returns
        -------
        CampaignSubmissionResult
            Successfully submitted toll-free campaign for approval.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.campaigns.toll_free.submit(
                campaign_id="tf_1234567890",
            )


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

    async def upsert(
        self,
        *,
        brand: typing.Optional[str] = OMIT,
        campaign_id: typing.Optional[str] = OMIT,
        keywords: typing.Optional[TollFreeCampaignKeywords] = OMIT,
        links: typing.Optional[TollFreeCampaignLinks] = OMIT,
        monthly_volume: typing.Optional[MessageVolumeEnum] = OMIT,
        name: typing.Optional[str] = OMIT,
        opt_in: typing.Optional[TollFreeCampaignOptIn] = OMIT,
        options: typing.Optional[TollFreeCampaignOptions] = OMIT,
        production_message_content: typing.Optional[str] = OMIT,
        use_case: typing.Optional[TollFreeCampaignUseCase] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TollFreeCampaignWithExtendedBrandAndStatus:
        """
        Create a new toll-free campaign or update an existing one.

        <Note>
        **To create a new campaign:** Omit `campaignId` — one will be generated automatically.

        **Before you start:** Create a [brand](/api-reference/brands/upsert) first — you'll need its `id` for the [`brand`](#request.body.brand) field.

        All fields are **required** unless specified otherwise, and will be validated when [submitted](/api-reference/campaigns/toll-free/submit).

        **See the response for example values for each field.**
        </Note>

        Parameters
        ----------
        brand : typing.Optional[str]
            Brand id. This identifier is a string that always begins with the prefix `b_`, for example: `b_1234567890`.

        campaign_id : typing.Optional[str]
            Unique identifier for the campaign. This identifier is a string that always begins with the prefix `tf_`, for example: `tf_1234567890`.

        keywords : typing.Optional[TollFreeCampaignKeywords]
            Keyword response configuration.

        links : typing.Optional[TollFreeCampaignLinks]
            Legal documentation links.

        monthly_volume : typing.Optional[MessageVolumeEnum]

        name : typing.Optional[str]
            Display name of the campaign. This is not sent to carriers for approval and is only used for your reference on the Pinnacle dashboard.

        opt_in : typing.Optional[TollFreeCampaignOptIn]
            Opt-in method and workflow.

        options : typing.Optional[TollFreeCampaignOptions]
            Campaign configuration options.

        production_message_content : typing.Optional[str]
            Example message(s) that would be sent in production. Should reflect the actual content users will receive, including HELP/STOP disclosures. See the [Production Message Content](/guides/campaigns/opt-in-compliance#production-message-content) section for requirements.

        use_case : typing.Optional[TollFreeCampaignUseCase]
            Use case classification for the campaign.

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

        Returns
        -------
        TollFreeCampaignWithExtendedBrandAndStatus
            Successfully created or updated toll-free campaign.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle
        from rcs.campaigns.toll_free import (
            TollFreeCampaignHelpKeywords,
            TollFreeCampaignKeywords,
            TollFreeCampaignLinks,
            TollFreeCampaignOptIn,
            TollFreeCampaignOptInKeywords,
            TollFreeCampaignOptions,
            TollFreeCampaignUseCase,
        )

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.campaigns.toll_free.upsert(
                brand="b_1234567890",
                campaign_id="tf_1234567890",
                keywords=TollFreeCampaignKeywords(
                    help=TollFreeCampaignHelpKeywords(
                        message="Pinnacle Software Development Inc.: For assistance, visit https://pinnacle.sh/support or email founders@trypinnacle.app. Msg&data rates may apply. Reply STOP to cancel.",
                    ),
                    opt_in=TollFreeCampaignOptInKeywords(
                        message="Pinnacle Software Development Inc.: You're enrolled in account & security alerts. Msg&data rates may apply. Message frequency varies. Reply HELP for help, STOP to cancel. Terms: https://pinnacle.sh/terms/ Privacy: https://pinnacle.sh/privacy/",
                        keywords=["START", "SUBSCRIBE"],
                    ),
                ),
                links=TollFreeCampaignLinks(
                    privacy_policy="https://www.pinnacle.sh/privacy",
                    terms_of_service="https://www.pinnacle.sh/terms",
                ),
                monthly_volume="10,000",
                name="Pinnacle",
                opt_in=TollFreeCampaignOptIn(
                    method="PAPER",
                    url="https://www.pinnacle.sh/opt-in",
                    workflow_description="End users opt-in when filling out the in-person intake forms where they will write their phone numbers and check a box indicating that they've opted in to messages. Link to paper form: https://www.pinnacle.sh/opt-in",
                ),
                options=TollFreeCampaignOptions(
                    age_gated=False,
                ),
                production_message_content="Hi [First Name], your order #[Order ID] has shipped and will arrive [Date]. Track here: [URL]. Reply HELP for help or STOP to unsubscribe.",
                use_case=TollFreeCampaignUseCase(
                    summary="Customers who have opted into text messages can interact with our automated SMS chatbot to receive transaction-driven notifications (order status, shipping updates, account alerts), ask support questions, share photos with friends, and manage their account details via simple, conversational text flows. All messages are transactional or interactive flows customers opt into. Users can send images (e.g., receipts) and get guided replies.",
                    value="CHATBOT",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.upsert(
            brand=brand,
            campaign_id=campaign_id,
            keywords=keywords,
            links=links,
            monthly_volume=monthly_volume,
            name=name,
            opt_in=opt_in,
            options=options,
            production_message_content=production_message_content,
            use_case=use_case,
            request_options=request_options,
        )
        return _response.data

    async def validate(
        self,
        *,
        campaign_id: str,
        additional_info: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CampaignValidationResult:
        """
        Validate your toll-free campaign configuration against carrier requirements and compliance rules.

        Parameters
        ----------
        campaign_id : str
            Unique identifier for the campaign.
            - When validating 10DLC campaigns, it must begin with the prefix `dlc_` (e.g., `dlc_1234567890`)
            - When validating toll-free campaigns, it must begin with the prefix `tf_` (e.g., `tf_1234567890`)
            - When validating RCS campaigns, it must begin with the prefix `rcs_` (e.g., `rcs_1234567890`)

        additional_info : typing.Optional[str]
            Any additional information you want to provide.

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

        Returns
        -------
        CampaignValidationResult
            Returns validation results.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.campaigns.toll_free.validate(
                additional_info="Please validate this DLC campaign for 10DLC compliance",
                campaign_id="dlc_1234567890",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.validate(
            campaign_id=campaign_id, additional_info=additional_info, request_options=request_options
        )
        return _response.data
