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

Defined Under Namespace

Classes: NotificationInstance, NotificationList, NotificationListResponse, NotificationPage, NotificationPageMetadata

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 Challenge. 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.



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

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:



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

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    ChallengeInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
        sid: @solution[:sid],
    )
end

#fetch_with_metadataChallengeInstance

Fetch the ChallengeInstanceMetadata

Returns:



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 321

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    challenge_instance = ChallengeInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
        sid: @solution[:sid],
    )
    ChallengeInstanceMetadata.new(
        @version,
        challenge_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



434
435
436
437
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 434

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

#notificationsNotificationList, NotificationContext

Access the notifications

Returns:



417
418
419
420
421
422
423
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 417

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



427
428
429
430
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 427

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 (Object) (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:



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 350

def update(
  auth_payload: :unset, 
  metadata: :unset
)

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

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    ChallengeInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
        sid: @solution[:sid],
    )
end

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

Update the ChallengeInstanceMetadata

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 (Object) (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:



381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 381

def (
  auth_payload: :unset, 
  metadata: :unset
)

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

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    challenge_instance = ChallengeInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
        sid: @solution[:sid],
    )
    ChallengeInstanceMetadata.new(
        @version,
        challenge_instance,
        response.headers,
        response.status_code
    )
end