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 datetime import datetime
from typing import Any, Dict, List, Optional, Union
from twilio.base import deserialize, serialize, values

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


class HostedNumberOrderInstance(InstanceResource):

    class Status(object):
        TWILIO_PROCESSING = "twilio-processing"
        RECEIVED = "received"
        PENDING_VERIFICATION = "pending-verification"
        VERIFIED = "verified"
        PENDING_LOA = "pending-loa"
        CARRIER_PROCESSING = "carrier-processing"
        TESTING = "testing"
        COMPLETED = "completed"
        FAILED = "failed"
        ACTION_REQUIRED = "action-required"

    class VerificationType(object):
        PHONE_CALL = "phone-call"
        PHONE_BILL = "phone-bill"

    """
    :ivar sid: A 34 character string that uniquely identifies this HostedNumberOrder.
    :ivar account_sid: A 34 character string that uniquely identifies the account.
    :ivar incoming_phone_number_sid: A 34 character string that uniquely identifies the [IncomingPhoneNumber](https://www.twilio.com/docs/phone-numbers/api/incomingphonenumber-resource) resource that represents the phone number being hosted.
    :ivar address_sid: A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number.
    :ivar signing_document_sid: A 34 character string that uniquely identifies the [Authorization Document](https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/authorization-document-resource) the user needs to sign.
    :ivar phone_number: Phone number to be hosted. This must be in [E.164](https://en.wikipedia.org/wiki/E.164) format, e.g., +16175551212
    :ivar capabilities: 
    :ivar friendly_name: A 64 character string that is a human-readable text that describes this resource.
    :ivar unique_name: Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
    :ivar status: 
    :ivar failure_reason: A message that explains why a hosted_number_order went to status \"action-required\"
    :ivar date_created: The date this resource was created, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
    :ivar date_updated: The date that this resource was updated, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
    :ivar verification_attempts: The number of attempts made to verify ownership of the phone number that is being hosted.
    :ivar email: Email of the owner of this phone number that is being hosted.
    :ivar cc_emails: A list of emails that LOA document for this HostedNumberOrder will be carbon copied to.
    :ivar url: The URL of this HostedNumberOrder.
    :ivar verification_type: 
    :ivar verification_document_sid: A 34 character string that uniquely identifies the Identity Document resource that represents the document for verifying ownership of the number to be hosted.
    :ivar extension: A numerical extension to be used when making the ownership verification call.
    :ivar call_delay: A value between 0-30 specifying the number of seconds to delay initiating the ownership verification call.
    :ivar verification_code: A verification code provided in the response for a user to enter when they pick up the phone call.
    :ivar verification_call_sids: A list of 34 character strings that are unique identifiers for the calls placed as part of ownership verification.
    """

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

        self.sid: Optional[str] = payload.get("sid")
        self.account_sid: Optional[str] = payload.get("accountSid")
        self.incoming_phone_number_sid: Optional[str] = payload.get(
            "incomingPhoneNumberSid"
        )
        self.address_sid: Optional[str] = payload.get("addressSid")
        self.signing_document_sid: Optional[str] = payload.get("signingDocumentSid")
        self.phone_number: Optional[str] = payload.get("phoneNumber")
        self.capabilities: Optional[str] = payload.get("capabilities")
        self.friendly_name: Optional[str] = payload.get("friendlyName")
        self.unique_name: Optional[str] = payload.get("uniqueName")
        self.status: Optional["HostedNumberOrderInstance.Status"] = payload.get(
            "status"
        )
        self.failure_reason: Optional[str] = payload.get("failureReason")
        self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
            payload.get("dateCreated")
        )
        self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
            payload.get("dateUpdated")
        )
        self.verification_attempts: Optional[int] = deserialize.integer(
            payload.get("verificationAttempts")
        )
        self.email: Optional[str] = payload.get("email")
        self.cc_emails: Optional[List[str]] = payload.get("ccEmails")
        self.url: Optional[str] = payload.get("url")
        self.verification_type: Optional[
            "HostedNumberOrderInstance.VerificationType"
        ] = payload.get("verificationType")
        self.verification_document_sid: Optional[str] = payload.get(
            "verificationDocumentSid"
        )
        self.extension: Optional[str] = payload.get("extension")
        self.call_delay: Optional[int] = deserialize.integer(payload.get("callDelay"))
        self.verification_code: Optional[str] = payload.get("verificationCode")
        self.verification_call_sids: Optional[List[str]] = payload.get(
            "verificationCallSids"
        )

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

        :returns: Machine friendly representation
        """

        return "<Twilio.Numbers.V3.HostedNumberOrderInstance>"


class HostedNumberOrderList(ListResource):

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

        :param version: Version that contains the resource

        """
        super().__init__(version)

        self._uri = "/HostedNumbers/HostedNumberOrders"

    def create(
        self,
        phone_number: str,
        sms_capability: bool,
        account_sid: Union[str, object] = values.unset,
        friendly_name: Union[str, object] = values.unset,
        unique_name: Union[str, object] = values.unset,
        cc_emails: Union[List[str], object] = values.unset,
        sms_url: Union[str, object] = values.unset,
        sms_method: Union[str, object] = values.unset,
        sms_fallback_url: Union[str, object] = values.unset,
        sms_fallback_method: Union[str, object] = values.unset,
        status_callback_url: Union[str, object] = values.unset,
        status_callback_method: Union[str, object] = values.unset,
        sms_application_sid: Union[str, object] = values.unset,
        address_sid: Union[str, object] = values.unset,
        email: Union[str, object] = values.unset,
        verification_type: Union[
            "HostedNumberOrderInstance.VerificationType", object
        ] = values.unset,
        verification_document_sid: Union[str, object] = values.unset,
    ) -> HostedNumberOrderInstance:
        """
        Create the HostedNumberOrderInstance

        :param phone_number: The number to host in [+E.164](https://en.wikipedia.org/wiki/E.164) format
        :param sms_capability: Used to specify that the SMS capability will be hosted on Twilio's platform.
        :param account_sid: This defaults to the AccountSid of the authorization the user is using. This can be provided to specify a subaccount to add the HostedNumberOrder to.
        :param friendly_name: A 64 character string that is a human readable text that describes this resource.
        :param unique_name: Optional. Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
        :param cc_emails: Optional. A list of emails that the LOA document for this HostedNumberOrder will be carbon copied to.
        :param sms_url: The URL that Twilio should request when somebody sends an SMS to the phone number. This will be copied onto the IncomingPhoneNumber resource.
        :param sms_method: The HTTP method that should be used to request the SmsUrl. Must be either `GET` or `POST`.  This will be copied onto the IncomingPhoneNumber resource.
        :param sms_fallback_url: A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl. This will be copied onto the IncomingPhoneNumber resource.
        :param sms_fallback_method: The HTTP method that should be used to request the SmsFallbackUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource.
        :param status_callback_url: Optional. The Status Callback URL attached to the IncomingPhoneNumber resource.
        :param status_callback_method: Optional. The Status Callback Method attached to the IncomingPhoneNumber resource.
        :param sms_application_sid: Optional. The 34 character sid of the application Twilio should use to handle SMS messages sent to this number. If a `SmsApplicationSid` is present, Twilio will ignore all of the SMS urls above and use those set on the application.
        :param address_sid: Optional. A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number.
        :param email: Optional. Email of the owner of this phone number that is being hosted.
        :param verification_type:
        :param verification_document_sid: Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill.

        :returns: The created HostedNumberOrderInstance
        """

        data = values.of(
            {
                "phoneNumber": phone_number,
                "smsCapability": serialize.boolean_to_string(sms_capability),
                "accountSid": account_sid,
                "friendlyName": friendly_name,
                "uniqueName": unique_name,
                "ccEmails": serialize.map(cc_emails, lambda e: e),
                "smsUrl": sms_url,
                "smsMethod": sms_method,
                "smsFallbackUrl": sms_fallback_url,
                "smsFallbackMethod": sms_fallback_method,
                "statusCallbackUrl": status_callback_url,
                "statusCallbackMethod": status_callback_method,
                "smsApplicationSid": sms_application_sid,
                "addressSid": address_sid,
                "email": email,
                "verificationType": verification_type,
                "verificationDocumentSid": verification_document_sid,
            }
        )
        headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})

        headers["Content-Type"] = "application/x-www-form-urlencoded"

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

        payload = self._version.create(
            method="POST", uri=self._uri, data=data, headers=headers
        )

        return HostedNumberOrderInstance(self._version, payload)

    async def create_async(
        self,
        phone_number: str,
        sms_capability: bool,
        account_sid: Union[str, object] = values.unset,
        friendly_name: Union[str, object] = values.unset,
        unique_name: Union[str, object] = values.unset,
        cc_emails: Union[List[str], object] = values.unset,
        sms_url: Union[str, object] = values.unset,
        sms_method: Union[str, object] = values.unset,
        sms_fallback_url: Union[str, object] = values.unset,
        sms_fallback_method: Union[str, object] = values.unset,
        status_callback_url: Union[str, object] = values.unset,
        status_callback_method: Union[str, object] = values.unset,
        sms_application_sid: Union[str, object] = values.unset,
        address_sid: Union[str, object] = values.unset,
        email: Union[str, object] = values.unset,
        verification_type: Union[
            "HostedNumberOrderInstance.VerificationType", object
        ] = values.unset,
        verification_document_sid: Union[str, object] = values.unset,
    ) -> HostedNumberOrderInstance:
        """
        Asynchronously create the HostedNumberOrderInstance

        :param phone_number: The number to host in [+E.164](https://en.wikipedia.org/wiki/E.164) format
        :param sms_capability: Used to specify that the SMS capability will be hosted on Twilio's platform.
        :param account_sid: This defaults to the AccountSid of the authorization the user is using. This can be provided to specify a subaccount to add the HostedNumberOrder to.
        :param friendly_name: A 64 character string that is a human readable text that describes this resource.
        :param unique_name: Optional. Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
        :param cc_emails: Optional. A list of emails that the LOA document for this HostedNumberOrder will be carbon copied to.
        :param sms_url: The URL that Twilio should request when somebody sends an SMS to the phone number. This will be copied onto the IncomingPhoneNumber resource.
        :param sms_method: The HTTP method that should be used to request the SmsUrl. Must be either `GET` or `POST`.  This will be copied onto the IncomingPhoneNumber resource.
        :param sms_fallback_url: A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl. This will be copied onto the IncomingPhoneNumber resource.
        :param sms_fallback_method: The HTTP method that should be used to request the SmsFallbackUrl. Must be either `GET` or `POST`. This will be copied onto the IncomingPhoneNumber resource.
        :param status_callback_url: Optional. The Status Callback URL attached to the IncomingPhoneNumber resource.
        :param status_callback_method: Optional. The Status Callback Method attached to the IncomingPhoneNumber resource.
        :param sms_application_sid: Optional. The 34 character sid of the application Twilio should use to handle SMS messages sent to this number. If a `SmsApplicationSid` is present, Twilio will ignore all of the SMS urls above and use those set on the application.
        :param address_sid: Optional. A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number.
        :param email: Optional. Email of the owner of this phone number that is being hosted.
        :param verification_type:
        :param verification_document_sid: Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill.

        :returns: The created HostedNumberOrderInstance
        """

        data = values.of(
            {
                "phoneNumber": phone_number,
                "smsCapability": serialize.boolean_to_string(sms_capability),
                "accountSid": account_sid,
                "friendlyName": friendly_name,
                "uniqueName": unique_name,
                "ccEmails": serialize.map(cc_emails, lambda e: e),
                "smsUrl": sms_url,
                "smsMethod": sms_method,
                "smsFallbackUrl": sms_fallback_url,
                "smsFallbackMethod": sms_fallback_method,
                "statusCallbackUrl": status_callback_url,
                "statusCallbackMethod": status_callback_method,
                "smsApplicationSid": sms_application_sid,
                "addressSid": address_sid,
                "email": email,
                "verificationType": verification_type,
                "verificationDocumentSid": verification_document_sid,
            }
        )
        headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})

        headers["Content-Type"] = "application/x-www-form-urlencoded"

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

        payload = await self._version.create_async(
            method="POST", uri=self._uri, data=data, headers=headers
        )

        return HostedNumberOrderInstance(self._version, payload)

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

        :returns: Machine friendly representation
        """
        return "<Twilio.Numbers.V3.HostedNumberOrderList>"
