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

    Twilio - Lookups
    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 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 QueryInstance(InstanceResource):

    class IdentityMatchParameters(object):
        """
        :ivar first_name:
        :ivar last_name:
        :ivar address_line1:
        :ivar address_line2:
        :ivar city:
        :ivar state:
        :ivar postal_code:
        :ivar address_country_code:
        :ivar national_id:
        :ivar date_of_birth:
        """

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

            self.first_name: Optional[str] = payload.get("first_name")
            self.last_name: Optional[str] = payload.get("last_name")
            self.address_line1: Optional[str] = payload.get("address_line1")
            self.address_line2: Optional[str] = payload.get("address_line2")
            self.city: Optional[str] = payload.get("city")
            self.state: Optional[str] = payload.get("state")
            self.postal_code: Optional[str] = payload.get("postal_code")
            self.address_country_code: Optional[str] = payload.get(
                "address_country_code"
            )
            self.national_id: Optional[str] = payload.get("national_id")
            self.date_of_birth: Optional[str] = payload.get("date_of_birth")

        def to_dict(self):
            return {
                "first_name": self.first_name,
                "last_name": self.last_name,
                "address_line1": self.address_line1,
                "address_line2": self.address_line2,
                "city": self.city,
                "state": self.state,
                "postal_code": self.postal_code,
                "address_country_code": self.address_country_code,
                "national_id": self.national_id,
                "date_of_birth": self.date_of_birth,
            }

    class LastSimSwapInfo(object):
        """
        :ivar last_sim_swap_date:
        :ivar swapped_period:
        :ivar swapped_in_period:
        """

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

            self.last_sim_swap_date: Optional[datetime] = payload.get(
                "last_sim_swap_date"
            )
            self.swapped_period: Optional[str] = payload.get("swapped_period")
            self.swapped_in_period: Optional[bool] = payload.get("swapped_in_period")

        def to_dict(self):
            return {
                "": self.last_sim_swap_date,
                "": self.swapped_period,
                "": self.swapped_in_period,
            }

    class LookupBatchRequest(object):
        """
        :ivar correlation_id: Unique identifier used to match request with response
        :ivar phone_number:
        :ivar fields:
        :ivar country_code:
        :ivar identity_match:
        :ivar reassigned_number:
        :ivar sms_pumping_risk:
        """

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

            self.correlation_id: Optional[str] = payload.get("correlation_id")
            self.phone_number: Optional[str] = payload.get("phone_number")
            self.fields: Optional[List[Enumstr]] = payload.get("fields")
            self.country_code: Optional[str] = payload.get("country_code")
            self.identity_match: Optional[QueryList.IdentityMatchParameters] = (
                payload.get("identity_match")
            )
            self.reassigned_number: Optional[QueryList.ReassignedNumberParameters] = (
                payload.get("reassigned_number")
            )
            self.sms_pumping_risk: Optional[QueryList.RiskParameters] = payload.get(
                "sms_pumping_risk"
            )

        def to_dict(self):
            return {
                "correlation_id": self.correlation_id,
                "phone_number": self.phone_number,
                "fields": self.fields,
                "country_code": self.country_code,
                "identity_match": (
                    self.identity_match.to_dict()
                    if self.identity_match is not None
                    else None
                ),
                "reassigned_number": (
                    self.reassigned_number.to_dict()
                    if self.reassigned_number is not None
                    else None
                ),
                "sms_pumping_risk": (
                    self.sms_pumping_risk.to_dict()
                    if self.sms_pumping_risk is not None
                    else None
                ),
            }

    class LookupRequest(object):
        """
        :ivar phone_numbers:
        """

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

            self.phone_numbers: Optional[List[QueryList.LookupBatchRequest]] = (
                payload.get("phone_numbers")
            )

        def to_dict(self):
            return {
                "phone_numbers": (
                    [phone_numbers.to_dict() for phone_numbers in self.phone_numbers]
                    if self.phone_numbers is not None
                    else None
                ),
            }

    class ReassignedNumberParameters(object):
        """
        :ivar last_verified_date:
        """

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

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

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

    class RiskParameters(object):
        """
        :ivar partner_sub_id:
        """

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

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

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

    """
    :ivar phone_numbers: 
    """

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

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

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

        :returns: Machine friendly representation
        """

        return "<Twilio.Lookups.V2.QueryInstance>"


class QueryList(ListResource):

    class IdentityMatchParameters(object):
        """
        :ivar first_name:
        :ivar last_name:
        :ivar address_line1:
        :ivar address_line2:
        :ivar city:
        :ivar state:
        :ivar postal_code:
        :ivar address_country_code:
        :ivar national_id:
        :ivar date_of_birth:
        """

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

            self.first_name: Optional[str] = payload.get("first_name")
            self.last_name: Optional[str] = payload.get("last_name")
            self.address_line1: Optional[str] = payload.get("address_line1")
            self.address_line2: Optional[str] = payload.get("address_line2")
            self.city: Optional[str] = payload.get("city")
            self.state: Optional[str] = payload.get("state")
            self.postal_code: Optional[str] = payload.get("postal_code")
            self.address_country_code: Optional[str] = payload.get(
                "address_country_code"
            )
            self.national_id: Optional[str] = payload.get("national_id")
            self.date_of_birth: Optional[str] = payload.get("date_of_birth")

        def to_dict(self):
            return {
                "first_name": self.first_name,
                "last_name": self.last_name,
                "address_line1": self.address_line1,
                "address_line2": self.address_line2,
                "city": self.city,
                "state": self.state,
                "postal_code": self.postal_code,
                "address_country_code": self.address_country_code,
                "national_id": self.national_id,
                "date_of_birth": self.date_of_birth,
            }

    class LastSimSwapInfo(object):
        """
        :ivar last_sim_swap_date:
        :ivar swapped_period:
        :ivar swapped_in_period:
        """

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

            self.last_sim_swap_date: Optional[datetime] = payload.get(
                "last_sim_swap_date"
            )
            self.swapped_period: Optional[str] = payload.get("swapped_period")
            self.swapped_in_period: Optional[bool] = payload.get("swapped_in_period")

        def to_dict(self):
            return {
                "": self.last_sim_swap_date,
                "": self.swapped_period,
                "": self.swapped_in_period,
            }

    class LookupBatchRequest(object):
        """
        :ivar correlation_id: Unique identifier used to match request with response
        :ivar phone_number:
        :ivar fields:
        :ivar country_code:
        :ivar identity_match:
        :ivar reassigned_number:
        :ivar sms_pumping_risk:
        """

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

            self.correlation_id: Optional[str] = payload.get("correlation_id")
            self.phone_number: Optional[str] = payload.get("phone_number")
            self.fields: Optional[List[Enumstr]] = payload.get("fields")
            self.country_code: Optional[str] = payload.get("country_code")
            self.identity_match: Optional[QueryList.IdentityMatchParameters] = (
                payload.get("identity_match")
            )
            self.reassigned_number: Optional[QueryList.ReassignedNumberParameters] = (
                payload.get("reassigned_number")
            )
            self.sms_pumping_risk: Optional[QueryList.RiskParameters] = payload.get(
                "sms_pumping_risk"
            )

        def to_dict(self):
            return {
                "correlation_id": self.correlation_id,
                "phone_number": self.phone_number,
                "fields": self.fields,
                "country_code": self.country_code,
                "identity_match": (
                    self.identity_match.to_dict()
                    if self.identity_match is not None
                    else None
                ),
                "reassigned_number": (
                    self.reassigned_number.to_dict()
                    if self.reassigned_number is not None
                    else None
                ),
                "sms_pumping_risk": (
                    self.sms_pumping_risk.to_dict()
                    if self.sms_pumping_risk is not None
                    else None
                ),
            }

    class LookupRequest(object):
        """
        :ivar phone_numbers:
        """

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

            self.phone_numbers: Optional[List[QueryList.LookupBatchRequest]] = (
                payload.get("phone_numbers")
            )

        def to_dict(self):
            return {
                "phone_numbers": (
                    [phone_numbers.to_dict() for phone_numbers in self.phone_numbers]
                    if self.phone_numbers is not None
                    else None
                ),
            }

    class ReassignedNumberParameters(object):
        """
        :ivar last_verified_date:
        """

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

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

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

    class RiskParameters(object):
        """
        :ivar partner_sub_id:
        """

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

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

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

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

        :param version: Version that contains the resource

        """
        super().__init__(version)

        self._uri = "/batch/query"

    def _create(
        self, lookup_request: Union[LookupRequest, object] = values.unset
    ) -> tuple:
        """
        Internal helper for create operation

        Returns:
            tuple: (payload, status_code, headers)
        """
        data = lookup_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, lookup_request: Union[LookupRequest, object] = values.unset
    ) -> QueryInstance:
        """
        Create the QueryInstance

        :param lookup_request:

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

    def create_with_http_info(
        self, lookup_request: Union[LookupRequest, object] = values.unset
    ) -> ApiResponse:
        """
        Create the QueryInstance and return response metadata

        :param lookup_request:

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

    async def _create_async(
        self, lookup_request: Union[LookupRequest, object] = values.unset
    ) -> tuple:
        """
        Internal async helper for create operation

        Returns:
            tuple: (payload, status_code, headers)
        """
        data = lookup_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, lookup_request: Union[LookupRequest, object] = values.unset
    ) -> QueryInstance:
        """
        Asynchronously create the QueryInstance

        :param lookup_request:

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

    async def create_with_http_info_async(
        self, lookup_request: Union[LookupRequest, object] = values.unset
    ) -> ApiResponse:
        """
        Asynchronously create the QueryInstance and return response metadata

        :param lookup_request:

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._create_async(
            lookup_request=lookup_request
        )
        instance = QueryInstance(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.Lookups.V2.QueryList>"
