##
#    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 ServiceList < ListResource
                
                    ##
                    # Initialize the ServiceList
                    # @param [Version] version Version that contains the resource
                    # @return [ServiceList] ServiceList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        @uri = "/Services"
                        
                    end
                    ##
                    # Create the ServiceInstance
                    # @param [String] friendly_name A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.**
                    # @param [String] code_length The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive.
                    # @param [Boolean] lookup_enabled Whether to perform a lookup with each verification started and return info about the phone number.
                    # @param [Boolean] skip_sms_to_landlines Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`.
                    # @param [Boolean] dtmf_input_required Whether to ask the user to press a number before delivering the verify code in a phone call.
                    # @param [String] tts_name The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages.
                    # @param [Boolean] psd2_enabled Whether to pass PSD2 transaction parameters when starting a verification.
                    # @param [Boolean] do_not_share_warning_enabled Whether to add a security warning at the end of an SMS verification body. Disabled by default and applies only to SMS. Example SMS body: `Your AppName verification code is: 1234. Don’t share this code with anyone; our employees will never ask for the code`
                    # @param [Boolean] custom_code_enabled Whether to allow sending verifications with a custom code instead of a randomly generated one.
                    # @param [Boolean] push_include_date Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter. This timestamp value is the same one as the one found in `date_created`, please use that one instead.
                    # @param [String] push_apn_credential_sid Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource)
                    # @param [String] push_fcm_credential_sid Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource)
                    # @param [String] totp_issuer Optional configuration for the TOTP factors. Set TOTP Issuer for this service. This will allow to configure the issuer of the TOTP URI. Defaults to the service friendly name if not provided.
                    # @param [String] totp_time_step Optional configuration for the TOTP factors. Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. Defaults to 30 seconds
                    # @param [String] totp_code_length Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6
                    # @param [String] totp_skew Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1
                    # @param [String] default_template_sid The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only.
                    # @param [String] whatsapp_msg_service_sid The SID of the Messaging Service containing WhatsApp Sender(s) that Verify will use to send WhatsApp messages to your users.
                    # @param [String] whatsapp_from The number to use as the WhatsApp Sender that Verify will use to send WhatsApp messages to your users.This WhatsApp Sender must be associated with a Messaging Service SID.
                    # @param [String] passkeys_relying_party_id The Relying Party ID for Passkeys. This is the domain of your application, e.g. `example.com`. It is used to identify your application when creating Passkeys.
                    # @param [String] passkeys_relying_party_name The Relying Party Name for Passkeys. This is the name of your application, e.g. `Example App`. It is used to identify your application when creating Passkeys.
                    # @param [String] passkeys_relying_party_origins The Relying Party Origins for Passkeys. This is the origin of your application, e.g. `login.example.com,www.example.com`. It is used to identify your application when creating Passkeys, it can have multiple origins split by `,`.
                    # @param [String] passkeys_authenticator_attachment The Authenticator Attachment for Passkeys. This is the type of authenticator that will be used to create Passkeys. It can be empty or it can have the values `platform`, `cross-platform` or `any`.
                    # @param [String] passkeys_discoverable_credentials Indicates whether credentials must be discoverable by the authenticator. It can be empty or it can have the values `required`, `preferred` or `discouraged`.
                    # @param [String] passkeys_user_verification The User Verification for Passkeys. This is the type of user verification that will be used to create Passkeys. It can be empty or it can have the values `required`, `preferred` or `discouraged`.
                    # @param [Boolean] verify_event_subscription_enabled Whether to allow verifications from the service to reach the stream-events sinks if configured
                    # @return [ServiceInstance] Created ServiceInstance
                    def create(
                        friendly_name: nil, 
                        code_length: :unset, 
                        lookup_enabled: :unset, 
                        skip_sms_to_landlines: :unset, 
                        dtmf_input_required: :unset, 
                        tts_name: :unset, 
                        psd2_enabled: :unset, 
                        do_not_share_warning_enabled: :unset, 
                        custom_code_enabled: :unset, 
                        push_include_date: :unset, 
                        push_apn_credential_sid: :unset, 
                        push_fcm_credential_sid: :unset, 
                        totp_issuer: :unset, 
                        totp_time_step: :unset, 
                        totp_code_length: :unset, 
                        totp_skew: :unset, 
                        default_template_sid: :unset, 
                        whatsapp_msg_service_sid: :unset, 
                        whatsapp_from: :unset, 
                        passkeys_relying_party_id: :unset, 
                        passkeys_relying_party_name: :unset, 
                        passkeys_relying_party_origins: :unset, 
                        passkeys_authenticator_attachment: :unset, 
                        passkeys_discoverable_credentials: :unset, 
                        passkeys_user_verification: :unset, 
                        verify_event_subscription_enabled: :unset
                    )

                        data = Twilio::Values.of({
                            'FriendlyName' => friendly_name,
                            'CodeLength' => code_length,
                            'LookupEnabled' => lookup_enabled,
                            'SkipSmsToLandlines' => skip_sms_to_landlines,
                            'DtmfInputRequired' => dtmf_input_required,
                            'TtsName' => tts_name,
                            'Psd2Enabled' => psd2_enabled,
                            'DoNotShareWarningEnabled' => do_not_share_warning_enabled,
                            'CustomCodeEnabled' => custom_code_enabled,
                            'Push.IncludeDate' => push_include_date,
                            'Push.ApnCredentialSid' => push_apn_credential_sid,
                            'Push.FcmCredentialSid' => push_fcm_credential_sid,
                            'Totp.Issuer' => totp_issuer,
                            'Totp.TimeStep' => totp_time_step,
                            'Totp.CodeLength' => totp_code_length,
                            'Totp.Skew' => totp_skew,
                            'DefaultTemplateSid' => default_template_sid,
                            'Whatsapp.MsgServiceSid' => whatsapp_msg_service_sid,
                            'Whatsapp.From' => whatsapp_from,
                            'Passkeys.RelyingParty.Id' => passkeys_relying_party_id,
                            'Passkeys.RelyingParty.Name' => passkeys_relying_party_name,
                            'Passkeys.RelyingParty.Origins' => passkeys_relying_party_origins,
                            'Passkeys.AuthenticatorAttachment' => passkeys_authenticator_attachment,
                            'Passkeys.DiscoverableCredentials' => passkeys_discoverable_credentials,
                            'Passkeys.UserVerification' => passkeys_user_verification,
                            'VerifyEventSubscriptionEnabled' => verify_event_subscription_enabled,
                        })

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        
                        
                        payload = @version.create('POST', @uri, data: data, headers: headers)
                        ServiceInstance.new(
                            @version,
                            payload,
                        )
                    end

                
                    ##
                    # Lists ServiceInstance records from the API as a list.
                    # Unlike stream(), this operation is eager and will load `limit` records into
                    # memory before returning.
                    # @param [Integer] limit Upper limit for the number of records to return. stream()
                    #    guarantees to never return more than limit.  Default is no limit
                    # @param [Integer] page_size Number of records to fetch per request, when
                    #    not set will use the default value of 50 records.  If no page_size is defined
                    #    but a limit is defined, stream() will attempt to read the limit with the most
                    #    efficient page size, i.e. min(limit, 1000)
                    # @return [Array] Array of up to limit results
                    def list(limit: nil, page_size: nil)
                        self.stream(
                            limit: limit,
                            page_size: page_size
                        ).entries
                    end

                    ##
                    # Streams Instance records from the API as an Enumerable.
                    # This operation lazily loads records as efficiently as possible until the limit
                    # is reached.
                    # @param [Integer] limit Upper limit for the number of records to return. stream()
                    #    guarantees to never return more than limit.  Default is no limit
                    # @param [Integer] page_size Number of records to fetch per request, when
                    #    not set will use the default value of 50 records.  If no page_size is defined
                    #    but a limit is defined, stream() will attempt to read the limit with the most
                    #    efficient page size, i.e. min(limit, 1000)
                    # @return [Enumerable] Enumerable that will yield up to limit results
                    def stream(limit: nil, page_size: nil)
                        limits = @version.read_limits(limit, page_size)

                        page = self.page(
                            page_size: limits[:page_size], )

                        @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
                    end

                    ##
                    # When passed a block, yields ServiceInstance records from the API.
                    # This operation lazily loads records as efficiently as possible until the limit
                    # is reached.
                    def each
                        limits = @version.read_limits

                        page = self.page(page_size: limits[:page_size], )

                        @version.stream(page,
                            limit: limits[:limit],
                            page_limit: limits[:page_limit]).each {|x| yield x}
                    end

                    ##
                    # Retrieve a single page of ServiceInstance records from the API.
                    # Request is executed immediately.
                    # @param [String] page_token PageToken provided by the API
                    # @param [Integer] page_number Page Number, this value is simply for client state
                    # @param [Integer] page_size Number of records to return, defaults to 50
                    # @return [Page] Page of ServiceInstance
                    def page(page_token: :unset, page_number: :unset, page_size: :unset)
                        params = Twilio::Values.of({
                            'PageToken' => page_token,
                            'Page' => page_number,
                            'PageSize' => page_size,
                        })
                        headers = Twilio::Values.of({})
                        
                        

                        response = @version.page('GET', @uri, params: params, headers: headers)

                        ServicePage.new(@version, response, @solution)
                    end

                    ##
                    # Retrieve a single page of ServiceInstance records from the API.
                    # Request is executed immediately.
                    # @param [String] target_url API-generated URL for the requested results page
                    # @return [Page] Page of ServiceInstance
                    def get_page(target_url)
                        response = @version.domain.request(
                            'GET',
                            target_url
                        )
                    ServicePage.new(@version, response, @solution)
                    end
                    


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


                class ServiceContext < InstanceContext
                    ##
                    # Initialize the ServiceContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] sid The Twilio-provided string that uniquely identifies the Service resource to update.
                    # @return [ServiceContext] ServiceContext
                    def initialize(version, sid)
                        super(version)

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

                        # Dependents
                        @verification_checks = nil
                        @new_verify_factors = nil
                        @new_factors = nil
                        @approve_challenge = nil
                        @verifications = nil
                        @access_tokens = nil
                        @webhooks = nil
                        @messaging_configurations = nil
                        @new_challenge = nil
                        @entities = nil
                        @rate_limits = nil
                    end
                    ##
                    # Delete the ServiceInstance
                    # @return [Boolean] True if delete succeeds, false otherwise
                    def delete

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        @version.delete('DELETE', @uri, headers: headers)
                    end

                    ##
                    # Fetch the ServiceInstance
                    # @return [ServiceInstance] Fetched ServiceInstance
                    def fetch

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        
                        
                        payload = @version.fetch('GET', @uri, headers: headers)
                        ServiceInstance.new(
                            @version,
                            payload,
                            sid: @solution[:sid],
                        )
                    end

                    ##
                    # Update the ServiceInstance
                    # @param [String] friendly_name A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.**
                    # @param [String] code_length The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive.
                    # @param [Boolean] lookup_enabled Whether to perform a lookup with each verification started and return info about the phone number.
                    # @param [Boolean] skip_sms_to_landlines Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`.
                    # @param [Boolean] dtmf_input_required Whether to ask the user to press a number before delivering the verify code in a phone call.
                    # @param [String] tts_name The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages.
                    # @param [Boolean] psd2_enabled Whether to pass PSD2 transaction parameters when starting a verification.
                    # @param [Boolean] do_not_share_warning_enabled Whether to add a privacy warning at the end of an SMS. **Disabled by default and applies only for SMS.**
                    # @param [Boolean] custom_code_enabled Whether to allow sending verifications with a custom code instead of a randomly generated one.
                    # @param [Boolean] push_include_date Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter.
                    # @param [String] push_apn_credential_sid Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource)
                    # @param [String] push_fcm_credential_sid Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource)
                    # @param [String] totp_issuer Optional configuration for the TOTP factors. Set TOTP Issuer for this service. This will allow to configure the issuer of the TOTP URI.
                    # @param [String] totp_time_step Optional configuration for the TOTP factors. Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. Defaults to 30 seconds
                    # @param [String] totp_code_length Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6
                    # @param [String] totp_skew Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1
                    # @param [String] default_template_sid The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only.
                    # @param [String] whatsapp_msg_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) to associate with the Verification Service.
                    # @param [String] whatsapp_from The WhatsApp number to use as the sender of the verification messages. This number must be associated with the WhatsApp Message Service.
                    # @param [String] passkeys_relying_party_id The Relying Party ID for Passkeys. This is the domain of your application, e.g. `example.com`. It is used to identify your application when creating Passkeys.
                    # @param [String] passkeys_relying_party_name The Relying Party Name for Passkeys. This is the name of your application, e.g. `Example App`. It is used to identify your application when creating Passkeys.
                    # @param [String] passkeys_relying_party_origins The Relying Party Origins for Passkeys. This is the origin of your application, e.g. `login.example.com,www.example.com`. It is used to identify your application when creating Passkeys, it can have multiple origins split by `,`.
                    # @param [String] passkeys_authenticator_attachment The Authenticator Attachment for Passkeys. This is the type of authenticator that will be used to create Passkeys. It can be empty or it can have the values `platform`, `cross-platform` or `any`.
                    # @param [String] passkeys_discoverable_credentials Indicates whether credentials must be discoverable by the authenticator. It can be empty or it can have the values `required`, `preferred` or `discouraged`.
                    # @param [String] passkeys_user_verification The User Verification for Passkeys. This is the type of user verification that will be used to create Passkeys. It can be empty or it can have the values `required`, `preferred` or `discouraged`.
                    # @param [Boolean] verify_event_subscription_enabled Whether to allow verifications from the service to reach the stream-events sinks if configured
                    # @return [ServiceInstance] Updated ServiceInstance
                    def update(
                        friendly_name: :unset, 
                        code_length: :unset, 
                        lookup_enabled: :unset, 
                        skip_sms_to_landlines: :unset, 
                        dtmf_input_required: :unset, 
                        tts_name: :unset, 
                        psd2_enabled: :unset, 
                        do_not_share_warning_enabled: :unset, 
                        custom_code_enabled: :unset, 
                        push_include_date: :unset, 
                        push_apn_credential_sid: :unset, 
                        push_fcm_credential_sid: :unset, 
                        totp_issuer: :unset, 
                        totp_time_step: :unset, 
                        totp_code_length: :unset, 
                        totp_skew: :unset, 
                        default_template_sid: :unset, 
                        whatsapp_msg_service_sid: :unset, 
                        whatsapp_from: :unset, 
                        passkeys_relying_party_id: :unset, 
                        passkeys_relying_party_name: :unset, 
                        passkeys_relying_party_origins: :unset, 
                        passkeys_authenticator_attachment: :unset, 
                        passkeys_discoverable_credentials: :unset, 
                        passkeys_user_verification: :unset, 
                        verify_event_subscription_enabled: :unset
                    )

                        data = Twilio::Values.of({
                            'FriendlyName' => friendly_name,
                            'CodeLength' => code_length,
                            'LookupEnabled' => lookup_enabled,
                            'SkipSmsToLandlines' => skip_sms_to_landlines,
                            'DtmfInputRequired' => dtmf_input_required,
                            'TtsName' => tts_name,
                            'Psd2Enabled' => psd2_enabled,
                            'DoNotShareWarningEnabled' => do_not_share_warning_enabled,
                            'CustomCodeEnabled' => custom_code_enabled,
                            'Push.IncludeDate' => push_include_date,
                            'Push.ApnCredentialSid' => push_apn_credential_sid,
                            'Push.FcmCredentialSid' => push_fcm_credential_sid,
                            'Totp.Issuer' => totp_issuer,
                            'Totp.TimeStep' => totp_time_step,
                            'Totp.CodeLength' => totp_code_length,
                            'Totp.Skew' => totp_skew,
                            'DefaultTemplateSid' => default_template_sid,
                            'Whatsapp.MsgServiceSid' => whatsapp_msg_service_sid,
                            'Whatsapp.From' => whatsapp_from,
                            'Passkeys.RelyingParty.Id' => passkeys_relying_party_id,
                            'Passkeys.RelyingParty.Name' => passkeys_relying_party_name,
                            'Passkeys.RelyingParty.Origins' => passkeys_relying_party_origins,
                            'Passkeys.AuthenticatorAttachment' => passkeys_authenticator_attachment,
                            'Passkeys.DiscoverableCredentials' => passkeys_discoverable_credentials,
                            'Passkeys.UserVerification' => passkeys_user_verification,
                            'VerifyEventSubscriptionEnabled' => verify_event_subscription_enabled,
                        })

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        
                        
                        payload = @version.update('POST', @uri, data: data, headers: headers)
                        ServiceInstance.new(
                            @version,
                            payload,
                            sid: @solution[:sid],
                        )
                    end

                    ##
                    # Access the verification_checks
                    # @return [VerificationCheckList]
                    # @return [VerificationCheckContext]
                    def verification_checks
                      unless @verification_checks
                        @verification_checks = VerificationCheckList.new(
                                @version, service_sid: @solution[:sid], )
                      end
                      @verification_checks
                    end
                    ##
                    # Access the new_verify_factors
                    # @return [NewVerifyFactorList]
                    # @return [NewVerifyFactorContext]
                    def new_verify_factors
                      unless @new_verify_factors
                        @new_verify_factors = NewVerifyFactorList.new(
                                @version, )
                      end
                      @new_verify_factors
                    end
                    ##
                    # Access the new_factors
                    # @return [NewFactorList]
                    # @return [NewFactorContext]
                    def new_factors
                      unless @new_factors
                        @new_factors = NewFactorList.new(
                                @version, )
                      end
                      @new_factors
                    end
                    ##
                    # Access the approve_challenge
                    # @return [ApproveChallengeList]
                    # @return [ApproveChallengeContext]
                    def approve_challenge
                      unless @approve_challenge
                        @approve_challenge = ApproveChallengeList.new(
                                @version, )
                      end
                      @approve_challenge
                    end
                    ##
                    # Access the verifications
                    # @return [VerificationList]
                    # @return [VerificationContext] if sid was passed.
                    def verifications(sid=:unset)

                        raise ArgumentError, 'sid cannot be nil' if sid.nil?

                        if sid != :unset
                            return VerificationContext.new(@version, @solution[:sid],sid )
                        end

                        unless @verifications
                            @verifications = VerificationList.new(
                                @version, service_sid: @solution[:sid], )
                        end

                     @verifications
                    end
                    ##
                    # Access the access_tokens
                    # @return [AccessTokenList]
                    # @return [AccessTokenContext] if sid was passed.
                    def access_tokens(sid=:unset)

                        raise ArgumentError, 'sid cannot be nil' if sid.nil?

                        if sid != :unset
                            return AccessTokenContext.new(@version, @solution[:sid],sid )
                        end

                        unless @access_tokens
                            @access_tokens = AccessTokenList.new(
                                @version, service_sid: @solution[:sid], )
                        end

                     @access_tokens
                    end
                    ##
                    # Access the webhooks
                    # @return [WebhookList]
                    # @return [WebhookContext] if sid was passed.
                    def webhooks(sid=:unset)

                        raise ArgumentError, 'sid cannot be nil' if sid.nil?

                        if sid != :unset
                            return WebhookContext.new(@version, @solution[:sid],sid )
                        end

                        unless @webhooks
                            @webhooks = WebhookList.new(
                                @version, service_sid: @solution[:sid], )
                        end

                     @webhooks
                    end
                    ##
                    # Access the messaging_configurations
                    # @return [MessagingConfigurationList]
                    # @return [MessagingConfigurationContext] if sid was passed.
                    def messaging_configurations(country=:unset)

                        raise ArgumentError, 'country cannot be nil' if country.nil?

                        if country != :unset
                            return MessagingConfigurationContext.new(@version, @solution[:sid],country )
                        end

                        unless @messaging_configurations
                            @messaging_configurations = MessagingConfigurationList.new(
                                @version, service_sid: @solution[:sid], )
                        end

                     @messaging_configurations
                    end
                    ##
                    # Access the new_challenge
                    # @return [NewChallengeList]
                    # @return [NewChallengeContext]
                    def new_challenge
                        NewChallengeContext.new(
                                @version,
                                @solution[:sid]
                                )
                    end
                    ##
                    # Access the entities
                    # @return [EntityList]
                    # @return [EntityContext] if sid was passed.
                    def entities(identity=:unset)

                        raise ArgumentError, 'identity cannot be nil' if identity.nil?

                        if identity != :unset
                            return EntityContext.new(@version, @solution[:sid],identity )
                        end

                        unless @entities
                            @entities = EntityList.new(
                                @version, service_sid: @solution[:sid], )
                        end

                     @entities
                    end
                    ##
                    # Access the rate_limits
                    # @return [RateLimitList]
                    # @return [RateLimitContext] if sid was passed.
                    def rate_limits(sid=:unset)

                        raise ArgumentError, 'sid cannot be nil' if sid.nil?

                        if sid != :unset
                            return RateLimitContext.new(@version, @solution[:sid],sid )
                        end

                        unless @rate_limits
                            @rate_limits = RateLimitList.new(
                                @version, service_sid: @solution[:sid], )
                        end

                     @rate_limits
                    end

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

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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Verify.V2.ServicePage>'
                    end
                end
                class ServiceInstance < InstanceResource
                    ##
                    # Initialize the ServiceInstance
                    # @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 Service
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [ServiceInstance] ServiceInstance
                    def initialize(version, payload , sid: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'sid' => payload['sid'],
                            'account_sid' => payload['account_sid'],
                            'friendly_name' => payload['friendly_name'],
                            'code_length' => payload['code_length'] == nil ? payload['code_length'] : payload['code_length'].to_i,
                            'lookup_enabled' => payload['lookup_enabled'],
                            'psd2_enabled' => payload['psd2_enabled'],
                            'skip_sms_to_landlines' => payload['skip_sms_to_landlines'],
                            'dtmf_input_required' => payload['dtmf_input_required'],
                            'tts_name' => payload['tts_name'],
                            'do_not_share_warning_enabled' => payload['do_not_share_warning_enabled'],
                            'custom_code_enabled' => payload['custom_code_enabled'],
                            'push' => payload['push'],
                            'totp' => payload['totp'],
                            'default_template_sid' => payload['default_template_sid'],
                            'whatsapp' => payload['whatsapp'],
                            'passkeys' => payload['passkeys'],
                            'verify_event_subscription_enabled' => payload['verify_event_subscription_enabled'],
                            'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
                            'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
                            'url' => payload['url'],
                            'links' => payload['links'],
                        }

                        # Context
                        @instance_context = nil
                        @params = { 'sid' => sid  || @properties['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 [ServiceContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = ServiceContext.new(@version , @params['sid'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [String] The unique string that we created to identify the Service resource.
                    def sid
                        @properties['sid']
                    end
                    
                    ##
                    # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Service resource.
                    def account_sid
                        @properties['account_sid']
                    end
                    
                    ##
                    # @return [String] The name that appears in the body of your verification messages. It can be up to 30 characters long and can include letters, numbers, spaces, dashes, underscores. Phone numbers, special characters or links are NOT allowed. It cannot contain more than 4 (consecutive or non-consecutive) digits. **This value should not contain PII.**
                    def friendly_name
                        @properties['friendly_name']
                    end
                    
                    ##
                    # @return [String] The length of the verification code to generate.
                    def code_length
                        @properties['code_length']
                    end
                    
                    ##
                    # @return [Boolean] Whether to perform a lookup with each verification started and return info about the phone number.
                    def lookup_enabled
                        @properties['lookup_enabled']
                    end
                    
                    ##
                    # @return [Boolean] Whether to pass PSD2 transaction parameters when starting a verification.
                    def psd2_enabled
                        @properties['psd2_enabled']
                    end
                    
                    ##
                    # @return [Boolean] Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`.
                    def skip_sms_to_landlines
                        @properties['skip_sms_to_landlines']
                    end
                    
                    ##
                    # @return [Boolean] Whether to ask the user to press a number before delivering the verify code in a phone call.
                    def dtmf_input_required
                        @properties['dtmf_input_required']
                    end
                    
                    ##
                    # @return [String] The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages.
                    def tts_name
                        @properties['tts_name']
                    end
                    
                    ##
                    # @return [Boolean] Whether to add a security warning at the end of an SMS verification body. Disabled by default and applies only to SMS. Example SMS body: `Your AppName verification code is: 1234. Don’t share this code with anyone; our employees will never ask for the code`
                    def do_not_share_warning_enabled
                        @properties['do_not_share_warning_enabled']
                    end
                    
                    ##
                    # @return [Boolean] Whether to allow sending verifications with a custom code instead of a randomly generated one.
                    def custom_code_enabled
                        @properties['custom_code_enabled']
                    end
                    
                    ##
                    # @return [Hash] Configurations for the Push factors (channel) created under this Service.
                    def push
                        @properties['push']
                    end
                    
                    ##
                    # @return [Hash] Configurations for the TOTP factors (channel) created under this Service.
                    def totp
                        @properties['totp']
                    end
                    
                    ##
                    # @return [String] 
                    def default_template_sid
                        @properties['default_template_sid']
                    end
                    
                    ##
                    # @return [Hash] 
                    def whatsapp
                        @properties['whatsapp']
                    end
                    
                    ##
                    # @return [Hash] 
                    def passkeys
                        @properties['passkeys']
                    end
                    
                    ##
                    # @return [Boolean] Whether to allow verifications from the service to reach the stream-events sinks if configured
                    def verify_event_subscription_enabled
                        @properties['verify_event_subscription_enabled']
                    end
                    
                    ##
                    # @return [Time] The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
                    def date_created
                        @properties['date_created']
                    end
                    
                    ##
                    # @return [Time] The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
                    def date_updated
                        @properties['date_updated']
                    end
                    
                    ##
                    # @return [String] The absolute URL of the resource.
                    def url
                        @properties['url']
                    end
                    
                    ##
                    # @return [Hash] The URLs of related resources.
                    def links
                        @properties['links']
                    end
                    
                    ##
                    # Delete the ServiceInstance
                    # @return [Boolean] True if delete succeeds, false otherwise
                    def delete

                        context.delete
                    end

                    ##
                    # Fetch the ServiceInstance
                    # @return [ServiceInstance] Fetched ServiceInstance
                    def fetch

                        context.fetch
                    end

                    ##
                    # Update the ServiceInstance
                    # @param [String] friendly_name A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.**
                    # @param [String] code_length The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive.
                    # @param [Boolean] lookup_enabled Whether to perform a lookup with each verification started and return info about the phone number.
                    # @param [Boolean] skip_sms_to_landlines Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`.
                    # @param [Boolean] dtmf_input_required Whether to ask the user to press a number before delivering the verify code in a phone call.
                    # @param [String] tts_name The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages.
                    # @param [Boolean] psd2_enabled Whether to pass PSD2 transaction parameters when starting a verification.
                    # @param [Boolean] do_not_share_warning_enabled Whether to add a privacy warning at the end of an SMS. **Disabled by default and applies only for SMS.**
                    # @param [Boolean] custom_code_enabled Whether to allow sending verifications with a custom code instead of a randomly generated one.
                    # @param [Boolean] push_include_date Optional configuration for the Push factors. If true, include the date in the Challenge's response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info. Default: false. **Deprecated** do not use this parameter.
                    # @param [String] push_apn_credential_sid Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource)
                    # @param [String] push_fcm_credential_sid Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource)
                    # @param [String] totp_issuer Optional configuration for the TOTP factors. Set TOTP Issuer for this service. This will allow to configure the issuer of the TOTP URI.
                    # @param [String] totp_time_step Optional configuration for the TOTP factors. Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. Defaults to 30 seconds
                    # @param [String] totp_code_length Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6
                    # @param [String] totp_skew Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1
                    # @param [String] default_template_sid The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only.
                    # @param [String] whatsapp_msg_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) to associate with the Verification Service.
                    # @param [String] whatsapp_from The WhatsApp number to use as the sender of the verification messages. This number must be associated with the WhatsApp Message Service.
                    # @param [String] passkeys_relying_party_id The Relying Party ID for Passkeys. This is the domain of your application, e.g. `example.com`. It is used to identify your application when creating Passkeys.
                    # @param [String] passkeys_relying_party_name The Relying Party Name for Passkeys. This is the name of your application, e.g. `Example App`. It is used to identify your application when creating Passkeys.
                    # @param [String] passkeys_relying_party_origins The Relying Party Origins for Passkeys. This is the origin of your application, e.g. `login.example.com,www.example.com`. It is used to identify your application when creating Passkeys, it can have multiple origins split by `,`.
                    # @param [String] passkeys_authenticator_attachment The Authenticator Attachment for Passkeys. This is the type of authenticator that will be used to create Passkeys. It can be empty or it can have the values `platform`, `cross-platform` or `any`.
                    # @param [String] passkeys_discoverable_credentials Indicates whether credentials must be discoverable by the authenticator. It can be empty or it can have the values `required`, `preferred` or `discouraged`.
                    # @param [String] passkeys_user_verification The User Verification for Passkeys. This is the type of user verification that will be used to create Passkeys. It can be empty or it can have the values `required`, `preferred` or `discouraged`.
                    # @param [Boolean] verify_event_subscription_enabled Whether to allow verifications from the service to reach the stream-events sinks if configured
                    # @return [ServiceInstance] Updated ServiceInstance
                    def update(
                        friendly_name: :unset, 
                        code_length: :unset, 
                        lookup_enabled: :unset, 
                        skip_sms_to_landlines: :unset, 
                        dtmf_input_required: :unset, 
                        tts_name: :unset, 
                        psd2_enabled: :unset, 
                        do_not_share_warning_enabled: :unset, 
                        custom_code_enabled: :unset, 
                        push_include_date: :unset, 
                        push_apn_credential_sid: :unset, 
                        push_fcm_credential_sid: :unset, 
                        totp_issuer: :unset, 
                        totp_time_step: :unset, 
                        totp_code_length: :unset, 
                        totp_skew: :unset, 
                        default_template_sid: :unset, 
                        whatsapp_msg_service_sid: :unset, 
                        whatsapp_from: :unset, 
                        passkeys_relying_party_id: :unset, 
                        passkeys_relying_party_name: :unset, 
                        passkeys_relying_party_origins: :unset, 
                        passkeys_authenticator_attachment: :unset, 
                        passkeys_discoverable_credentials: :unset, 
                        passkeys_user_verification: :unset, 
                        verify_event_subscription_enabled: :unset
                    )

                        context.update(
                            friendly_name: friendly_name, 
                            code_length: code_length, 
                            lookup_enabled: lookup_enabled, 
                            skip_sms_to_landlines: skip_sms_to_landlines, 
                            dtmf_input_required: dtmf_input_required, 
                            tts_name: tts_name, 
                            psd2_enabled: psd2_enabled, 
                            do_not_share_warning_enabled: do_not_share_warning_enabled, 
                            custom_code_enabled: custom_code_enabled, 
                            push_include_date: push_include_date, 
                            push_apn_credential_sid: push_apn_credential_sid, 
                            push_fcm_credential_sid: push_fcm_credential_sid, 
                            totp_issuer: totp_issuer, 
                            totp_time_step: totp_time_step, 
                            totp_code_length: totp_code_length, 
                            totp_skew: totp_skew, 
                            default_template_sid: default_template_sid, 
                            whatsapp_msg_service_sid: whatsapp_msg_service_sid, 
                            whatsapp_from: whatsapp_from, 
                            passkeys_relying_party_id: passkeys_relying_party_id, 
                            passkeys_relying_party_name: passkeys_relying_party_name, 
                            passkeys_relying_party_origins: passkeys_relying_party_origins, 
                            passkeys_authenticator_attachment: passkeys_authenticator_attachment, 
                            passkeys_discoverable_credentials: passkeys_discoverable_credentials, 
                            passkeys_user_verification: passkeys_user_verification, 
                            verify_event_subscription_enabled: verify_event_subscription_enabled, 
                        )
                    end

                    ##
                    # Access the verification_checks
                    # @return [verification_checks] verification_checks
                    def verification_checks
                        context.verification_checks
                    end

                    ##
                    # Access the new_verify_factors
                    # @return [new_verify_factors] new_verify_factors
                    def new_verify_factors
                        context.new_verify_factors
                    end

                    ##
                    # Access the new_factors
                    # @return [new_factors] new_factors
                    def new_factors
                        context.new_factors
                    end

                    ##
                    # Access the approve_challenge
                    # @return [approve_challenge] approve_challenge
                    def approve_challenge
                        context.approve_challenge
                    end

                    ##
                    # Access the verifications
                    # @return [verifications] verifications
                    def verifications
                        context.verifications
                    end

                    ##
                    # Access the access_tokens
                    # @return [access_tokens] access_tokens
                    def access_tokens
                        context.access_tokens
                    end

                    ##
                    # Access the webhooks
                    # @return [webhooks] webhooks
                    def webhooks
                        context.webhooks
                    end

                    ##
                    # Access the messaging_configurations
                    # @return [messaging_configurations] messaging_configurations
                    def messaging_configurations
                        context.messaging_configurations
                    end

                    ##
                    # Access the new_challenge
                    # @return [new_challenge] new_challenge
                    def new_challenge
                        context.new_challenge
                    end

                    ##
                    # Access the entities
                    # @return [entities] entities
                    def entities
                        context.entities
                    end

                    ##
                    # Access the rate_limits
                    # @return [rate_limits] rate_limits
                    def rate_limits
                        context.rate_limits
                    end

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

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

            end
        end
    end
end
