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, 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 EncryptedSentencesInstance(InstanceResource):
    """
    :ivar location: The location of the encrypted sentences.
    :ivar transcript_sid:
    :ivar url:
    """

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

        self.location: Optional[str] = payload.get("location")
        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[EncryptedSentencesContext] = None

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

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

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

        :param redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences.

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

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

        :param redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences.

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

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

        :param redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences.

        :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 EncryptedSentencesInstance with HTTP info

        :param redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences.

        :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.EncryptedSentencesInstance {}>".format(context)


class EncryptedSentencesContext(InstanceContext):

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

        :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}/Sentences/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
    ) -> EncryptedSentencesInstance:
        """
        Fetch the EncryptedSentencesInstance

        :param redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences.

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

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

        :param redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences.

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._fetch(redacted=redacted)
        instance = EncryptedSentencesInstance(
            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
    ) -> EncryptedSentencesInstance:
        """
        Asynchronous coroutine to fetch the EncryptedSentencesInstance

        :param redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences.

        :returns: The fetched EncryptedSentencesInstance
        """
        payload, _, _ = await self._fetch_async(redacted=redacted)
        return EncryptedSentencesInstance(
            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 EncryptedSentencesInstance and return response metadata

        :param redacted: Grant access to PII Redacted/Unredacted Sentences. If redaction is enabled, the default is `true` to access redacted sentences.

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._fetch_async(redacted=redacted)
        instance = EncryptedSentencesInstance(
            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.EncryptedSentencesContext {}>".format(context)


class EncryptedSentencesList(ListResource):

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

        :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) -> EncryptedSentencesContext:
        """
        Constructs a EncryptedSentencesContext

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

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

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

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

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