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

    Twilio - Numbers
    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
from twilio.base import values
from twilio.base.api_response import ApiResponse

from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version


class EmbeddedSessionInstance(InstanceResource):

    class NumbersV1CreateEmbeddedSessionRequest(object):
        """
        :ivar theme_set_id: Theme ID for the Compliance Embeddable UI. Overrides the theme set during registration creation.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.theme_set_id: Optional[str] = payload.get("themeSetId")

        def to_dict(self):
            return {
                "themeSetId": self.theme_set_id,
            }

    """
    :ivar id: Registration identifier (BU-prefixed).
    :ivar session_id: Session ID for the compliance embeddable.
    :ivar session_token: Ephemeral session token for the compliance embeddable.
    """

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

        self.id: Optional[str] = payload.get("id")
        self.session_id: Optional[str] = payload.get("sessionId")
        self.session_token: Optional[str] = payload.get("sessionToken")

        self._solution = {
            "bundle_sid": bundle_sid or self.bundle_sid,
        }

    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.Numbers.V1.EmbeddedSessionInstance {}>".format(context)


class EmbeddedSessionList(ListResource):

    class NumbersV1CreateEmbeddedSessionRequest(object):
        """
        :ivar theme_set_id: Theme ID for the Compliance Embeddable UI. Overrides the theme set during registration creation.
        """

        def __init__(self, payload: Dict[str, Any]):

            self.theme_set_id: Optional[str] = payload.get("themeSetId")

        def to_dict(self):
            return {
                "themeSetId": self.theme_set_id,
            }

    def __init__(self, version: Version, bundle_sid: str):
        """
        Initialize the EmbeddedSessionList

        :param version: Version that contains the resource
        :param bundle_sid: The unique identifier of the registration (BU-prefixed).

        """
        super().__init__(version)

        # Path Solution
        self._solution = {
            "bundle_sid": bundle_sid,
        }
        self._uri = "/SenderIdRegistrations/{bundle_sid}/EmbeddedSessions".format(
            **self._solution
        )

    def _create(
        self,
        numbers_v1_create_embedded_session_request: NumbersV1CreateEmbeddedSessionRequest,
    ) -> tuple:
        """
        Internal helper for create operation

        Returns:
            tuple: (payload, status_code, headers)
        """
        data = numbers_v1_create_embedded_session_request.to_dict()

        headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})

        headers["Content-Type"] = "application/json"

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

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

    def create(
        self,
        numbers_v1_create_embedded_session_request: NumbersV1CreateEmbeddedSessionRequest,
    ) -> EmbeddedSessionInstance:
        """
        Create the EmbeddedSessionInstance

        :param numbers_v1_create_embedded_session_request:

        :returns: The created EmbeddedSessionInstance
        """
        payload, _, _ = self._create(
            numbers_v1_create_embedded_session_request=numbers_v1_create_embedded_session_request
        )
        return EmbeddedSessionInstance(
            self._version, payload, bundle_sid=self._solution["bundle_sid"]
        )

    def create_with_http_info(
        self,
        numbers_v1_create_embedded_session_request: NumbersV1CreateEmbeddedSessionRequest,
    ) -> ApiResponse:
        """
        Create the EmbeddedSessionInstance and return response metadata

        :param numbers_v1_create_embedded_session_request:

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._create(
            numbers_v1_create_embedded_session_request=numbers_v1_create_embedded_session_request
        )
        instance = EmbeddedSessionInstance(
            self._version, payload, bundle_sid=self._solution["bundle_sid"]
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    async def _create_async(
        self,
        numbers_v1_create_embedded_session_request: NumbersV1CreateEmbeddedSessionRequest,
    ) -> tuple:
        """
        Internal async helper for create operation

        Returns:
            tuple: (payload, status_code, headers)
        """
        data = numbers_v1_create_embedded_session_request.to_dict()

        headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})

        headers["Content-Type"] = "application/json"

        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,
        numbers_v1_create_embedded_session_request: NumbersV1CreateEmbeddedSessionRequest,
    ) -> EmbeddedSessionInstance:
        """
        Asynchronously create the EmbeddedSessionInstance

        :param numbers_v1_create_embedded_session_request:

        :returns: The created EmbeddedSessionInstance
        """
        payload, _, _ = await self._create_async(
            numbers_v1_create_embedded_session_request=numbers_v1_create_embedded_session_request
        )
        return EmbeddedSessionInstance(
            self._version, payload, bundle_sid=self._solution["bundle_sid"]
        )

    async def create_with_http_info_async(
        self,
        numbers_v1_create_embedded_session_request: NumbersV1CreateEmbeddedSessionRequest,
    ) -> ApiResponse:
        """
        Asynchronously create the EmbeddedSessionInstance and return response metadata

        :param numbers_v1_create_embedded_session_request:

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._create_async(
            numbers_v1_create_embedded_session_request=numbers_v1_create_embedded_session_request
        )
        instance = EmbeddedSessionInstance(
            self._version, payload, bundle_sid=self._solution["bundle_sid"]
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

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

        :returns: Machine friendly representation
        """
        return "<Twilio.Numbers.V1.EmbeddedSessionList>"
