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



278
279
280
281
282
283
284
285
286
287
288
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 278

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



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 292

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



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 313

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],
    )
    .new(
        @version,
        challenge_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#notificationsNotificationList, NotificationContext

Access the notifications



409
410
411
412
413
414
415
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 409

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



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

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



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 342

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



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 373

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],
    )
    .new(
        @version,
        challenge_instance,
        response.headers,
        response.status_code
    )
end