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

    Twilio - Verify
    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
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 NewVerifyFactorInstance(InstanceResource):

    class VerifyPasskeysFactorRequest(object):
        """
        :ivar id: A [base64url](https://base64.guru/standards/base64url) encoded representation of `rawId`.
        :ivar raw_id: The globally unique identifier for this `PublicKeyCredential`.
        :ivar authenticator_attachment: A string that indicates the mechanism by which the WebAuthn implementation is attached to the authenticator at the time the associated  `navigator.credentials.create()` or `navigator.credentials.get()` call completes.
        :ivar type: The valid credential types supported by the API. The values of this enumeration are used for versioning the `AuthenticatorAssertion` and `AuthenticatorAttestation` structures according to the type of the authenticator.
        :ivar response:
        """

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

            self.id: Optional[str] = payload.get("id")
            self.raw_id: Optional[str] = payload.get("raw_id")
            self.authenticator_attachment: Optional["NewVerifyFactorInstance.str"] = (
                payload.get("authenticator_attachment")
            )
            self.type: Optional["NewVerifyFactorInstance.str"] = payload.get("type")
            self.response: Optional[
                NewVerifyFactorList.VerifyPasskeysFactorRequestResponse
            ] = payload.get("response")

        def to_dict(self):
            return {
                "id": self.id,
                "raw_id": self.raw_id,
                "authenticator_attachment": self.authenticator_attachment,
                "type": self.type,
                "response": (
                    self.response.to_dict() if self.response is not None else None
                ),
            }

    class VerifyPasskeysFactorRequestResponse(object):
        """
        :ivar attestation_object: The authenticator data and an attestation statement for a new key pair generated by the authenticator.
        :ivar client_data_json: This property contains the JSON-compatible serialization of the data passed from the browser to the authenticator in order to generate this credential.
        :ivar transports: An array of strings providing hints as to the methods the client could use to communicate with the relevant authenticator of the public key credential to retrieve.
        """

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

            self.attestation_object: Optional[str] = payload.get("attestation_object")
            self.client_data_json: Optional[str] = payload.get("client_data_json")
            self.transports: Optional[List[Enumstr]] = payload.get("transports")

        def to_dict(self):
            return {
                "attestation_object": self.attestation_object,
                "client_data_json": self.client_data_json,
                "transports": self.transports,
            }

    """
    :ivar sid: A 34 character string that uniquely identifies this Factor.
    :ivar account_sid: The unique SID identifier of the Account.
    :ivar service_sid: The unique SID identifier of the Service.
    :ivar entity_sid: The unique SID identifier of the Entity.
    :ivar identity: Customer unique identity for the Entity owner of the Factor.
    :ivar date_created: The date that this Factor was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
    :ivar date_updated: The date that this Factor was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
    :ivar friendly_name: A human readable description of this resource, up to 64 characters.
    :ivar status: The Status of this Factor. One of `unverified` or `verified`.
    :ivar factor_type: The Type of this Factor. Currently `push` and `totp` are supported.
    :ivar config: An object that contains configurations specific to a `factor_type`.
    :ivar metadata: Custom metadata associated with the factor.
    :ivar url: The URL of this resource.
    """

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

        self.sid: Optional[str] = payload.get("sid")
        self.account_sid: Optional[str] = payload.get("account_sid")
        self.service_sid: Optional[str] = payload.get("service_sid")
        self.entity_sid: Optional[str] = payload.get("entity_sid")
        self.identity: Optional[str] = payload.get("identity")
        self.date_created: Optional[datetime] = deserialize.iso8601_datetime(
            payload.get("date_created")
        )
        self.date_updated: Optional[datetime] = deserialize.iso8601_datetime(
            payload.get("date_updated")
        )
        self.friendly_name: Optional[str] = payload.get("friendly_name")
        self.status: Optional[str] = payload.get("status")
        self.factor_type: Optional[str] = payload.get("factor_type")
        self.config: Optional[Dict[str, object]] = payload.get("config")
        self.metadata: Optional[Dict[str, object]] = payload.get("metadata")
        self.url: Optional[str] = payload.get("url")

        self._solution = {
            "service_sid": service_sid,
        }

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

        :returns: Machine friendly representation
        """
        context = " ".join("{}={}".format(k, v) for k, v in self._solution.items())
        return "<Twilio.Verify.V2.NewVerifyFactorInstance {}>".format(context)


class NewVerifyFactorList(ListResource):

    class VerifyPasskeysFactorRequest(object):
        """
        :ivar id: A [base64url](https://base64.guru/standards/base64url) encoded representation of `rawId`.
        :ivar raw_id: The globally unique identifier for this `PublicKeyCredential`.
        :ivar authenticator_attachment: A string that indicates the mechanism by which the WebAuthn implementation is attached to the authenticator at the time the associated  `navigator.credentials.create()` or `navigator.credentials.get()` call completes.
        :ivar type: The valid credential types supported by the API. The values of this enumeration are used for versioning the `AuthenticatorAssertion` and `AuthenticatorAttestation` structures according to the type of the authenticator.
        :ivar response:
        """

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

            self.id: Optional[str] = payload.get("id")
            self.raw_id: Optional[str] = payload.get("raw_id")
            self.authenticator_attachment: Optional["NewVerifyFactorInstance.str"] = (
                payload.get("authenticator_attachment")
            )
            self.type: Optional["NewVerifyFactorInstance.str"] = payload.get("type")
            self.response: Optional[
                NewVerifyFactorList.VerifyPasskeysFactorRequestResponse
            ] = payload.get("response")

        def to_dict(self):
            return {
                "id": self.id,
                "raw_id": self.raw_id,
                "authenticator_attachment": self.authenticator_attachment,
                "type": self.type,
                "response": (
                    self.response.to_dict() if self.response is not None else None
                ),
            }

    class VerifyPasskeysFactorRequestResponse(object):
        """
        :ivar attestation_object: The authenticator data and an attestation statement for a new key pair generated by the authenticator.
        :ivar client_data_json: This property contains the JSON-compatible serialization of the data passed from the browser to the authenticator in order to generate this credential.
        :ivar transports: An array of strings providing hints as to the methods the client could use to communicate with the relevant authenticator of the public key credential to retrieve.
        """

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

            self.attestation_object: Optional[str] = payload.get("attestation_object")
            self.client_data_json: Optional[str] = payload.get("client_data_json")
            self.transports: Optional[List[Enumstr]] = payload.get("transports")

        def to_dict(self):
            return {
                "attestation_object": self.attestation_object,
                "client_data_json": self.client_data_json,
                "transports": self.transports,
            }

    def __init__(self, version: Version, service_sid: str):
        """
        Initialize the NewVerifyFactorList

        :param version: Version that contains the resource
        :param service_sid: The unique SID identifier of the Service.

        """
        super().__init__(version)

        # Path Solution
        self._solution = {
            "service_sid": service_sid,
        }
        self._uri = "/Services/{service_sid}/Passkeys/VerifyFactor".format(
            **self._solution
        )

    def _update(
        self, verify_passkeys_factor_request: VerifyPasskeysFactorRequest
    ) -> tuple:
        """
        Internal helper for update operation

        Returns:
            tuple: (payload, status_code, headers)
        """
        data = verify_passkeys_factor_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.update_with_response_info(
            method="POST", uri=self._uri, data=data, headers=headers
        )

    def update(
        self, verify_passkeys_factor_request: VerifyPasskeysFactorRequest
    ) -> NewVerifyFactorInstance:
        """
        Update the NewVerifyFactorInstance

        :param verify_passkeys_factor_request:

        :returns: The updated NewVerifyFactorInstance
        """
        payload, _, _ = self._update(
            verify_passkeys_factor_request=verify_passkeys_factor_request
        )
        return NewVerifyFactorInstance(
            self._version, payload, service_sid=self._solution["service_sid"]
        )

    def update_with_http_info(
        self, verify_passkeys_factor_request: VerifyPasskeysFactorRequest
    ) -> ApiResponse:
        """
        Update the NewVerifyFactorInstance and return response metadata

        :param verify_passkeys_factor_request:

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = self._update(
            verify_passkeys_factor_request=verify_passkeys_factor_request
        )
        instance = NewVerifyFactorInstance(
            self._version, payload, service_sid=self._solution["service_sid"]
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

    async def _update_async(
        self, verify_passkeys_factor_request: VerifyPasskeysFactorRequest
    ) -> tuple:
        """
        Internal async helper for update operation

        Returns:
            tuple: (payload, status_code, headers)
        """
        data = verify_passkeys_factor_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.update_with_response_info_async(
            method="POST", uri=self._uri, data=data, headers=headers
        )

    async def update_async(
        self, verify_passkeys_factor_request: VerifyPasskeysFactorRequest
    ) -> NewVerifyFactorInstance:
        """
        Asynchronously update the NewVerifyFactorInstance

        :param verify_passkeys_factor_request:

        :returns: The updated NewVerifyFactorInstance
        """
        payload, _, _ = await self._update_async(
            verify_passkeys_factor_request=verify_passkeys_factor_request
        )
        return NewVerifyFactorInstance(
            self._version, payload, service_sid=self._solution["service_sid"]
        )

    async def update_with_http_info_async(
        self, verify_passkeys_factor_request: VerifyPasskeysFactorRequest
    ) -> ApiResponse:
        """
        Asynchronously update the NewVerifyFactorInstance and return response metadata

        :param verify_passkeys_factor_request:

        :returns: ApiResponse with instance, status code, and headers
        """
        payload, status_code, headers = await self._update_async(
            verify_passkeys_factor_request=verify_passkeys_factor_request
        )
        instance = NewVerifyFactorInstance(
            self._version, payload, service_sid=self._solution["service_sid"]
        )
        return ApiResponse(data=instance, status_code=status_code, headers=headers)

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

        :returns: Machine friendly representation
        """
        return "<Twilio.Verify.V2.NewVerifyFactorList>"
