##
#    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.
#


module Twilio
    module REST
        class Verify < VerifyBase
            class V2 < Version
                class ServiceContext < InstanceContext

                     class NewChallengeList < ListResource
                
                    class CreatePasskeysChallengeRequest
                            # @param [identity]: [String] 
                            # @param [factor_sid]: [String] 
                        attr_accessor :identity, :factor_sid
                        def initialize(payload)
                                @identity = payload["identity"]
                                @factor_sid = payload["factor_sid"]
                        end
                        def to_json(options = {})
                        {
                                "identity": @identity,
                                "factor_sid": @factor_sid,
                        }.to_json(options)
                        end
                    end


                    ##
                    # Initialize the NewChallengeList
                    # @param [Version] version Version that contains the resource
                    # @return [NewChallengeList] NewChallengeList
                    def initialize(version, service_sid: nil)
                        super(version)
                        # Path Solution
                        @solution = { service_sid: service_sid }
                        
                        
                    end
                


                    # Provide a user friendly representation
                    def to_s
                        '#<Twilio.Verify.V2.NewChallengeList>'
                    end
                end


                class NewChallengeContext < InstanceContext
                    ##
                    # Initialize the NewChallengeContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] service_sid The unique SID identifier of the Service.
                    # @return [NewChallengeContext] NewChallengeContext
                    def initialize(version, service_sid)
                        super(version)

                        # Path Solution
                        @solution = { service_sid: service_sid,  }
                        @uri = "/Services/#{@solution[:service_sid]}/Passkeys/Challenges"

                        
                    end
                    ##
                    # Create the NewChallengeInstance
                    # @param [CreatePasskeysChallengeRequest] create_passkeys_challenge_request 
                    # @return [NewChallengeInstance] Created NewChallengeInstance
                    def create(create_passkeys_challenge_request: nil
                    )

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        headers['Content-Type'] = 'application/json'
                        
                        
                        
                        
                        payload = @version.create('POST', @uri, headers: headers, data: create_passkeys_challenge_request.to_json)
                        NewChallengeInstance.new(
                            @version,
                            payload,
                            service_sid: @solution[:service_sid],
                        )
                    end


                    ##
                    # Provide a user friendly representation
                    def to_s
                        context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
                        "#<Twilio.Verify.V2.NewChallengeContext #{context}>"
                    end

                    ##
                    # Provide a detailed, user friendly representation
                    def inspect
                        context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
                        "#<Twilio.Verify.V2.NewChallengeContext #{context}>"
                    end
                end

                class NewChallengePage < Page
                    ##
                    # Initialize the NewChallengePage
                    # @param [Version] version Version that contains the resource
                    # @param [Response] response Response from the API
                    # @param [Hash] solution Path solution for the resource
                    # @return [NewChallengePage] NewChallengePage
                    def initialize(version, response, solution)
                        super(version, response)

                        # Path Solution
                        @solution = solution
                    end

                    ##
                    # Build an instance of NewChallengeInstance
                    # @param [Hash] payload Payload response from the API
                    # @return [NewChallengeInstance] NewChallengeInstance
                    def get_instance(payload)
                        NewChallengeInstance.new(@version, payload, service_sid: @solution[:service_sid])
                    end

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Verify.V2.NewChallengePage>'
                    end
                end
                class NewChallengeInstance < InstanceResource
                    ##
                    # Initialize the NewChallengeInstance
                    # @param [Version] version Version that contains the resource
                    # @param [Hash] payload payload that contains response from Twilio
                    # @param [String] account_sid The SID of the
                    #   {Account}[https://www.twilio.com/docs/iam/api/account] that created this NewChallenge
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [NewChallengeInstance] NewChallengeInstance
                    def initialize(version, payload , service_sid: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'options' => payload['options'],
                            'sid' => payload['sid'],
                            'account_sid' => payload['account_sid'],
                            'service_sid' => payload['service_sid'],
                            'entity_sid' => payload['entity_sid'],
                            'identity' => payload['identity'],
                            'factor_sid' => payload['factor_sid'],
                            'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
                            'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
                            'date_responded' => Twilio.deserialize_iso8601_datetime(payload['date_responded']),
                            'expiration_date' => Twilio.deserialize_iso8601_datetime(payload['expiration_date']),
                            'status' => payload['status'],
                            'responded_reason' => payload['responded_reason'],
                            'details' => payload['details'],
                            'hidden_details' => payload['hidden_details'],
                            'metadata' => payload['metadata'],
                            'factor_type' => payload['factor_type'],
                            'url' => payload['url'],
                            'links' => payload['links'],
                        }

                        # Context
                        @instance_context = nil
                        @params = { 'service_sid' => service_sid  || @properties['service_sid']  , }
                    end

                    ##
                    # Generate an instance context for the instance, the context is capable of
                    # performing various actions.  All instance actions are proxied to the context
                    # @return [NewChallengeContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = NewChallengeContext.new(@version , @params['service_sid'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [Hash] An object that contains challenge options. Currently only used for `passkeys`.
                    def options
                        @properties['options']
                    end
                    
                    ##
                    # @return [String] A 34 character string that uniquely identifies this Challenge.
                    def sid
                        @properties['sid']
                    end
                    
                    ##
                    # @return [String] The unique SID identifier of the Account.
                    def account_sid
                        @properties['account_sid']
                    end
                    
                    ##
                    # @return [String] The unique SID identifier of the Service.
                    def service_sid
                        @properties['service_sid']
                    end
                    
                    ##
                    # @return [String] The unique SID identifier of the Entity.
                    def entity_sid
                        @properties['entity_sid']
                    end
                    
                    ##
                    # @return [String] Customer unique identity for the Entity owner of the Challenge.
                    def identity
                        @properties['identity']
                    end
                    
                    ##
                    # @return [String] The unique SID identifier of the Factor.
                    def factor_sid
                        @properties['factor_sid']
                    end
                    
                    ##
                    # @return [Time] The date that this Challenge was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    def date_created
                        @properties['date_created']
                    end
                    
                    ##
                    # @return [Time] The date that this Challenge was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    def date_updated
                        @properties['date_updated']
                    end
                    
                    ##
                    # @return [Time] The date that this Challenge was responded, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    def date_responded
                        @properties['date_responded']
                    end
                    
                    ##
                    # @return [Time] The date-time when this Challenge expires, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    def expiration_date
                        @properties['expiration_date']
                    end
                    
                    ##
                    # @return [String] The Status of this Challenge. One of `pending`, `expired`, `approved` or `denied`.
                    def status
                        @properties['status']
                    end
                    
                    ##
                    # @return [String] Reason for the Challenge to be in certain `status`. One of `none`, `not_needed` or `not_requested`.
                    def responded_reason
                        @properties['responded_reason']
                    end
                    
                    ##
                    # @return [Hash] Details provided to give context about the Challenge.
                    def details
                        @properties['details']
                    end
                    
                    ##
                    # @return [Hash] Details provided to give context about the Challenge.
                    def hidden_details
                        @properties['hidden_details']
                    end
                    
                    ##
                    # @return [Hash] Custom metadata associated with the challenge.
                    def metadata
                        @properties['metadata']
                    end
                    
                    ##
                    # @return [String] The Factor Type of this Challenge. Currently `push` and `totp` are supported.
                    def factor_type
                        @properties['factor_type']
                    end
                    
                    ##
                    # @return [String] The URL of this resource.
                    def url
                        @properties['url']
                    end
                    
                    ##
                    # @return [Hash] Contains a dictionary of URL links to nested resources of this Challenge.
                    def links
                        @properties['links']
                    end
                    
                    ##
                    # Create the NewChallengeInstance
                    # @param [CreatePasskeysChallengeRequest] create_passkeys_challenge_request 
                    # @return [NewChallengeInstance] Created NewChallengeInstance
                    def create(create_passkeys_challenge_request: nil
                    )

                        context.create(
                        )
                    end

                    ##
                    # Provide a user friendly representation
                    def to_s
                        values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
                        "<Twilio.Verify.V2.NewChallengeInstance #{values}>"
                    end

                    ##
                    # Provide a detailed, user friendly representation
                    def inspect
                        values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
                        "<Twilio.Verify.V2.NewChallengeInstance #{values}>"
                    end
                end

             end
            end
        end
    end
end


