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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, identity: nil, sid: nil) ⇒ ChallengeInstance

Initialize the ChallengeInstance

Parameters:

  • version (Version) —

    Version that contains the resource

  • payload (Hash) —

    payload that contains response from Twilio

  • service_sid (String) (defaults to: nil) —

    The unique SID identifier of the Service.

  • identity (String) (defaults to: nil) —

    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) (defaults to: nil) —

    A 34 character string that uniquely identifies this Challenge.



341
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
367
368
369
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 341

def initialize(version, payload, service_sid: nil, identity: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'account_sid' => payload['account_sid'],
      'service_sid' => payload['service_sid'],
      'entity_sid' => payload['entity_sid'],
      'identity' => payload['identity'],
      'factor_sid' => payload['factor_sid'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'date_responded' => Twilio.deserialize_iso8601_datetime(payload['date_responded']),
      'expiration_date' => Twilio.deserialize_iso8601_datetime(payload['expiration_date']),
      'status' => payload['status'],
      'responded_reason' => payload['responded_reason'],
      'details' => payload['details'],
      'hidden_details' => payload['hidden_details'],
      'metadata' => payload['metadata'],
      'factor_type' => payload['factor_type'],
      'url' => payload['url'],
      'links' => payload['links'],
  }

  # Context
  @instance_context = nil
  @params = {'service_sid' => service_sid, 'identity' => identity, 'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sid ⇒ String

Returns Account Sid.

Returns:

  • (String) —

    Account Sid.



395
396
397
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 395

def 
  @properties['account_sid']
end

#context ⇒ ChallengeContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



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

def context
  unless @instance_context
    @instance_context = ChallengeContext.new(
        @version,
        @params['service_sid'],
        @params['identity'],
        @params['sid'],
    )
  end
  @instance_context
end

#date_created ⇒ Time

Returns The date this Challenge was created.

Returns:

  • (Time) —

    The date this Challenge was created



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

def date_created
  @properties['date_created']
end

#date_responded ⇒ Time

Returns The date this Challenge was responded.

Returns:

  • (Time) —

    The date this Challenge was responded



437
438
439
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 437

def date_responded
  @properties['date_responded']
end

#date_updated ⇒ Time

Returns The date this Challenge was updated.

Returns:

  • (Time) —

    The date this Challenge was updated



431
432
433
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 431

def date_updated
  @properties['date_updated']
end

#details ⇒ Hash

Returns Details about the Challenge.

Returns:

  • (Hash) —

    Details about the Challenge.



461
462
463
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 461

def details
  @properties['details']
end

#entity_sid ⇒ String

Returns Entity Sid.

Returns:

  • (String) —

    Entity Sid.



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

def entity_sid
  @properties['entity_sid']
end

#expiration_date ⇒ Time

Returns The date-time when this Challenge expires.

Returns:

  • (Time) —

    The date-time when this Challenge expires



443
444
445
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 443

def expiration_date
  @properties['expiration_date']
end

#factor_sid ⇒ String

Returns Factor Sid.

Returns:

  • (String) —

    Factor Sid.



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

def factor_sid
  @properties['factor_sid']
end

#factor_type ⇒ challenge.FactorTypes

Returns The Factor Type of this Challenge.

Returns:

  • (challenge.FactorTypes) —

    The Factor Type of this Challenge



479
480
481
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 479

def factor_type
  @properties['factor_type']
end

#fetch ⇒ ChallengeInstance

Fetch the ChallengeInstance

Returns:



498
499
500
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 498

def fetch
  context.fetch
end

#hidden_details ⇒ Hash

Returns Hidden details about the Challenge.

Returns:

  • (Hash) —

    Hidden details about the Challenge



467
468
469
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 467

def hidden_details
  @properties['hidden_details']
end

#identity ⇒ String

Returns Unique external identifier of the Entity.

Returns:

  • (String) —

    Unique external identifier of the Entity



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

def identity
  @properties['identity']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



533
534
535
536
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 533

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Verify.V2.ChallengeInstance #{values}>"
end

Returns Nested resource URLs.

Returns:

  • (String) —

    Nested resource URLs.



491
492
493
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 491

def links
  @properties['links']
end

#metadata ⇒ Hash

Returns Metadata of the challenge.

Returns:

  • (Hash) —

    Metadata of the challenge.



473
474
475
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 473

def 
  @properties['metadata']
end

#notifications ⇒ notifications

Access the notifications

Returns:



520
521
522
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 520

def notifications
  context.notifications
end

#responded_reason ⇒ challenge.ChallengeReasons

Returns The Reason of this Challenge status.

Returns:

  • (challenge.ChallengeReasons) —

    The Reason of this Challenge status



455
456
457
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 455

def responded_reason
  @properties['responded_reason']
end

#service_sid ⇒ String

Returns Service Sid.

Returns:

  • (String) —

    Service Sid.



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

def service_sid
  @properties['service_sid']
end

#sid ⇒ String

Returns A string that uniquely identifies this Challenge.

Returns:

  • (String) —

    A string that uniquely identifies this Challenge.



389
390
391
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 389

def sid
  @properties['sid']
end

#status ⇒ challenge.ChallengeStatuses

Returns The Status of this Challenge.

Returns:

  • (challenge.ChallengeStatuses) —

    The Status of this Challenge



449
450
451
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 449

def status
  @properties['status']
end

#to_s ⇒ Object

Provide a user friendly representation



526
527
528
529
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 526

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Verify.V2.ChallengeInstance #{values}>"
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. {"os": "Android"}. Can be up to 1024 characters in length.

Returns:



513
514
515
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 513

def update(auth_payload: :unset, metadata: :unset)
  context.update(auth_payload: auth_payload, metadata: , )
end

#url ⇒ String

Returns The URL of this resource.

Returns:

  • (String) —

    The URL of this resource.



485
486
487
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 485

def url
  @properties['url']
end