Class: Twilio::REST::Verify::V2::ServiceContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/verify/v2/service.rb,
lib/twilio-ruby/rest/verify/v2/service/entity.rb,
lib/twilio-ruby/rest/verify/v2/service/webhook.rb,
lib/twilio-ruby/rest/verify/v2/service/rate_limit.rb,
lib/twilio-ruby/rest/verify/v2/service/access_token.rb,
lib/twilio-ruby/rest/verify/v2/service/verification.rb,
lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb,
lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb,
lib/twilio-ruby/rest/verify/v2/service/rate_limit/bucket.rb,
lib/twilio-ruby/rest/verify/v2/service/verification_check.rb,
lib/twilio-ruby/rest/verify/v2/service/messaging_configuration.rb

Defined Under Namespace

Classes: AccessTokenInstance, AccessTokenList, AccessTokenPage, EntityContext, EntityInstance, EntityList, EntityPage, MessagingConfigurationContext, MessagingConfigurationInstance, MessagingConfigurationList, MessagingConfigurationPage, RateLimitContext, RateLimitInstance, RateLimitList, RateLimitPage, VerificationCheckInstance, VerificationCheckList, VerificationCheckPage, VerificationContext, VerificationInstance, VerificationList, VerificationPage, WebhookContext, WebhookInstance, WebhookList, WebhookPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ServiceContext

Initialize the ServiceContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The Twilio-provided string that uniquely identifies the Verification Service resource to fetch.



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 201

def initialize(version, sid)
  super(version)

  # Path Solution
  @solution = {sid: sid, }
  @uri = "/Services/#{@solution[:sid]}"

  # Dependents
  @verifications = nil
  @verification_checks = nil
  @rate_limits = nil
  @messaging_configurations = nil
  @entities = nil
  @webhooks = nil
  @access_tokens = nil
end

Instance Method Details

#access_tokensAccessTokenList, AccessTokenContext

Access the access_tokens

Returns:



390
391
392
393
394
395
396
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 390

def access_tokens
  unless @access_tokens
    @access_tokens = AccessTokenList.new(@version, service_sid: @solution[:sid], )
  end

  @access_tokens
end

#deleteBoolean

Delete the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



230
231
232
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 230

def delete
   @version.delete('DELETE', @uri)
end

#entities(identity = :unset) ⇒ EntityList, EntityContext

Access the entities

Returns:

Raises:

  • (ArgumentError)


354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 354

def entities(identity=:unset)
  raise ArgumentError, 'identity cannot be nil' if identity.nil?

  if identity != :unset
    return EntityContext.new(@version, @solution[:sid], identity, )
  end

  unless @entities
    @entities = EntityList.new(@version, service_sid: @solution[:sid], )
  end

  @entities
end

#fetchServiceInstance

Fetch the ServiceInstance

Returns:



221
222
223
224
225
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 221

def fetch
  payload = @version.fetch('GET', @uri)

  ServiceInstance.new(@version, payload, sid: @solution[:sid], )
end

#inspectObject

Provide a detailed, user friendly representation



407
408
409
410
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 407

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Verify.V2.ServiceContext #{context}>"
end

#messaging_configurations(country = :unset) ⇒ MessagingConfigurationList, MessagingConfigurationContext

Access the messaging_configurations

Returns:

Raises:

  • (ArgumentError)


336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 336

def messaging_configurations(country=:unset)
  raise ArgumentError, 'country cannot be nil' if country.nil?

  if country != :unset
    return MessagingConfigurationContext.new(@version, @solution[:sid], country, )
  end

  unless @messaging_configurations
    @messaging_configurations = MessagingConfigurationList.new(@version, service_sid: @solution[:sid], )
  end

  @messaging_configurations
end

#rate_limits(sid = :unset) ⇒ RateLimitList, RateLimitContext

Access the rate_limits

Returns:

Raises:

  • (ArgumentError)


318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 318

