# 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.entrypointfield import Entrypointfield
from ..types.file_content_ftype import FileContentFtype
from ..types.payabli_api_response_00_responsedatanonobject import PayabliApiResponse00Responsedatanonobject
from ..types.payabli_api_response_generic_2_part import PayabliApiResponseGeneric2Part
from ..types.payabli_pages import PayabliPages
from ..types.settings_query_record import SettingsQueryRecord
from .raw_client import AsyncRawPaypointClient, RawPaypointClient
from .types.get_basic_entry_by_id_response import GetBasicEntryByIdResponse
from .types.get_basic_entry_response import GetBasicEntryResponse
from .types.get_entry_config_response import GetEntryConfigResponse
from .types.migrate_paypoint_response import MigratePaypointResponse
from .types.notification_request import NotificationRequest

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


class PaypointClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawPaypointClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawPaypointClient
        """
        return self._raw_client

    def get_basic_entry(
        self, entry: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetBasicEntryResponse:
        """
        Gets the basic details for a paypoint.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

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

        Returns
        -------
        GetBasicEntryResponse
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.paypoint.get_basic_entry(
            entry="8cfec329267",
        )
        """
        _response = self._raw_client.get_basic_entry(entry, request_options=request_options)
        return _response.data

    def get_basic_entry_by_id(
        self, id_paypoint: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetBasicEntryByIdResponse:
        """
        Retrieves the basic details for a paypoint by ID.

        Parameters
        ----------
        id_paypoint : str
            Paypoint ID. You can find this value by querying `/api/Query/paypoints/{orgId}`

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

        Returns
        -------
        GetBasicEntryByIdResponse
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.paypoint.get_basic_entry_by_id(
            id_paypoint="198",
        )
        """
        _response = self._raw_client.get_basic_entry_by_id(id_paypoint, request_options=request_options)
        return _response.data

    def get_entry_config(
        self,
        entry: str,
        *,
        entrypages: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetEntryConfigResponse:
        """
        Gets the details for a single paypoint.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        entrypages : typing.Optional[str]

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

        Returns
        -------
        GetEntryConfigResponse
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.paypoint.get_entry_config(
            entry="8cfec329267",
        )
        """
        _response = self._raw_client.get_entry_config(entry, entrypages=entrypages, request_options=request_options)
        return _response.data

    def get_page(
        self, entry: str, subdomain: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliPages:
        """
        Gets the details for single payment page for a paypoint.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        subdomain : str
            Payment page identifier. The subdomain value is the last portion of the payment page URL. For example, in`https://paypages-sandbox.payabli.com/513823dc10/pay-your-fees-1`, the subdomain is `pay-your-fees-1`.

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

        Returns
        -------
        PayabliPages
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.paypoint.get_page(
            entry="8cfec329267",
            subdomain="pay-your-fees-1",
        )
        """
        _response = self._raw_client.get_page(entry, subdomain, request_options=request_options)
        return _response.data

    def remove_page(
        self, entry: str, subdomain: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliApiResponseGeneric2Part:
        """
        Deletes a payment page in a paypoint.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        subdomain : str
            Payment page identifier. The subdomain value is the last portion of the payment page URL. For example, in`https://paypages-sandbox.payabli.com/513823dc10/pay-your-fees-1`, the subdomain is `pay-your-fees-1`.

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

        Returns
        -------
        PayabliApiResponseGeneric2Part
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.paypoint.remove_page(
            entry="8cfec329267",
            subdomain="pay-your-fees-1",
        )
        """
        _response = self._raw_client.remove_page(entry, subdomain, request_options=request_options)
        return _response.data

    def save_logo(
        self,
        entry: str,
        *,
        f_content: typing.Optional[str] = OMIT,
        filename: typing.Optional[str] = OMIT,
        ftype: typing.Optional[FileContentFtype] = OMIT,
        furl: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PayabliApiResponse00Responsedatanonobject:
        """
        Updates a paypoint logo.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        f_content : typing.Optional[str]
            Content of file, Base64-encoded. Ignored if furl is specified. Max upload size is 30 MB.

        filename : typing.Optional[str]
            The name of the attached file.

        ftype : typing.Optional[FileContentFtype]
            The MIME type of the file (if content is provided)

        furl : typing.Optional[str]
            Optional URL provided to show or download the file remotely

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

        Returns
        -------
        PayabliApiResponse00Responsedatanonobject
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.paypoint.save_logo(
            entry="8cfec329267",
        )
        """
        _response = self._raw_client.save_logo(
            entry, f_content=f_content, filename=filename, ftype=ftype, furl=furl, request_options=request_options
        )
        return _response.data

    def settings_page(
        self, entry: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SettingsQueryRecord:
        """
        Retrieves an paypoint's basic settings like custom fields, identifiers, and invoicing settings.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

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

        Returns
        -------
        SettingsQueryRecord
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.paypoint.settings_page(
            entry="8cfec329267",
        )
        """
        _response = self._raw_client.settings_page(entry, request_options=request_options)
        return _response.data

    def migrate(
        self,
        *,
        entry_point: Entrypointfield,
        new_parent_organization_id: int,
        notification_request: typing.Optional[NotificationRequest] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MigratePaypointResponse:
        """
        Migrates a paypoint to a new parent organization.

        Parameters
        ----------
        entry_point : Entrypointfield

        new_parent_organization_id : int
            The ID for the paypoint's new parent organization.

        notification_request : typing.Optional[NotificationRequest]
            Optional notification request object for a webhook

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

        Returns
        -------
        MigratePaypointResponse
            Success

        Examples
        --------
        from payabli import payabli
        from payabli.paypoint import NotificationRequest, WebHeaderParameter

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.paypoint.migrate(
            entry_point="473abc123def",
            new_parent_organization_id=123,
            notification_request=NotificationRequest(
                notification_url="https://webhook-test.yoursie.com",
                web_header_parameters=[
                    WebHeaderParameter(
                        key="testheader",
                        value="1234567890",
                    )
                ],
            ),
        )
        """
        _response = self._raw_client.migrate(
            entry_point=entry_point,
            new_parent_organization_id=new_parent_organization_id,
            notification_request=notification_request,
            request_options=request_options,
        )
        return _response.data


class AsyncPaypointClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawPaypointClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawPaypointClient
        """
        return self._raw_client

    async def get_basic_entry(
        self, entry: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetBasicEntryResponse:
        """
        Gets the basic details for a paypoint.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

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

        Returns
        -------
        GetBasicEntryResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.paypoint.get_basic_entry(
                entry="8cfec329267",
            )


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

    async def get_basic_entry_by_id(
        self, id_paypoint: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetBasicEntryByIdResponse:
        """
        Retrieves the basic details for a paypoint by ID.

        Parameters
        ----------
        id_paypoint : str
            Paypoint ID. You can find this value by querying `/api/Query/paypoints/{orgId}`

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

        Returns
        -------
        GetBasicEntryByIdResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.paypoint.get_basic_entry_by_id(
                id_paypoint="198",
            )


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

    async def get_entry_config(
        self,
        entry: str,
        *,
        entrypages: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetEntryConfigResponse:
        """
        Gets the details for a single paypoint.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        entrypages : typing.Optional[str]

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

        Returns
        -------
        GetEntryConfigResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.paypoint.get_entry_config(
                entry="8cfec329267",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_entry_config(
            entry, entrypages=entrypages, request_options=request_options
        )
        return _response.data

    async def get_page(
        self, entry: str, subdomain: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliPages:
        """
        Gets the details for single payment page for a paypoint.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        subdomain : str
            Payment page identifier. The subdomain value is the last portion of the payment page URL. For example, in`https://paypages-sandbox.payabli.com/513823dc10/pay-your-fees-1`, the subdomain is `pay-your-fees-1`.

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

        Returns
        -------
        PayabliPages
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.paypoint.get_page(
                entry="8cfec329267",
                subdomain="pay-your-fees-1",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_page(entry, subdomain, request_options=request_options)
        return _response.data

    async def remove_page(
        self, entry: str, subdomain: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliApiResponseGeneric2Part:
        """
        Deletes a payment page in a paypoint.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        subdomain : str
            Payment page identifier. The subdomain value is the last portion of the payment page URL. For example, in`https://paypages-sandbox.payabli.com/513823dc10/pay-your-fees-1`, the subdomain is `pay-your-fees-1`.

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

        Returns
        -------
        PayabliApiResponseGeneric2Part
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.paypoint.remove_page(
                entry="8cfec329267",
                subdomain="pay-your-fees-1",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.remove_page(entry, subdomain, request_options=request_options)
        return _response.data

    async def save_logo(
        self,
        entry: str,
        *,
        f_content: typing.Optional[str] = OMIT,
        filename: typing.Optional[str] = OMIT,
        ftype: typing.Optional[FileContentFtype] = OMIT,
        furl: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PayabliApiResponse00Responsedatanonobject:
        """
        Updates a paypoint logo.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        f_content : typing.Optional[str]
            Content of file, Base64-encoded. Ignored if furl is specified. Max upload size is 30 MB.

        filename : typing.Optional[str]
            The name of the attached file.

        ftype : typing.Optional[FileContentFtype]
            The MIME type of the file (if content is provided)

        furl : typing.Optional[str]
            Optional URL provided to show or download the file remotely

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

        Returns
        -------
        PayabliApiResponse00Responsedatanonobject
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.paypoint.save_logo(
                entry="8cfec329267",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.save_logo(
            entry, f_content=f_content, filename=filename, ftype=ftype, furl=furl, request_options=request_options
        )
        return _response.data

    async def settings_page(
        self, entry: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SettingsQueryRecord:
        """
        Retrieves an paypoint's basic settings like custom fields, identifiers, and invoicing settings.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

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

        Returns
        -------
        SettingsQueryRecord
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.paypoint.settings_page(
                entry="8cfec329267",
            )


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

    async def migrate(
        self,
        *,
        entry_point: Entrypointfield,
        new_parent_organization_id: int,
        notification_request: typing.Optional[NotificationRequest] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MigratePaypointResponse:
        """
        Migrates a paypoint to a new parent organization.

        Parameters
        ----------
        entry_point : Entrypointfield

        new_parent_organization_id : int
            The ID for the paypoint's new parent organization.

        notification_request : typing.Optional[NotificationRequest]
            Optional notification request object for a webhook

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

        Returns
        -------
        MigratePaypointResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli
        from payabli.paypoint import NotificationRequest, WebHeaderParameter

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.paypoint.migrate(
                entry_point="473abc123def",
                new_parent_organization_id=123,
                notification_request=NotificationRequest(
                    notification_url="https://webhook-test.yoursie.com",
                    web_header_parameters=[
                        WebHeaderParameter(
                            key="testheader",
                            value="1234567890",
                        )
                    ],
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.migrate(
            entry_point=entry_point,
            new_parent_organization_id=new_parent_organization_id,
            notification_request=notification_request,
            request_options=request_options,
        )
        return _response.data
