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

    Twilio - Marketplace
    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 ReferralConversionInstance(InstanceResource):

    class CreateReferralConversionRequest(object):
        """
        :ivar referral_account_sid:
        """

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

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

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

    """
    :ivar converted_account_sid: 
    """

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

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

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

        :returns: Machine friendly representation
        """

        return "<Twilio.Marketplace.V1.ReferralConversionInstance>"


class ReferralConversionList(ListResource):

    class CreateReferralConversionRequest(object):
        """
        :ivar referral_account_sid:
        """

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

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

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

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

        :param version: Version that contains the resource

        """
        super().__init__(version)

        self._uri = "/ReferralConversion"

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

        Returns:
            tuple: (payload, status_code, headers)
        """
        data = create_referral_conversion_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, create_referral_conversion_request: CreateReferralConversionRequest
    ) -> ReferralConversionInstance:
        """
        Create the ReferralConversionInstance

        :param create_referral_conversion_request:

        :returns: The created ReferralConversionInstance
        """
        payload, _, _ = self._create(
            create_referral_conversion_request=create_referral_conversion_request
        )
        return ReferralConversionInstance(self._version, payload)

    def create_with_http_info(
        self, create_referral_conversion_request: CreateReferralConversionRequest
    ) -> ApiResponse:
        """
        Create the ReferralConversionInstance and return response metadata

        :param create_referral_conversion_request:

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._create(
            create_referral_conversion_request=create_referral_conversion_request
        )
        instance = ReferralConversionInstance(self._version, payload)
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

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

        Returns:
            tuple: (payload, status_code, headers)
        """
        data = create_referral_conversion_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, create_referral_conversion_request: CreateReferralConversionRequest
    ) -> ReferralConversionInstance:
        """
        Asynchronously create the ReferralConversionInstance

        :param create_referral_conversion_request:

        :returns: The created ReferralConversionInstance
        """
        payload, _, _ = await self._create_async(
            create_referral_conversion_request=create_referral_conversion_request
        )
        return ReferralConversionInstance(self._version, payload)

    async def create_with_http_info_async(
        self, create_referral_conversion_request: CreateReferralConversionRequest
    ) -> ApiResponse:
        """
        Asynchronously create the ReferralConversionInstance and return response metadata

        :param create_referral_conversion_request:

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._create_async(
            create_referral_conversion_request=create_referral_conversion_request
        )
        instance = ReferralConversionInstance(self._version, payload)
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

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

        :returns: Machine friendly representation
        """
        return "<Twilio.Marketplace.V1.ReferralConversionList>"