def rate_limits(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return RateLimitContext.new(@version, @solution[:sid], sid, )
  end

  unless @rate_limits
    @rate_limits = RateLimitList.new(@version, service_sid: @solution[:sid], )
  end

  @rate_limits
end

#to_sObject

Provide a user friendly representation



400
401
402
403
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 400

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Verify.V2.ServiceContext #{context}>"
end

#update(friendly_name: :unset, code_length: :unset, lookup_enabled: :unset, skip_sms_to_landlines: :unset, dtmf_input_required: :unset, tts_name: :unset, psd2_enabled: :unset, do_not_share_warning_enabled: :unset, custom_code_enabled: :unset, push: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

  • friendly_name (String) (defaults to: :unset)

    A descriptive string that you create to describe the verification service. It can be up to 64 characters long. **This value should not contain PII.**

  • code_length (String) (defaults to: :unset)

    The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive.

  • lookup_enabled (Boolean) (defaults to: :unset)

    Whether to perform a lookup with each verification started and return info about the phone number.

  • skip_sms_to_landlines (Boolean) (defaults to: :unset)

    Whether to skip sending SMS verifications to landlines. Requires ‘lookup_enabled`.

  • dtmf_input_required (Boolean) (defaults to: :unset)

    Whether to ask the user to press a number before delivering the verify code in a phone call.

  • tts_name (String) (defaults to: :unset)

    The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages.

  • psd2_enabled (Boolean) (defaults to: :unset)

    Whether to pass PSD2 transaction parameters when starting a verification.

  • do_not_share_warning_enabled (Boolean) (defaults to: :unset)

    Whether to add a privacy warning at the end of an SMS. **Disabled by default and applies only for SMS.**

  • custom_code_enabled (Boolean) (defaults to: :unset)

    Whether to allow sending verifications with a custom code instead of a randomly generated one. Not available for all customers.

  • push (Hash) (defaults to: :unset)

    Configurations for the Push factors (channel) created under this Service. If present, it must be a json string with the following format: “ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”, “include_date”: true. If ‘include_date` is set to `true`, which is the default, that means that the push challenge’s response will include the date created value. If `include_date` is set to `false`, then the date created value will not be included. See [Challenge](www.twilio.com/docs/verify/api/challenge) resource’s details parameter for more info

Returns:



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 265

def update(friendly_name: :unset, code_length: :unset, lookup_enabled: :unset, skip_sms_to_landlines: :unset, dtmf_input_required: :unset, tts_name: :unset, psd2_enabled: :unset, do_not_share_warning_enabled: :unset, custom_code_enabled: :unset, push: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'CodeLength' => code_length,
      'LookupEnabled' => lookup_enabled,
      'SkipSmsToLandlines' => skip_sms_to_landlines,
      'DtmfInputRequired' => dtmf_input_required,
      'TtsName' => tts_name,
      'Psd2Enabled' => psd2_enabled,
      'DoNotShareWarningEnabled' => do_not_share_warning_enabled,
      'CustomCodeEnabled' => custom_code_enabled,
      'Push' => Twilio.serialize_object(push),
  })

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

  ServiceInstance.new(@version, payload, sid: @solution[:sid], )
end

#verification_checksVerificationCheckList, VerificationCheckContext

Access the verification_checks

Returns:



306
307
308
309
310
311
312
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 306

def verification_checks
  unless @verification_checks
    @verification_checks = VerificationCheckList.new(@version, service_sid: @solution[:sid], )
  end

  @verification_checks
end

#verifications(sid = :unset) ⇒ VerificationList, VerificationContext

Access the verifications

Returns:

Raises:

  • (ArgumentError)


288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 288

def verifications(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return VerificationContext.new(@version, @solution[:sid], sid, )
  end

  unless @verifications
    @verifications = VerificationList.new(@version, service_sid: @solution[:sid], )
  end

  @verifications
end

#webhooks(sid = :unset) ⇒ WebhookList, WebhookContext

Access the webhooks

Returns:

Raises:

  • (ArgumentError)


372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/twilio-ruby/rest/verify/v2/service.rb', line 372

def webhooks(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return WebhookContext.new(@version, @solution[:sid], sid, )
  end

  unless @webhooks
    @webhooks = WebhookList.new(@version, service_sid: @solution[:sid], )
  end

  @webhooks
end