##
# 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 VerificationCheckList < ListResource
            ##
            # Initialize the VerificationCheckList
            # @param [Version] version Version that contains the resource
            # @param [String] service_sid The SID of the
            #   [Service](https://www.twilio.com/docs/verify/api/service) the resource is
            #   associated with.
            # @return [VerificationCheckList] VerificationCheckList
            def initialize(version, service_sid: nil)
              super(version)

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

            ##
            # Retrieve a single page of VerificationCheckInstance records from the API.
            # Request is executed immediately.
            # @param [String] code The 4-10 character string being verified.
            # @param [String] to The phone number to verify. Either this parameter or the
            #   `verification_sid` must be specified. Phone numbers must be in [E.164
            #   format](https://www.twilio.com/docs/glossary/what-e164).
            # @param [String] verification_sid A SID that uniquely identifies the Verification
            #   Check. Either this parameter or the `to` phone number must be specified.
            # @param [String] amount The amount of the associated PSD2 compliant transaction.
            #   Requires the PSD2 Service flag enabled.
            # @param [String] payee The payee of the associated PSD2 compliant transaction.
            #   Requires the PSD2 Service flag enabled.
            # @return [VerificationCheckInstance] Newly created VerificationCheckInstance
            def create(code: nil, to: :unset, verification_sid: :unset, amount: :unset, payee: :unset)
              data = Twilio::Values.of({
                  'Code' => code,
                  'To' => to,
                  'VerificationSid' => verification_sid,
                  'Amount' => amount,
                  'Payee' => payee,
              })

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

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

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

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

              # Path Solution
              @solution = solution
            end

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

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

          ##
          # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
          class VerificationCheckInstance < InstanceResource
            ##
            # Initialize the VerificationCheckInstance
            # @param [Version] version Version that contains the resource
            # @param [Hash] payload payload that contains response from Twilio
            # @param [String] service_sid The SID of the
            #   [Service](https://www.twilio.com/docs/verify/api/service) the resource is
            #   associated with.
            # @return [VerificationCheckInstance] VerificationCheckInstance
            def initialize(version, payload, service_sid: nil)
              super(version)

              # Marshaled Properties
              @properties = {
                  'sid' => payload['sid'],
                  'service_sid' => payload['service_sid'],
                  'account_sid' => payload['account_sid'],
                  'to' => payload['to'],
                  'channel' => payload['channel'],
                  'status' => payload['status'],
                  'valid' => payload['valid'],
                  'amount' => payload['amount'],
                  'payee' => payload['payee'],
                  'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
                  'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
              }
            end

            ##
            # @return [String] The unique string that identifies the resource
            def sid
              @properties['sid']
            end

            ##
            # @return [String] The SID of the Service that the resource is associated with
            def service_sid
              @properties['service_sid']
            end

            ##
            # @return [String] The SID of the Account that created the resource
            def account_sid
              @properties['account_sid']
            end

            ##
            # @return [String] The phone number being verified
            def to
              @properties['to']
            end

            ##
            # @return [verification_check.Channel] The verification method to use
            def channel
              @properties['channel']
            end

            ##
            # @return [String] The status of the verification resource
            def status
              @properties['status']
            end

            ##
            # @return [Boolean] Whether the verification was successful
            def valid
              @properties['valid']
            end

            ##
            # @return [String] The amount of the associated PSD2 compliant transaction.
            def amount
              @properties['amount']
            end

            ##
            # @return [String] The payee of the associated PSD2 compliant transaction
            def payee
              @properties['payee']
            end

            ##
            # @return [Time] The ISO 8601 date and time in GMT when the Verification Check resource was created
            def date_created
              @properties['date_created']
            end

            ##
            # @return [Time] The ISO 8601 date and time in GMT when the Verification Check resource was last updated
            def date_updated
              @properties['date_updated']
            end

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

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