r"""
    This code was generated by
   ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
    |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
    |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \

    Twilio - Trusthub
    This is the public Twilio REST API.

    NOTE: This class is auto generated by OpenAPI Generator.
    https://openapi-generator.tech
    Do not edit the class manually.
"""

from typing import Any, Dict, Optional, Union
from twilio.base import values
from twilio.base.api_response import ApiResponse
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version


class ComplianceInquiriesInstance(InstanceResource):
    """
    :ivar inquiry_id: The unique ID used to start an embedded compliance registration session.
    :ivar inquiry_session_token: The session token used to start an embedded compliance registration session.
    :ivar customer_id: The CustomerID matching the Customer Profile that should be resumed or resubmitted for editing.
    :ivar url: The URL of this resource.
    """

    def __init__(
        self,
        version: Version,
        payload: Dict[str, Any],
        customer_id: Optional[str] = None,
    ):
        super().__init__(version)

        self.inquiry_id: Optional[str] = payload.get("inquiry_id")
        self.inquiry_session_token: Optional[str] = payload.get("inquiry_session_token")
        self.customer_id: Optional[str] = payload.get("customer_id")
        self.url: Optional[str] = payload.get("url")

        self._solution = {
            "customer_id": customer_id or self.customer_id,
        }
        self._context: Optional[ComplianceInquiriesContext] = None

    @property
    def _proxy(self) -> "ComplianceInquiriesContext":
        """
        Generate an instance context for the instance, the context is capable of
        performing various actions. All instance actions are proxied to the context

        :returns: ComplianceInquiriesContext for this ComplianceInquiriesInstance
        """
        if self._context is None:
            self._context = ComplianceInquiriesContext(
                self._version,
                customer_id=self._solution["customer_id"],
            )
        return self._context

    def update(
        self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset
    ) -> "ComplianceInquiriesInstance":
        """
        Update the ComplianceInquiriesInstance

        :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile.
        :param theme_set_id: Theme id for styling the inquiry form.

        :returns: The updated ComplianceInquiriesInstance
        """
        return self._proxy.update(
            primary_profile_sid=primary_profile_sid,
            theme_set_id=theme_set_id,
        )

    async def update_async(
        self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset
    ) -> "ComplianceInquiriesInstance":
        """
        Asynchronous coroutine to update the ComplianceInquiriesInstance

        :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile.
        :param theme_set_id: Theme id for styling the inquiry form.

        :returns: The updated ComplianceInquiriesInstance
        """
        return await self._proxy.update_async(
            primary_profile_sid=primary_profile_sid,
            theme_set_id=theme_set_id,
        )

    def update_with_http_info(
        self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset
    ) -> ApiResponse:
        """
        Update the ComplianceInquiriesInstance with HTTP info

        :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile.
        :param theme_set_id: Theme id for styling the inquiry form.

        :returns: ApiResponse with instance, status code, and headers
        """
        return self._proxy.update_with_http_info(
            primary_profile_sid=primary_profile_sid,
            theme_set_id=theme_set_id,
        )

    async def update_with_http_info_async(
        self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset
    ) -> ApiResponse:
        """
        Asynchronous coroutine to update the ComplianceInquiriesInstance with HTTP info

        :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile.
        :param theme_set_id: Theme id for styling the inquiry form.

        :returns: ApiResponse with instance, status code, and headers
        """
        return await self._proxy.update_with_http_info_async(
            primary_profile_sid=primary_profile_sid,
            theme_set_id=theme_set_id,
        )

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """
        context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
        return "<Twilio.Trusthub.V1.ComplianceInquiriesInstance {}>".format(context)


class ComplianceInquiriesContext(InstanceContext):

    def __init__(self, version: Version, customer_id: str):
        """
        Initialize the ComplianceInquiriesContext

        :param version: Version that contains the resource
        :param customer_id: The unique CustomerId matching the Customer Profile/Compliance Inquiry that should be resumed or resubmitted. This value will have been returned by the initial Compliance Inquiry creation call.
        """
        super().__init__(version)

        # Path Solution
        self._solution = {
            "customer_id": customer_id,
        }
        self._uri = "/ComplianceInquiries/Customers/{customer_id}/Initialize".format(
            **self._solution
        )

    def _update(
        self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset
    ) -> tuple:
        """
        Internal helper for update operation

        Returns:
            tuple: (payload, status_code, headers)
        """

        data = values.of(
            {
                "PrimaryProfileSid": primary_profile_sid,
                "ThemeSetId": theme_set_id,
            }
        )
        headers = values.of({})

        headers["Content-Type"] = "application/x-www-form-urlencoded"

        headers["Accept"] = "application/json"

        return self._version.update_with_response_info(
            method="POST", uri=self._uri, data=data, headers=headers
        )

    def update(
        self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset
    ) -> ComplianceInquiriesInstance:
        """
        Update the ComplianceInquiriesInstance

        :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile.
        :param theme_set_id: Theme id for styling the inquiry form.

        :returns: The updated ComplianceInquiriesInstance
        """
        payload, _, _ = self._update(
            primary_profile_sid=primary_profile_sid, theme_set_id=theme_set_id
        )
        return ComplianceInquiriesInstance(
            self._version, payload, customer_id=self._solution["customer_id"]
        )

    def update_with_http_info(
        self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset
    ) -> ApiResponse:
        """
        Update the ComplianceInquiriesInstance and return response metadata

        :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile.
        :param theme_set_id: Theme id for styling the inquiry form.

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._update(
            primary_profile_sid=primary_profile_sid, theme_set_id=theme_set_id
        )
        instance = ComplianceInquiriesInstance(
            self._version, payload, customer_id=self._solution["customer_id"]
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    async def _update_async(
        self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset
    ) -> tuple:
        """
        Internal async helper for update operation

        Returns:
            tuple: (payload, status_code, headers)
        """

        data = values.of(
            {
                "PrimaryProfileSid": primary_profile_sid,
                "ThemeSetId": theme_set_id,
            }
        )
        headers = values.of({})

        headers["Content-Type"] = "application/x-www-form-urlencoded"

        headers["Accept"] = "application/json"

        return await self._version.update_with_response_info_async(
            method="POST", uri=self._uri, data=data, headers=headers
        )

    async def update_async(
        self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset
    ) -> ComplianceInquiriesInstance:
        """
        Asynchronous coroutine to update the ComplianceInquiriesInstance

        :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile.
        :param theme_set_id: Theme id for styling the inquiry form.

        :returns: The updated ComplianceInquiriesInstance
        """
        payload, _, _ = await self._update_async(
            primary_profile_sid=primary_profile_sid, theme_set_id=theme_set_id
        )
        return ComplianceInquiriesInstance(
            self._version, payload, customer_id=self._solution["customer_id"]
        )

    async def update_with_http_info_async(
        self, primary_profile_sid: str, theme_set_id: Union[str, object] = values.unset
    ) -> ApiResponse:
        """
        Asynchronous coroutine to update the ComplianceInquiriesInstance and return response metadata

        :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile.
        :param theme_set_id: Theme id for styling the inquiry form.

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._update_async(
            primary_profile_sid=primary_profile_sid, theme_set_id=theme_set_id
        )
        instance = ComplianceInquiriesInstance(
            self._version, payload, customer_id=self._solution["customer_id"]
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """
        context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
        return "<Twilio.Trusthub.V1.ComplianceInquiriesContext {}>".format(context)


class ComplianceInquiriesList(ListResource):

    def __init__(self, version: Version):
        """
        Initialize the ComplianceInquiriesList

        :param version: Version that contains the resource

        """
        super().__init__(version)

        self._uri = "/ComplianceInquiries/Customers/Initialize"

    def _create(
        self,
        notification_email: Union[str, object] = values.unset,
        theme_set_id: Union[str, object] = values.unset,
        primary_profile_sid: Union[str, object] = values.unset,
    ) -> tuple:
        """
        Internal helper for create operation

        Returns:
            tuple: (payload, status_code, headers)
        """

        data = values.of(
            {
                "NotificationEmail": notification_email,
                "ThemeSetId": theme_set_id,
                "PrimaryProfileSid": primary_profile_sid,
            }
        )
        headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})

        headers["Content-Type"] = "application/x-www-form-urlencoded"

        headers["Accept"] = "application/json"

        return self._version.create_with_response_info(
            method="POST", uri=self._uri, data=data, headers=headers
        )

    def create(
        self,
        notification_email: Union[str, object] = values.unset,
        theme_set_id: Union[str, object] = values.unset,
        primary_profile_sid: Union[str, object] = values.unset,
    ) -> ComplianceInquiriesInstance:
        """
        Create the ComplianceInquiriesInstance

        :param notification_email: The email address that approval status updates will be sent to. If not specified, the email address associated with your primary customer profile will be used.
        :param theme_set_id: Theme id for styling the inquiry form.
        :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile.

        :returns: The created ComplianceInquiriesInstance
        """
        payload, _, _ = self._create(
            notification_email=notification_email,
            theme_set_id=theme_set_id,
            primary_profile_sid=primary_profile_sid,
        )
        return ComplianceInquiriesInstance(self._version, payload)

    def create_with_http_info(
        self,
        notification_email: Union[str, object] = values.unset,
        theme_set_id: Union[str, object] = values.unset,
        primary_profile_sid: Union[str, object] = values.unset,
    ) -> ApiResponse:
        """
        Create the ComplianceInquiriesInstance and return response metadata

        :param notification_email: The email address that approval status updates will be sent to. If not specified, the email address associated with your primary customer profile will be used.
        :param theme_set_id: Theme id for styling the inquiry form.
        :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile.

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._create(
            notification_email=notification_email,
            theme_set_id=theme_set_id,
            primary_profile_sid=primary_profile_sid,
        )
        instance = ComplianceInquiriesInstance(self._version, payload)
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    async def _create_async(
        self,
        notification_email: Union[str, object] = values.unset,
        theme_set_id: Union[str, object] = values.unset,
        primary_profile_sid: Union[str, object] = values.unset,
    ) -> tuple:
        """
        Internal async helper for create operation

        Returns:
            tuple: (payload, status_code, headers)
        """

        data = values.of(
            {
                "NotificationEmail": notification_email,
                "ThemeSetId": theme_set_id,
                "PrimaryProfileSid": primary_profile_sid,
            }
        )
        headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})

        headers["Content-Type"] = "application/x-www-form-urlencoded"

        headers["Accept"] = "application/json"

        return await self._version.create_with_response_info_async(
            method="POST", uri=self._uri, data=data, headers=headers
        )

    async def create_async(
        self,
        notification_email: Union[str, object] = values.unset,
        theme_set_id: Union[str, object] = values.unset,
        primary_profile_sid: Union[str, object] = values.unset,
    ) -> ComplianceInquiriesInstance:
        """
        Asynchronously create the ComplianceInquiriesInstance

        :param notification_email: The email address that approval status updates will be sent to. If not specified, the email address associated with your primary customer profile will be used.
        :param theme_set_id: Theme id for styling the inquiry form.
        :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile.

        :returns: The created ComplianceInquiriesInstance
        """
        payload, _, _ = await self._create_async(
            notification_email=notification_email,
            theme_set_id=theme_set_id,
            primary_profile_sid=primary_profile_sid,
        )
        return ComplianceInquiriesInstance(self._version, payload)

    async def create_with_http_info_async(
        self,
        notification_email: Union[str, object] = values.unset,
        theme_set_id: Union[str, object] = values.unset,
        primary_profile_sid: Union[str, object] = values.unset,
    ) -> ApiResponse:
        """
        Asynchronously create the ComplianceInquiriesInstance and return response metadata

        :param notification_email: The email address that approval status updates will be sent to. If not specified, the email address associated with your primary customer profile will be used.
        :param theme_set_id: Theme id for styling the inquiry form.
        :param primary_profile_sid: The unique SID identifier of the Primary Customer Profile that should be used as a parent. Only necessary when creating a secondary Customer Profile.

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._create_async(
            notification_email=notification_email,
            theme_set_id=theme_set_id,
            primary_profile_sid=primary_profile_sid,
        )
        instance = ComplianceInquiriesInstance(self._version, payload)
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    def get(self, customer_id: str) -> ComplianceInquiriesContext:
        """
        Constructs a ComplianceInquiriesContext

        :param customer_id: The unique CustomerId matching the Customer Profile/Compliance Inquiry that should be resumed or resubmitted. This value will have been returned by the initial Compliance Inquiry creation call.
        """
        return ComplianceInquiriesContext(self._version, customer_id=customer_id)

    def __call__(self, customer_id: str) -> ComplianceInquiriesContext:
        """
        Constructs a ComplianceInquiriesContext

        :param customer_id: The unique CustomerId matching the Customer Profile/Compliance Inquiry that should be resumed or resubmitted. This value will have been returned by the initial Compliance Inquiry creation call.
        """
        return ComplianceInquiriesContext(self._version, customer_id=customer_id)

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """
        return "<Twilio.Trusthub.V1.ComplianceInquiriesList>"
