## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 # / / # # frozen_string_literal: true module Twilio module REST class Verify < Domain class V2 < Version class VerificationAttemptList < ListResource ## # Initialize the VerificationAttemptList # @param [Version] version Version that contains the resource # @return [VerificationAttemptList] VerificationAttemptList def initialize(version) super(version) # Path Solution @solution = {} @uri = "/Attempts" end ## # Lists VerificationAttemptInstance records from the API as a list. # Unlike stream(), this operation is eager and will load `limit` records into # memory before returning. # @param [Time] date_created_after Datetime filter used to query Verification # Attempts created after this datetime. Given as GMT in RFC 2822 format. # @param [Time] date_created_before Datetime filter used to query Verification # Attempts created before this datetime. Given as GMT in RFC 2822 format. # @param [String] channel_data_to Destination of a verification. It is phone # number in E.164 format. # @param [String] country Filter used to query Verification Attempts sent to the # specified destination country. # @param [verification_attempt.Channels] channel Filter used to query Verification # Attempts by communication channel. Valid values are `SMS` and `CALL` # @param [String] verify_service_sid Filter used to query Verification Attempts by # verify service. Only attempts of the provided SID will be returned. # @param [String] verification_sid Filter used to return all the Verification # Attempts of a single verification. Only attempts of the provided verification # SID will be returned. # @param [verification_attempt.ConversionStatus] status Filter used to query # Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for # attempts that were not converted, and `CONVERTED`, for attempts that were # confirmed. # @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(date_created_after: :unset, date_created_before: :unset, channel_data_to: :unset, country: :unset, channel: :unset, verify_service_sid: :unset, verification_sid: :unset, status: :unset, limit: nil, page_size: nil) self.stream( date_created_after: date_created_after, date_created_before: date_created_before, channel_data_to: channel_data_to, country: country, channel: channel, verify_service_sid: verify_service_sid, verification_sid: verification_sid, status: status, limit: limit, page_size: page_size ).entries end ## # Streams VerificationAttemptInstance records from the API as an Enumerable. # This operation lazily loads records as efficiently as possible until the limit # is reached. # @param [Time] date_created_after Datetime filter used to query Verification # Attempts created after this datetime. Given as GMT in RFC 2822 format. # @param [Time] date_created_before Datetime filter used to query Verification # Attempts created before this datetime. Given as GMT in RFC 2822 format. # @param [String] channel_data_to Destination of a verification. It is phone # number in E.164 format. # @param [String] country Filter used to query Verification Attempts sent to the # specified destination country. # @param [verification_attempt.Channels] channel Filter used to query Verification # Attempts by communication channel. Valid values are `SMS` and `CALL` # @param [String] verify_service_sid Filter used to query Verification Attempts by # verify service. Only attempts of the provided SID will be returned. # @param [String] verification_sid Filter used to return all the Verification # Attempts of a single verification. Only attempts of the provided verification # SID will be returned. # @param [verification_attempt.ConversionStatus] status Filter used to query # Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for # attempts that were not converted, and `CONVERTED`, for attempts that were # confirmed. # @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(date_created_after: :unset, date_created_before: :unset, channel_data_to: :unset, country: :unset, channel: :unset, verify_service_sid: :unset, verification_sid: :unset, status: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( date_created_after: date_created_after, date_created_before: date_created_before, channel_data_to: channel_data_to, country: country, channel: channel, verify_service_sid: verify_service_sid, verification_sid: verification_sid, status: status, page_size: limits[:page_size], ) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end ## # When passed a block, yields VerificationAttemptInstance 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 VerificationAttemptInstance records from the API. # Request is executed immediately. # @param [Time] date_created_after Datetime filter used to query Verification # Attempts created after this datetime. Given as GMT in RFC 2822 format. # @param [Time] date_created_before Datetime filter used to query Verification # Attempts created before this datetime. Given as GMT in RFC 2822 format. # @param [String] channel_data_to Destination of a verification. It is phone # number in E.164 format. # @param [String] country Filter used to query Verification Attempts sent to the # specified destination country. # @param [verification_attempt.Channels] channel Filter used to query Verification # Attempts by communication channel. Valid values are `SMS` and `CALL` # @param [String] verify_service_sid Filter used to query Verification Attempts by # verify service. Only attempts of the provided SID will be returned. # @param [String] verification_sid Filter used to return all the Verification # Attempts of a single verification. Only attempts of the provided verification # SID will be returned. # @param [verification_attempt.ConversionStatus] status Filter used to query # Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for # attempts that were not converted, and `CONVERTED`, for attempts that were # confirmed. # @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 VerificationAttemptInstance def page(date_created_after: :unset, date_created_before: :unset, channel_data_to: :unset, country: :unset, channel: :unset, verify_service_sid: :unset, verification_sid: :unset, status: :unset, page_token: :unset, page_number: :unset, page_size: :unset) params = Twilio::Values.of({ 'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after), 'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before), 'ChannelData.To' => channel_data_to, 'Country' => country, 'Channel' => channel, 'VerifyServiceSid' => verify_service_sid, 'VerificationSid' => verification_sid, 'Status' => status, 'PageToken' => page_token, 'Page' => page_number, 'PageSize' => page_size, }) response = @version.page('GET', @uri, params: params) VerificationAttemptPage.new(@version, response, @solution) end ## # Retrieve a single page of VerificationAttemptInstance records from the API. # Request is executed immediately. # @param [String] target_url API-generated URL for the requested results page # @return [Page] Page of VerificationAttemptInstance def get_page(target_url) response = @version.domain.request( 'GET', target_url ) VerificationAttemptPage.new(@version, response, @solution) end ## # Provide a user friendly representation def to_s '#' end end class VerificationAttemptPage < Page ## # Initialize the VerificationAttemptPage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API # @param [Hash] solution Path solution for the resource # @return [VerificationAttemptPage] VerificationAttemptPage def initialize(version, response, solution) super(version, response) # Path Solution @solution = solution end ## # Build an instance of VerificationAttemptInstance # @param [Hash] payload Payload response from the API # @return [VerificationAttemptInstance] VerificationAttemptInstance def get_instance(payload) VerificationAttemptInstance.new(@version, payload, ) end ## # Provide a user friendly representation def to_s '' end end class VerificationAttemptContext < InstanceContext ## # Initialize the VerificationAttemptContext # @param [Version] version Version that contains the resource # @param [String] sid The unique SID identifier of a Verification Attempt # @return [VerificationAttemptContext] VerificationAttemptContext def initialize(version, sid) super(version) # Path Solution @solution = {sid: sid, } @uri = "/Attempts/#{@solution[:sid]}" end ## # Fetch the VerificationAttemptInstance # @return [VerificationAttemptInstance] Fetched VerificationAttemptInstance def fetch payload = @version.fetch('GET', @uri) VerificationAttemptInstance.new(@version, payload, 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 class VerificationAttemptInstance < InstanceResource ## # Initialize the VerificationAttemptInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio # @param [String] sid The unique SID identifier of a Verification Attempt # @return [VerificationAttemptInstance] VerificationAttemptInstance def initialize(version, payload, sid: nil) super(version) # Marshaled Properties @properties = { 'sid' => payload['sid'], 'account_sid' => payload['account_sid'], 'service_sid' => payload['service_sid'], 'verification_sid' => payload['verification_sid'], 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 'conversion_status' => payload['conversion_status'], 'channel' => payload['channel'], 'price' => payload['price'], 'channel_data' => payload['channel_data'], 'url' => payload['url'], } # 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 [VerificationAttemptContext] VerificationAttemptContext for this VerificationAttemptInstance def context unless @instance_context @instance_context = VerificationAttemptContext.new(@version, @params['sid'], ) end @instance_context end ## # @return [String] The SID that uniquely identifies the verification attempt. def sid @properties['sid'] end ## # @return [String] The SID of the Account that created the verification. def account_sid @properties['account_sid'] end ## # @return [String] The SID of the verify service that generated this attempt. def service_sid @properties['service_sid'] end ## # @return [String] The SID of the verification that generated this attempt. def verification_sid @properties['verification_sid'] end ## # @return [Time] The date this Attempt was created def date_created @properties['date_created'] end ## # @return [Time] The date this Attempt was updated def date_updated @properties['date_updated'] end ## # @return [verification_attempt.ConversionStatus] Status of the conversion for the verification. def conversion_status @properties['conversion_status'] end ## # @return [verification_attempt.Channels] Communication channel used for the attempt. def channel @properties['channel'] end ## # @return [Hash] An object containing the charge for this verification attempt. def price @properties['price'] end ## # @return [Hash] An object containing the channel specific information for an attempt. def channel_data @properties['channel_data'] end ## # @return [String] The url def url @properties['url'] end ## # Fetch the VerificationAttemptInstance # @return [VerificationAttemptInstance] Fetched VerificationAttemptInstance 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