##
# This code was generated by
# \ / _    _  _|   _  _
#  | (_)\/(_)(_|\/| |(/_  v1.0.0
#       /       /
#
# frozen_string_literal: true

module Twilio
  module REST
    class Verify < Domain
      class V2 < Version
        class ServiceContext < InstanceContext
          ##
          # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
          class AccessTokenList < ListResource
            ##
            # Initialize the AccessTokenList
            # @param [Version] version Version that contains the resource
            # @param [String] service_sid The unique string that we created to identify the
            #   Service resource.
            # @return [AccessTokenList] AccessTokenList
            def initialize(version, service_sid: nil)
              super(version)

              # Path Solution
              @solution = {service_sid: service_sid}
              @uri = "/Services/#{@solution[:service_sid]}/AccessTokens"
            end

            ##
            # Create the AccessTokenInstance
            # @param [String] identity The unique external identifier for the Entity of the
            #   Service. This identifier should be immutable, not PII, and generated by your
            #   external system, such as your user's UUID, GUID, or SID.
            # @param [access_token.FactorTypes] factor_type The Type of this Factor. Eg.
            #   `push`
            # @param [String] factor_friendly_name The friendly name of the factor that is
            #   going to be created with this access token
            # @return [AccessTokenInstance] Created AccessTokenInstance
            def create(identity: nil, factor_type: nil, factor_friendly_name: :unset)
              data = Twilio::Values.of({
                  'Identity' => identity,
                  'FactorType' => factor_type,
                  'FactorFriendlyName' => factor_friendly_name,
              })

              payload = @version.create('POST', @uri, data: data)

              AccessTokenInstance.new(@version, payload, service_sid: @solution[:service_sid], )
            end

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

          ##
          # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
          class AccessTokenPage < Page
            ##
            # Initialize the AccessTokenPage
            # @param [Version] version Version that contains the resource
            # @param [Response] response Response from the API
            # @param [Hash] solution Path solution for the resource
            # @return [AccessTokenPage] AccessTokenPage
            def initialize(version, response, solution)
              super(version, response)

              # Path Solution
              @solution = solution
            end

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

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

          ##
          # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
          class AccessTokenInstance < InstanceResource
            ##
            # Initialize the AccessTokenInstance
            # @param [Version] version Version that contains the resource
            # @param [Hash] payload payload that contains response from Twilio
            # @param [String] service_sid The unique string that we created to identify the
            #   Service resource.
            # @return [AccessTokenInstance] AccessTokenInstance
            def initialize(version, payload, service_sid: nil)
              super(version)

              # Marshaled Properties
              @properties = {'token' => payload['token'], }
            end

            ##
            # @return [String] Generated access token.
            def token
              @properties['token']
            end

            ##
            # Provide a user friendly representation
            def to_s
              "<Twilio.Verify.V2.AccessTokenInstance>"
            end

            ##
            # Provide a detailed, user friendly representation
            def inspect
              "<Twilio.Verify.V2.AccessTokenInstance>"
            end
          end
        end
      end
    end
  end
end