## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 # / / # # frozen_string_literal: true module Twilio module REST class Verify < Domain class V1 < Version class ServiceContext < InstanceContext ## # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. class VerificationList < ListResource ## # Initialize the VerificationList # @param [Version] version Version that contains the resource # @param [String] service_sid The unique SID identifier of the Service. # @return [VerificationList] VerificationList def initialize(version, service_sid: nil) super(version) # Path Solution @solution = {service_sid: service_sid} @uri = "/Services/#{@solution[:service_sid]}/Verifications" end ## # Retrieve a single page of VerificationInstance records from the API. # Request is executed immediately. # @param [String] to The To phonenumber of the phone being verified # @param [String] channel The method in which the phone will be verified. Either # sms or call # @param [String] custom_message A character string containing a custom message # for this verification # @param [String] send_digits Digits to send when a phone call is started, same # parameters as in Programmable Voice are supported # @param [String] locale Supported values are af, ar, ca, cs, da, de, el, en, es, # fi, fr, he, hi, hr, hu, id, it, ja, ko, ms, nb, nl, pl, pt, pr-BR, ro, ru, sv, # th, tl, tr, vi, zh, zh-CN, zh-HK # @param [String] custom_code Pass in a pre-generated code. Code length can be # between 4-10 characters. # @param [String] amount Amount of the associated PSD2 compliant transaction. # Requires the PSD2 Service flag enabled. # @param [String] payee Payee of the associated PSD2 compliant transaction. # Requires the PSD2 Service flag enabled. # @return [VerificationInstance] Newly created VerificationInstance def create(to: nil, channel: nil, custom_message: :unset, send_digits: :unset, locale: :unset, custom_code: :unset, amount: :unset, payee: :unset) data = Twilio::Values.of({ 'To' => to, 'Channel' => channel, 'CustomMessage' => custom_message, 'SendDigits' => send_digits, 'Locale' => locale, 'CustomCode' => custom_code, 'Amount' => amount, 'Payee' => payee, }) payload = @version.create( 'POST', @uri, data: data ) VerificationInstance.new(@version, payload, service_sid: @solution[:service_sid], ) end ## # Provide a user friendly representation def to_s '#' end end ## # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. class VerificationPage < Page ## # Initialize the VerificationPage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API # @param [Hash] solution Path solution for the resource # @return [VerificationPage] VerificationPage def initialize(version, response, solution) super(version, response) # Path Solution @solution = solution end ## # Build an instance of VerificationInstance # @param [Hash] payload Payload response from the API # @return [VerificationInstance] VerificationInstance def get_instance(payload) VerificationInstance.new(@version, payload, service_sid: @solution[:service_sid], ) end ## # Provide a user friendly representation def to_s '' end end ## # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. class VerificationContext < InstanceContext ## # Initialize the VerificationContext # @param [Version] version Version that contains the resource # @param [String] service_sid The unique SID identifier of the Service. # @param [String] sid A 34 character string that uniquely identifies this # Verification or the associated phone number. # @return [VerificationContext] VerificationContext def initialize(version, service_sid, sid) super(version) # Path Solution @solution = {service_sid: service_sid, sid: sid, } @uri = "/Services/#{@solution[:service_sid]}/Verifications/#{@solution[:sid]}" end ## # Update the VerificationInstance # @param [verification.Status] status New status to set for the Verification, only # canceled is allowed at the moment. # @return [VerificationInstance] Updated VerificationInstance def update(status: nil) data = Twilio::Values.of({'Status' => status, }) payload = @version.update( 'POST', @uri, data: data, ) VerificationInstance.new( @version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end ## # Fetch a VerificationInstance # @return [VerificationInstance] Fetched VerificationInstance def fetch params = Twilio::Values.of({}) payload = @version.fetch( 'GET', @uri, params, ) VerificationInstance.new( @version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end ## # Provide a user friendly representation def to_s context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') "#" end ## # Provide a detailed, user friendly representation def inspect context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') "#" end end ## # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. class VerificationInstance < InstanceResource ## # Initialize the VerificationInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio # @param [String] service_sid The unique SID identifier of the Service. # @param [String] sid A 34 character string that uniquely identifies this # Verification or the associated phone number. # @return [VerificationInstance] VerificationInstance def initialize(version, payload, service_sid: nil, 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'], 'lookup' => payload['lookup'], 'amount' => payload['amount'], 'payee' => payload['payee'], 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 'url' => payload['url'], } # Context @instance_context = nil @params = {'service_sid' => service_sid, '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 [VerificationContext] VerificationContext for this VerificationInstance def context unless @instance_context @instance_context = VerificationContext.new(@version, @params['service_sid'], @params['sid'], ) end @instance_context end ## # @return [String] A string that uniquely identifies this Verification. def sid @properties['sid'] end ## # @return [String] Service Sid. def service_sid @properties['service_sid'] end ## # @return [String] Account Sid. def account_sid @properties['account_sid'] end ## # @return [String] To phonenumber def to @properties['to'] end ## # @return [verification.Channel] sms or call def channel @properties['channel'] end ## # @return [String] pending, approved, denied or expired def status @properties['status'] end ## # @return [Boolean] successful verification def valid @properties['valid'] end ## # @return [Hash] Info about the phone number def lookup @properties['lookup'] end ## # @return [String] Amount of the associated PSD2 compliant transaction. def amount @properties['amount'] end ## # @return [String] Payee of the associated PSD2 compliant transaction. def payee @properties['payee'] end ## # @return [Time] The date this Verification was created def date_created @properties['date_created'] end ## # @return [Time] The date this Verification was updated def date_updated @properties['date_updated'] end ## # @return [String] The URL of this resource. def url @properties['url'] end ## # Update the VerificationInstance # @param [verification.Status] status New status to set for the Verification, only # canceled is allowed at the moment. # @return [VerificationInstance] Updated VerificationInstance def update(status: nil) context.update(status: status, ) end ## # Fetch a VerificationInstance # @return [VerificationInstance] Fetched VerificationInstance def fetch context.fetch end ## # Provide a user friendly representation def to_s values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") "" end ## # Provide a detailed, user friendly representation def inspect values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") "" end end end end end end end