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

    Twilio - Content
    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 Optional
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 ApprovalFetchInstance(InstanceResource):
    def __init__(self, version, payload, sid: str):
        """
        Initialize the ApprovalFetchInstance

        :returns: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchInstance
        :rtype: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchInstance
        """
        super().__init__(version)

        self._properties = {
            "sid": payload.get("sid"),
            "account_sid": payload.get("account_sid"),
            "whatsapp": payload.get("whatsapp"),
            "url": payload.get("url"),
        }

        self._solution = {
            "sid": sid,
        }
        self._context: Optional[ApprovalFetchContext] = None

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

        :returns: ApprovalFetchContext for this ApprovalFetchInstance
        :rtype: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchContext
        """
        if self._context is None:
            self._context = ApprovalFetchContext(
                self._version,
                sid=self._solution["sid"],
            )
        return self._context

    @property
    def sid(self):
        """
        :returns: The unique string that that we created to identify the Content resource.
        :rtype: str
        """
        return self._properties["sid"]

    @property
    def account_sid(self):
        """
        :returns: The SID of the [Account](https://www.twilio.com/docs/usage/api/account) that created Content resource.
        :rtype: str
        """
        return self._properties["account_sid"]

    @property
    def whatsapp(self):
        """
        :returns: Contains the whatsapp approval information for the Content resource, with fields such as approval status, rejection reason, and category, amongst others.
        :rtype: dict
        """
        return self._properties["whatsapp"]

    @property
    def url(self):
        """
        :returns: The URL of the resource, relative to `https://content.twilio.com`.
        :rtype: str
        """
        return self._properties["url"]

    def fetch(self):
        """
        Fetch the ApprovalFetchInstance


        :returns: The fetched ApprovalFetchInstance
        :rtype: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchInstance
        """
        return self._proxy.fetch()

    async def fetch_async(self):
        """
        Asynchronous coroutine to fetch the ApprovalFetchInstance


        :returns: The fetched ApprovalFetchInstance
        :rtype: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchInstance
        """
        return await self._proxy.fetch_async()

    def __repr__(self):
        """
        Provide a friendly representation

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


class ApprovalFetchContext(InstanceContext):
    def __init__(self, version: Version, sid: str):
        """
        Initialize the ApprovalFetchContext

        :param Version version: Version that contains the resource
        :param sid: The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch.

        :returns: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchContext
        :rtype: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchContext
        """
        super().__init__(version)

        # Path Solution
        self._solution = {
            "sid": sid,
        }
        self._uri = "/Content/{sid}/ApprovalRequests".format(**self._solution)

    def fetch(self):
        """
        Fetch the ApprovalFetchInstance


        :returns: The fetched ApprovalFetchInstance
        :rtype: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchInstance
        """

        payload = self._version.fetch(
            method="GET",
            uri=self._uri,
        )

        return ApprovalFetchInstance(
            self._version,
            payload,
            sid=self._solution["sid"],
        )

    async def fetch_async(self):
        """
        Asynchronous coroutine to fetch the ApprovalFetchInstance


        :returns: The fetched ApprovalFetchInstance
        :rtype: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchInstance
        """

        payload = await self._version.fetch_async(
            method="GET",
            uri=self._uri,
        )

        return ApprovalFetchInstance(
            self._version,
            payload,
            sid=self._solution["sid"],
        )

    def __repr__(self):
        """
        Provide a friendly representation

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


class ApprovalFetchList(ListResource):
    def __init__(self, version: Version, sid: str):
        """
        Initialize the ApprovalFetchList

        :param Version version: Version that contains the resource
        :param sid: The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch.

        :returns: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchList
        :rtype: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchList
        """
        super().__init__(version)

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

    def get(self):
        """
        Constructs a ApprovalFetchContext


        :returns: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchContext
        :rtype: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchContext
        """
        return ApprovalFetchContext(self._version, sid=self._solution["sid"])

    def __call__(self):
        """
        Constructs a ApprovalFetchContext


        :returns: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchContext
        :rtype: twilio.rest.content.v1.content.approval_fetch.ApprovalFetchContext
        """
        return ApprovalFetchContext(self._version, sid=self._solution["sid"])

    def __repr__(self):
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        :rtype: str
        """
        return "<Twilio.Content.V1.ApprovalFetchList>"
