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

    Twilio - Intelligence
    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, List, Optional, Union
from twilio.base import serialize, 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 EncryptedOperatorResultsInstance(InstanceResource):
    """
    :ivar locations: The locations of the encrypted operator results.
    :ivar transcript_sid:
    :ivar url:
    """

    def __init__(self, version: Version, payload: Dict[str, Any], transcript_sid: str):
        super().__init__(version)

        self.locations: Optional[List[str]] = payload.get("locations")
        self.transcript_sid: Optional[str] = payload.get("transcript_sid")
        self.url: Optional[str] = payload.get("url")

        self._solution = {
            "transcript_sid": transcript_sid,
        }
        self._context: Optional[EncryptedOperatorResultsContext] = None

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

        :returns: EncryptedOperatorResultsContext for this EncryptedOperatorResultsInstance
        """
        if self._context is None:
            self._context = EncryptedOperatorResultsContext(
                self._version,
                transcript_sid=self._solution["transcript_sid"],
            )
        return self._context

    def fetch(
        self, redacted: Union[bool, object] = values.unset
    ) -> "EncryptedOperatorResultsInstance":
        """
        Fetch the EncryptedOperatorResultsInstance

        :param redacted: Grant access to PII Redacted/Unredacted Operator Results. If redaction is enabled, the default is `true` to access redacted operator results.

        :returns: The fetched EncryptedOperatorResultsInstance
        """
        return self._proxy.fetch(
            redacted=redacted,
        )

    async def fetch_async(
        self, redacted: Union[bool, object] = values.unset
    ) -> "EncryptedOperatorResultsInstance":
        """
        Asynchronous coroutine to fetch the EncryptedOperatorResultsInstance

        :param redacted: Grant access to PII Redacted/Unredacted Operator Results. If redaction is enabled, the default is `true` to access redacted operator results.

        :returns: The fetched EncryptedOperatorResultsInstance
        """
        return await self._proxy.fetch_async(
            redacted=redacted,
        )

    def fetch_with_http_info(
        self, redacted: Union[bool, object] = values.unset
    ) -> ApiResponse:
        """
        Fetch the EncryptedOperatorResultsInstance with HTTP info

        :param redacted: Grant access to PII Redacted/Unredacted Operator Results. If redaction is enabled, the default is `true` to access redacted operator results.

        :returns: ApiResponse with instance, status code, and headers
        """
        return self._proxy.fetch_with_http_info(
            redacted=redacted,
        )

    async def fetch_with_http_info_async(
        self, redacted: Union[bool, object] = values.unset
    ) -> ApiResponse:
        """
        Asynchronous coroutine to fetch the EncryptedOperatorResultsInstance with HTTP info

        :param redacted: Grant access to PII Redacted/Unredacted Operator Results. If redaction is enabled, the default is `true` to access redacted operator results.

        :returns: ApiResponse with instance, status code, and headers
        """
        return await self._proxy.fetch_with_http_info_async(
            redacted=redacted,
        )

    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.Intelligence.V2.EncryptedOperatorResultsInstance {}>".format(
            context
        )


class EncryptedOperatorResultsContext(InstanceContext):

    def __init__(self, version: Version, transcript_sid: str):
        """
        Initialize the EncryptedOperatorResultsContext

        :param version: Version that contains the resource
        :param transcript_sid: The unique SID identifier of the Transcript.
        """
        super().__init__(version)

        # Path Solution
        self._solution = {
            "transcript_sid": transcript_sid,
        }
        self._uri = "/Transcripts/{transcript_sid}/OperatorResults/Encrypted".format(
            **self._solution
        )

    def _fetch(self, redacted: Union[bool, object] = values.unset) -> tuple:
        """
        Internal helper for fetch operation

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

        params = values.of(
            {
                "Redacted": serialize.boolean_to_string(redacted),
            }
        )

        headers = values.of({})

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

        return self._version.fetch_with_response_info(
            method="GET", uri=self._uri, params=params, headers=headers
        )

    def fetch(
        self, redacted: Union[bool, object] = values.unset
    ) -> EncryptedOperatorResultsInstance:
        """
        Fetch the EncryptedOperatorResultsInstance

        :param redacted: Grant access to PII Redacted/Unredacted Operator Results. If redaction is enabled, the default is `true` to access redacted operator results.

        :returns: The fetched EncryptedOperatorResultsInstance
        """
        payload, _, _ = self._fetch(redacted=redacted)
        return EncryptedOperatorResultsInstance(
            self._version,
            payload,
            transcript_sid=self._solution["transcript_sid"],
        )

    def fetch_with_http_info(
        self, redacted: Union[bool, object] = values.unset
    ) -> ApiResponse:
        """
        Fetch the EncryptedOperatorResultsInstance and return response metadata

        :param redacted: Grant access to PII Redacted/Unredacted Operator Results. If redaction is enabled, the default is `true` to access redacted operator results.

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._fetch(redacted=redacted)
        instance = EncryptedOperatorResultsInstance(
            self._version,
            payload,
            transcript_sid=self._solution["transcript_sid"],
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    async def _fetch_async(self, redacted: Union[bool, object] = values.unset) -> tuple:
        """
        Internal async helper for fetch operation

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

        params = values.of(
            {
                "Redacted": serialize.boolean_to_string(redacted),
            }
        )

        headers = values.of({})

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

        return await self._version.fetch_with_response_info_async(
            method="GET", uri=self._uri, params=params, headers=headers
        )

    async def fetch_async(
        self, redacted: Union[bool, object] = values.unset
    ) -> EncryptedOperatorResultsInstance:
        """
        Asynchronous coroutine to fetch the EncryptedOperatorResultsInstance

        :param redacted: Grant access to PII Redacted/Unredacted Operator Results. If redaction is enabled, the default is `true` to access redacted operator results.

        :returns: The fetched EncryptedOperatorResultsInstance
        """
        payload, _, _ = await self._fetch_async(redacted=redacted)
        return EncryptedOperatorResultsInstance(
            self._version,
            payload,
            transcript_sid=self._solution["transcript_sid"],
        )

    async def fetch_with_http_info_async(
        self, redacted: Union[bool, object] = values.unset
    ) -> ApiResponse:
        """
        Asynchronous coroutine to fetch the EncryptedOperatorResultsInstance and return response metadata

        :param redacted: Grant access to PII Redacted/Unredacted Operator Results. If redaction is enabled, the default is `true` to access redacted operator results.

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._fetch_async(redacted=redacted)
        instance = EncryptedOperatorResultsInstance(
            self._version,
            payload,
            transcript_sid=self._solution["transcript_sid"],
        )
        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.Intelligence.V2.EncryptedOperatorResultsContext {}>".format(
            context
        )


class EncryptedOperatorResultsList(ListResource):

    def __init__(self, version: Version, transcript_sid: str):
        """
        Initialize the EncryptedOperatorResultsList

        :param version: Version that contains the resource
        :param transcript_sid: The unique SID identifier of the Transcript.

        """
        super().__init__(version)

        # Path Solution
        self._solution = {
            "transcript_sid": transcript_sid,
        }

    def get(self) -> EncryptedOperatorResultsContext:
        """
        Constructs a EncryptedOperatorResultsContext

        """
        return EncryptedOperatorResultsContext(
            self._version, transcript_sid=self._solution["transcript_sid"]
        )

    def __call__(self) -> EncryptedOperatorResultsContext:
        """
        Constructs a EncryptedOperatorResultsContext

        """
        return EncryptedOperatorResultsContext(
            self._version, transcript_sid=self._solution["transcript_sid"]
        )

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

        :returns: Machine friendly representation
        """
        return "<Twilio.Intelligence.V2.EncryptedOperatorResultsList>"
