## # 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 ServiceContext < InstanceContext class VerificationList < ListResource ## # Initialize the VerificationList # @param [Version] version Version that contains the resource # @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 ## # Create the VerificationInstance # @param [String] to The phone number or [email](https://www.twilio.com/docs/verify/email) to verify. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). # @param [String] channel The verification method to use. One of: [`email`](https://www.twilio.com/docs/verify/email), `sms`, `whatsapp`, `call`, `sna` or `auto`. # @param [String] custom_friendly_name A custom user defined friendly name that overwrites the existing one in the verification message # @param [String] custom_message The text of a custom message to use for the verification. # @param [String] send_digits The digits to send after a phone call is answered, for example, to dial an extension. For more information, see the Programmable Voice documentation of [sendDigits](https://www.twilio.com/docs/voice/twiml/number#attributes-sendDigits). # @param [String] locale Locale will automatically resolve based on phone number country code for SMS, WhatsApp, and call channel verifications. It will fallback to English or the template’s default translation if the selected translation is not available. This parameter will override the automatic locale resolution. [See supported languages and more information here](https://www.twilio.com/docs/verify/supported-languages). # @param [String] custom_code A pre-generated code to use for verification. The code can be between 4 and 10 characters, inclusive. # @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. # @param [Object] rate_limits The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request. # @param [Object] channel_configuration [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields 'from' and 'from_name' are optional but if included the 'from' field must have a valid email address. # @param [String] app_hash Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`. # @param [String] template_sid The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. # @param [String] template_custom_substitutions A stringified JSON object in which the keys are the template's special variables and the values are the variables substitutions. # @param [String] device_ip Strongly encouraged if using the auto channel. The IP address of the client's device. If provided, it has to be a valid IPv4 or IPv6 address. # @param [RiskCheck] risk_check # @param [String] tags A string containing a JSON map of key value pairs of tags to be recorded as metadata for the message. The object may contain up to 10 tags. Keys and values can each be up to 128 characters in length. # @return [VerificationInstance] Created VerificationInstance def create( to: nil, channel: nil, custom_friendly_name: :unset, custom_message: :unset, send_digits: :unset, locale: :unset, custom_code: :unset, amount: :unset, payee: :unset, rate_limits: :unset, channel_configuration: :unset, app_hash: :unset, template_sid: :unset, template_custom_substitutions: :unset, device_ip: :unset, risk_check: :unset, tags: :unset ) data = Twilio::Values.of({ 'To' => to, 'Channel' => channel, 'CustomFriendlyName' => custom_friendly_name, 'CustomMessage' => custom_message, 'SendDigits' => send_digits, 'Locale' => locale, 'CustomCode' => custom_code, 'Amount' => amount, 'Payee' => payee, 'RateLimits' => Twilio.serialize_object(rate_limits), 'ChannelConfiguration' => Twilio.serialize_object(channel_configuration), 'AppHash' => app_hash, 'TemplateSid' => template_sid, 'TemplateCustomSubstitutions' => template_custom_substitutions, 'DeviceIp' => device_ip, 'RiskCheck' => risk_check, 'Tags' => tags, }) 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 class VerificationContext < InstanceContext ## # Initialize the VerificationContext # @param [Version] version Version that contains the resource # @param [String] service_sid The SID of the verification [Service](https://www.twilio.com/docs/verify/api/service) to update the resource from. # @param [String] sid The Twilio-provided string that uniquely identifies the Verification resource to update. # @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 ## # Fetch the VerificationInstance # @return [VerificationInstance] Fetched VerificationInstance def fetch payload = @version.fetch('GET', @uri) VerificationInstance.new( @version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end ## # Update the VerificationInstance # @param [Status] status # @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 ## # 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 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 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] account_sid The SID of the # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Verification # resource. # @param [String] sid The SID of the Call resource to fetch. # @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'], 'send_code_attempts' => payload['send_code_attempts'], 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 'sna' => payload['sna'], 'url' => payload['url'], } # Context @instance_context = nil @params = { 'service_sid' => service_sid || @properties['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] CallContext for this CallInstance def context unless @instance_context @instance_context = VerificationContext.new(@version , @params['service_sid'], @params['sid']) end @instance_context end ## # @return [String] The unique string that we created to identify the Verification resource. def sid @properties['sid'] end ## # @return [String] The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with. def service_sid @properties['service_sid'] end ## # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Verification resource. def account_sid @properties['account_sid'] end ## # @return [String] The phone number or [email](https://www.twilio.com/docs/verify/email) being verified. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). def to @properties['to'] end ## # @return [Channel] def channel @properties['channel'] end ## # @return [String] The status of the verification. Can be: `pending`, `approved`, `canceled`, `max_attempts_reached`, `deleted`, `failed` or `expired`. def status @properties['status'] end ## # @return [Boolean] Use \"status\" instead. Legacy property indicating whether the verification was successful. def valid @properties['valid'] end ## # @return [Hash] Information about the phone number being verified. def lookup @properties['lookup'] end ## # @return [String] The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. def amount @properties['amount'] end ## # @return [String] The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. def payee @properties['payee'] end ## # @return [Array] An array of verification attempt objects containing the channel attempted and the channel-specific transaction SID. def send_code_attempts @properties['send_code_attempts'] 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 [Hash] The set of fields used for a silent network auth (`sna`) verification. Contains a single field with the URL to be invoked to verify the phone number. def sna @properties['sna'] end ## # @return [String] The absolute URL of the Verification resource. def url @properties['url'] end ## # Fetch the VerificationInstance # @return [VerificationInstance] Fetched VerificationInstance def fetch context.fetch end ## # Update the VerificationInstance # @param [Status] status # @return [VerificationInstance] Updated VerificationInstance def update( status: nil ) context.update( status: status, ) 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