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, Optional
from twilio.base import deserialize, 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 SenderIdRegistrationInstance(InstanceResource):

    class NumbersV1CreateEmbeddedRegistrationRequest(object):
        """
        :ivar regulation_id: The regulation for this registration.
        :ivar regulation_version: The regulation version.
        :ivar friendly_name: Human-readable name for the registration.
        :ivar status_notification_email: Email address for registration status notifications.
        :ivar status_callback_url: The URL of this resource.
        :ivar comments: Additional comments about the registration.
        :ivar theme_set_id: Theme ID for the Compliance Embeddable UI.
        :ivar data: Registration data organized by section (alphanumericSender, business, useCase, authorizedRepresentative, officer, businessAddress).
        """

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

            self.regulation_id: Optional[str] = payload.get("regulationId")
            self.regulation_version: Optional[int] = payload.get("regulationVersion")
            self.friendly_name: Optional[str] = payload.get("friendlyName")
            self.status_notification_email: Optional[str] = payload.get(
                "statusNotificationEmail"
            )
            self.status_callback_url: Optional[str] = payload.get("statusCallbackUrl")
            self.comments: Optional[str] = payload.get("comments")
            self.theme_set_id: Optional[str] = payload.get("themeSetId")
            self.data: Optional[Dict[str, object]] = payload.get("data")

        def to_dict(self):
            return {
                "regulationId": self.regulation_id,
                "regulationVersion": self.regulation_version,
                "friendlyName": self.friendly_name,
                "statusNotificationEmail": self.status_notification_email,
                "statusCallbackUrl": self.status_callback_url,
                "comments": self.comments,
                "themeSetId": self.theme_set_id,
                "data": self.data,
            }

    """
    :ivar id: Registration identifier (BU-prefixed).
    :ivar regulation_id: The regulation ID for this registration.
    :ivar regulation_version: The regulation version.
    :ivar friendly_name: The friendly name provided in the request.
    :ivar status: Registration status. Always DRAFT on creation.
    :ivar status_notification_email: Email address for status notifications.
    :ivar status_callback_url: Callback URL for status webhooks.
    :ivar comments: Additional comments.
    :ivar embedded_session: 
    :ivar data: Registration data echoed from the request.
    :ivar date_created: Timestamp of creation.
    :ivar date_updated: Timestamp of last update.
    """

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

        self.id: Optional[str] = payload.get("id")
        self.regulation_id: Optional[str] = payload.get("regulationId")
        self.regulation_version: Optional[int] = deserialize.integer(
            payload.get("regulationVersion")
        )
        self.friendly_name: Optional[str] = payload.get("friendlyName")
        self.status: Optional[str] = payload.get("status")
        self.status_notification_email: Optional[str] = payload.get(
            "statusNotificationEmail"
        )
        self.status_callback_url: Optional[str] = payload.get("statusCallbackUrl")
        self.comments: Optional[str] = payload.get("comments")
        self.embedded_session: Optional[str] = payload.get("embeddedSession")
        self.data: Optional[Dict[str, object]] = payload.get("data")
        self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
            payload.get("dateCreated")
        )
        self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
            payload.get("dateUpdated")
        )

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

        :returns: Machine friendly representation
        """

        return "<Twilio.Numbers.V1.SenderIdRegistrationInstance>"


class SenderIdRegistrationList(ListResource):

    class NumbersV1CreateEmbeddedRegistrationRequest(object):
        """
        :ivar regulation_id: The regulation for this registration.
        :ivar regulation_version: The regulation version.
        :ivar friendly_name: Human-readable name for the registration.
        :ivar status_notification_email: Email address for registration status notifications.
        :ivar status_callback_url: The URL of this resource.
        :ivar comments: Additional comments about the registration.
        :ivar theme_set_id: Theme ID for the Compliance Embeddable UI.
        :ivar data: Registration data organized by section (alphanumericSender, business, useCase, authorizedRepresentative, officer, businessAddress).
        """

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

            self.regulation_id: Optional[str] = payload.get("regulationId")
            self.regulation_version: Optional[int] = payload.get("regulationVersion")
            self.friendly_name: Optional[str] = payload.get("friendlyName")
            self.status_notification_email: Optional[str] = payload.get(
                "statusNotificationEmail"
            )
            self.status_callback_url: Optional[str] = payload.get("statusCallbackUrl")
            self.comments: Optional[str] = payload.get("comments")
            self.theme_set_id: Optional[str] = payload.get("themeSetId")
            self.data: Optional[Dict[str, object]] = payload.get("data")

        def to_dict(self):
            return {
                "regulationId": self.regulation_id,
                "regulationVersion": self.regulation_version,
                "friendlyName": self.friendly_name,
                "statusNotificationEmail": self.status_notification_email,
                "statusCallbackUrl": self.status_callback_url,
                "comments": self.comments,
                "themeSetId": self.theme_set_id,
                "data": self.data,
            }

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

        :param version: Version that contains the resource

        """
        super().__init__(version)

        self._uri = "/SenderIdRegistrations"

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

        Returns:
            tuple: (payload, status_code, headers)
        """
        data = numbers_v1_create_embedded_registration_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,
        numbers_v1_create_embedded_registration_request: NumbersV1CreateEmbeddedRegistrationRequest,
    ) -> SenderIdRegistrationInstance:
        """
        Create the SenderIdRegistrationInstance

        :param numbers_v1_create_embedded_registration_request:

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

    def create_with_http_info(
        self,
        numbers_v1_create_embedded_registration_request: NumbersV1CreateEmbeddedRegistrationRequest,
    ) -> ApiResponse:
        """
        Create the SenderIdRegistrationInstance and return response metadata

        :param numbers_v1_create_embedded_registration_request:

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

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

        Returns:
            tuple: (payload, status_code, headers)
        """
        data = numbers_v1_create_embedded_registration_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,
        numbers_v1_create_embedded_registration_request: NumbersV1CreateEmbeddedRegistrationRequest,
    ) -> SenderIdRegistrationInstance:
        """
        Asynchronously create the SenderIdRegistrationInstance

        :param numbers_v1_create_embedded_registration_request:

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

    async def create_with_http_info_async(
        self,
        numbers_v1_create_embedded_registration_request: NumbersV1CreateEmbeddedRegistrationRequest,
    ) -> ApiResponse:
        """
        Asynchronously create the SenderIdRegistrationInstance and return response metadata

        :param numbers_v1_create_embedded_registration_request:

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._create_async(
            numbers_v1_create_embedded_registration_request=numbers_v1_create_embedded_registration_request
        )
        instance = SenderIdRegistrationInstance(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.Numbers.V1.SenderIdRegistrationList>"
