# 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.add_payment_method_domain_api_response import AddPaymentMethodDomainApiResponse
from ..types.domain_name import DomainName
from ..types.entity_id import EntityId
from ..types.entity_type import EntityType
from ..types.payment_method_domain_api_response import PaymentMethodDomainApiResponse
from ..types.payment_method_domain_general_response import PaymentMethodDomainGeneralResponse
from .raw_client import AsyncRawPaymentMethodDomainClient, RawPaymentMethodDomainClient
from .types.add_payment_method_domain_request_apple_pay import AddPaymentMethodDomainRequestApplePay
from .types.add_payment_method_domain_request_google_pay import AddPaymentMethodDomainRequestGooglePay
from .types.delete_payment_method_domain_response import DeletePaymentMethodDomainResponse
from .types.list_payment_method_domains_response import ListPaymentMethodDomainsResponse
from .types.update_payment_method_domain_request_wallet import UpdatePaymentMethodDomainRequestWallet

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


class PaymentMethodDomainClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawPaymentMethodDomainClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawPaymentMethodDomainClient
        """
        return self._raw_client

    def add_payment_method_domain(
        self,
        *,
        apple_pay: typing.Optional[AddPaymentMethodDomainRequestApplePay] = OMIT,
        google_pay: typing.Optional[AddPaymentMethodDomainRequestGooglePay] = OMIT,
        domain_name: typing.Optional[DomainName] = OMIT,
        entity_id: typing.Optional[EntityId] = OMIT,
        entity_type: typing.Optional[EntityType] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AddPaymentMethodDomainApiResponse:
        """
        Add a payment method domain to an organization or paypoint.

        Parameters
        ----------
        apple_pay : typing.Optional[AddPaymentMethodDomainRequestApplePay]
            Apple Pay configuration information.

        google_pay : typing.Optional[AddPaymentMethodDomainRequestGooglePay]
            Google Pay configuration information.

        domain_name : typing.Optional[DomainName]

        entity_id : typing.Optional[EntityId]

        entity_type : typing.Optional[EntityType]

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

        Returns
        -------
        AddPaymentMethodDomainApiResponse
            Success

        Examples
        --------
        from payabli import payabli
        from payabli.payment_method_domain import (
            AddPaymentMethodDomainRequestApplePay,
            AddPaymentMethodDomainRequestGooglePay,
        )

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.payment_method_domain.add_payment_method_domain(
            domain_name="checkout.example.com",
            entity_id=109,
            entity_type="paypoint",
            apple_pay=AddPaymentMethodDomainRequestApplePay(
                is_enabled=True,
            ),
            google_pay=AddPaymentMethodDomainRequestGooglePay(
                is_enabled=True,
            ),
        )
        """
        _response = self._raw_client.add_payment_method_domain(
            apple_pay=apple_pay,
            google_pay=google_pay,
            domain_name=domain_name,
            entity_id=entity_id,
            entity_type=entity_type,
            request_options=request_options,
        )
        return _response.data

    def cascade_payment_method_domain(
        self, domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PaymentMethodDomainGeneralResponse:
        """
        Cascades a payment method domain to all child entities. All paypoints and suborganization under this parent will inherit this domain and its settings.

        Parameters
        ----------
        domain_id : str
            The payment method domain's ID in Payabli.

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

        Returns
        -------
        PaymentMethodDomainGeneralResponse
            Success

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

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.payment_method_domain.cascade_payment_method_domain(
            domain_id="pmd_b8237fa45c964d8a9ef27160cd42b8c5",
        )
        """
        _response = self._raw_client.cascade_payment_method_domain(domain_id, request_options=request_options)
        return _response.data

    def delete_payment_method_domain(
        self, domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeletePaymentMethodDomainResponse:
        """
        Delete a payment method domain. You can't delete an inherited domain, you must delete a domain at the organization level.

        Parameters
        ----------
        domain_id : str
            The payment method domain's ID in Payabli.

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

        Returns
        -------
        DeletePaymentMethodDomainResponse
            Success response for a deleted payment method domain.

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

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.payment_method_domain.delete_payment_method_domain(
            domain_id="pmd_b8237fa45c964d8a9ef27160cd42b8c5",
        )
        """
        _response = self._raw_client.delete_payment_method_domain(domain_id, request_options=request_options)
        return _response.data

    def get_payment_method_domain(
        self, domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PaymentMethodDomainApiResponse:
        """
        Get the details for a payment method domain.

        Parameters
        ----------
        domain_id : str
            The payment method domain's ID in Payabli.

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

        Returns
        -------
        PaymentMethodDomainApiResponse
            Success response that includes a payment method domain's details.

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

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.payment_method_domain.get_payment_method_domain(
            domain_id="pmd_b8237fa45c964d8a9ef27160cd42b8c5",
        )
        """
        _response = self._raw_client.get_payment_method_domain(domain_id, request_options=request_options)
        return _response.data

    def list_payment_method_domains(
        self,
        *,
        entity_id: typing.Optional[int] = None,
        entity_type: typing.Optional[str] = None,
        from_record: typing.Optional[int] = None,
        limit_record: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListPaymentMethodDomainsResponse:
        """
        Get a list of payment method domains that belong to a PSP, organization, or paypoint.

        Parameters
        ----------
        entity_id : typing.Optional[int]
            Identifier for the organization or paypoint.
            - For organization, provide the organization ID - For paypoint, provide the paypoint ID

        entity_type : typing.Optional[str]
            The type of entity. Valid values:
              - organization
              - paypoint
              - psp

        from_record : typing.Optional[int]
            Number of records to skip. Defaults to `0`.

        limit_record : typing.Optional[int]
            Max number of records for query response. Defaults to `20`.

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

        Returns
        -------
        ListPaymentMethodDomainsResponse
            Success

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

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.payment_method_domain.list_payment_method_domains(
            entity_id=1147,
            entity_type="paypoint",
        )
        """
        _response = self._raw_client.list_payment_method_domains(
            entity_id=entity_id,
            entity_type=entity_type,
            from_record=from_record,
            limit_record=limit_record,
            request_options=request_options,
        )
        return _response.data

    def update_payment_method_domain(
        self,
        domain_id: str,
        *,
        apple_pay: typing.Optional[UpdatePaymentMethodDomainRequestWallet] = OMIT,
        google_pay: typing.Optional[UpdatePaymentMethodDomainRequestWallet] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PaymentMethodDomainGeneralResponse:
        """
        Update a payment method domain's configuration values.

        Parameters
        ----------
        domain_id : str
            The payment method domain's ID in Payabli.

        apple_pay : typing.Optional[UpdatePaymentMethodDomainRequestWallet]

        google_pay : typing.Optional[UpdatePaymentMethodDomainRequestWallet]

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

        Returns
        -------
        PaymentMethodDomainGeneralResponse
            Success response for configuration update.

        Examples
        --------
        from payabli import payabli
        from payabli.payment_method_domain import UpdatePaymentMethodDomainRequestWallet

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.payment_method_domain.update_payment_method_domain(
            domain_id="pmd_b8237fa45c964d8a9ef27160cd42b8c5",
            apple_pay=UpdatePaymentMethodDomainRequestWallet(
                is_enabled=False,
            ),
            google_pay=UpdatePaymentMethodDomainRequestWallet(
                is_enabled=False,
            ),
        )
        """
        _response = self._raw_client.update_payment_method_domain(
            domain_id, apple_pay=apple_pay, google_pay=google_pay, request_options=request_options
        )
        return _response.data

    def verify_payment_method_domain(
        self, domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PaymentMethodDomainGeneralResponse:
        """
        Verify a new payment method domain. If verification is successful, Apple Pay is automatically activated for the domain.

        Parameters
        ----------
        domain_id : str
            The payment method domain's ID in Payabli.

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

        Returns
        -------
        PaymentMethodDomainGeneralResponse
            Success

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

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.payment_method_domain.verify_payment_method_domain(
            domain_id="pmd_b8237fa45c964d8a9ef27160cd42b8c5",
        )
        """
        _response = self._raw_client.verify_payment_method_domain(domain_id, request_options=request_options)
        return _response.data


class AsyncPaymentMethodDomainClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawPaymentMethodDomainClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawPaymentMethodDomainClient
        """
        return self._raw_client

    async def add_payment_method_domain(
        self,
        *,
        apple_pay: typing.Optional[AddPaymentMethodDomainRequestApplePay] = OMIT,
        google_pay: typing.Optional[AddPaymentMethodDomainRequestGooglePay] = OMIT,
        domain_name: typing.Optional[DomainName] = OMIT,
        entity_id: typing.Optional[EntityId] = OMIT,
        entity_type: typing.Optional[EntityType] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AddPaymentMethodDomainApiResponse:
        """
        Add a payment method domain to an organization or paypoint.

        Parameters
        ----------
        apple_pay : typing.Optional[AddPaymentMethodDomainRequestApplePay]
            Apple Pay configuration information.

        google_pay : typing.Optional[AddPaymentMethodDomainRequestGooglePay]
            Google Pay configuration information.

        domain_name : typing.Optional[DomainName]

        entity_id : typing.Optional[EntityId]

        entity_type : typing.Optional[EntityType]

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

        Returns
        -------
        AddPaymentMethodDomainApiResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli
        from payabli.payment_method_domain import (
            AddPaymentMethodDomainRequestApplePay,
            AddPaymentMethodDomainRequestGooglePay,
        )

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.payment_method_domain.add_payment_method_domain(
                domain_name="checkout.example.com",
                entity_id=109,
                entity_type="paypoint",
                apple_pay=AddPaymentMethodDomainRequestApplePay(
                    is_enabled=True,
                ),
                google_pay=AddPaymentMethodDomainRequestGooglePay(
                    is_enabled=True,
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.add_payment_method_domain(
            apple_pay=apple_pay,
            google_pay=google_pay,
            domain_name=domain_name,
            entity_id=entity_id,
            entity_type=entity_type,
            request_options=request_options,
        )
        return _response.data

    async def cascade_payment_method_domain(
        self, domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PaymentMethodDomainGeneralResponse:
        """
        Cascades a payment method domain to all child entities. All paypoints and suborganization under this parent will inherit this domain and its settings.

        Parameters
        ----------
        domain_id : str
            The payment method domain's ID in Payabli.

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

        Returns
        -------
        PaymentMethodDomainGeneralResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.payment_method_domain.cascade_payment_method_domain(
                domain_id="pmd_b8237fa45c964d8a9ef27160cd42b8c5",
            )


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

    async def delete_payment_method_domain(
        self, domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeletePaymentMethodDomainResponse:
        """
        Delete a payment method domain. You can't delete an inherited domain, you must delete a domain at the organization level.

        Parameters
        ----------
        domain_id : str
            The payment method domain's ID in Payabli.

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

        Returns
        -------
        DeletePaymentMethodDomainResponse
            Success response for a deleted payment method domain.

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.payment_method_domain.delete_payment_method_domain(
                domain_id="pmd_b8237fa45c964d8a9ef27160cd42b8c5",
            )


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

    async def get_payment_method_domain(
        self, domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PaymentMethodDomainApiResponse:
        """
        Get the details for a payment method domain.

        Parameters
        ----------
        domain_id : str
            The payment method domain's ID in Payabli.

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

        Returns
        -------
        PaymentMethodDomainApiResponse
            Success response that includes a payment method domain's details.

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.payment_method_domain.get_payment_method_domain(
                domain_id="pmd_b8237fa45c964d8a9ef27160cd42b8c5",
            )


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

    async def list_payment_method_domains(
        self,
        *,
        entity_id: typing.Optional[int] = None,
        entity_type: typing.Optional[str] = None,
        from_record: typing.Optional[int] = None,
        limit_record: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListPaymentMethodDomainsResponse:
        """
        Get a list of payment method domains that belong to a PSP, organization, or paypoint.

        Parameters
        ----------
        entity_id : typing.Optional[int]
            Identifier for the organization or paypoint.
            - For organization, provide the organization ID - For paypoint, provide the paypoint ID

        entity_type : typing.Optional[str]
            The type of entity. Valid values:
              - organization
              - paypoint
              - psp

        from_record : typing.Optional[int]
            Number of records to skip. Defaults to `0`.

        limit_record : typing.Optional[int]
            Max number of records for query response. Defaults to `20`.

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

        Returns
        -------
        ListPaymentMethodDomainsResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.payment_method_domain.list_payment_method_domains(
                entity_id=1147,
                entity_type="paypoint",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_payment_method_domains(
            entity_id=entity_id,
            entity_type=entity_type,
            from_record=from_record,
            limit_record=limit_record,
            request_options=request_options,
        )
        return _response.data

    async def update_payment_method_domain(
        self,
        domain_id: str,
        *,
        apple_pay: typing.Optional[UpdatePaymentMethodDomainRequestWallet] = OMIT,
        google_pay: typing.Optional[UpdatePaymentMethodDomainRequestWallet] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PaymentMethodDomainGeneralResponse:
        """
        Update a payment method domain's configuration values.

        Parameters
        ----------
        domain_id : str
            The payment method domain's ID in Payabli.

        apple_pay : typing.Optional[UpdatePaymentMethodDomainRequestWallet]

        google_pay : typing.Optional[UpdatePaymentMethodDomainRequestWallet]

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

        Returns
        -------
        PaymentMethodDomainGeneralResponse
            Success response for configuration update.

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli
        from payabli.payment_method_domain import UpdatePaymentMethodDomainRequestWallet

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.payment_method_domain.update_payment_method_domain(
                domain_id="pmd_b8237fa45c964d8a9ef27160cd42b8c5",
                apple_pay=UpdatePaymentMethodDomainRequestWallet(
                    is_enabled=False,
                ),
                google_pay=UpdatePaymentMethodDomainRequestWallet(
                    is_enabled=False,
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_payment_method_domain(
            domain_id, apple_pay=apple_pay, google_pay=google_pay, request_options=request_options
        )
        return _response.data

    async def verify_payment_method_domain(
        self, domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PaymentMethodDomainGeneralResponse:
        """
        Verify a new payment method domain. If verification is successful, Apple Pay is automatically activated for the domain.

        Parameters
        ----------
        domain_id : str
            The payment method domain's ID in Payabli.

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

        Returns
        -------
        PaymentMethodDomainGeneralResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.payment_method_domain.verify_payment_method_domain(
                domain_id="pmd_b8237fa45c964d8a9ef27160cd42b8c5",
            )


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