Class: Twilio::REST::Verify::V2::ServiceContext::EntityContext::ChallengeContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb,
lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Defined Under Namespace

Classes: NotificationInstance, NotificationList, NotificationPage

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, identity, sid) ⇒ ChallengeContext

Initialize the ChallengeContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The unique SID identifier of the Service.

  • identity (String)

    Customer unique identity for the Entity owner of the Challenges. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.

  • sid (String)

    A 34 character string that uniquely identifies this Challenge.


248
249
250
251
252
253
254
255
256
257
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 248

def initialize(version, service_sid, identity, sid)
  super(version)

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

  # Dependents
  @notifications = nil
end

Instance Method Details

#fetchChallengeInstance

Fetch the ChallengeInstance

Returns:


262
263
264
265
266
267
268
269
270
271
272
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 262

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

  ChallengeInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      identity: @solution[:identity],
      sid: @solution[:sid],
  )
end

#inspectObject

Provide a detailed, user friendly representation


328
329
330
331
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 328

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

#notificationsNotificationList, NotificationContext

Access the notifications

Returns:


306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 306

def notifications
  unless @notifications
    @notifications = NotificationList.new(
        @version,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
        challenge_sid: @solution[:sid],
    )
  end

  @notifications
end

#to_sObject

Provide a user friendly representation


321
322
323
324
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 321

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

#update(auth_payload: :unset, metadata: :unset) ⇒ ChallengeInstance

Update the ChallengeInstance

Parameters:

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

    The optional payload needed to verify the Challenge. E.g., a TOTP would use the numeric code. For `TOTP` this value must be between 3 and 8 characters long. For `Push` this value can be up to 5456 characters in length

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

    Custom metadata associated with the challenge. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `“Android”`. Can be up to 1024 characters in length.

Returns:


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

def update(auth_payload: :unset, metadata: :unset)
  data = Twilio::Values.of({
      'AuthPayload' => auth_payload,
      'Metadata' => Twilio.serialize_object(),
  })

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

  ChallengeInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      identity: @solution[:identity],
      sid: @solution[:sid],
  )
end