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

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

Overview

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

Instance Method Summary collapse

Constructor Details

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

Initialize the FactorInstance

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)

    The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, and generated by your external system, such as your user's UUID, GUID, or SID. This value must be between 8 and 64 characters long.

  • sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this Factor.


273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 273

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'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'friendly_name' => payload['friendly_name'],
      'status' => payload['status'],
      'factor_type' => payload['factor_type'],
      'config' => payload['config'],
      'url' => payload['url'],
  }

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

Instance Method Details

#account_sidString

Returns Account Sid.

Returns:

  • (String)

    Account Sid.


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

def 
  @properties['account_sid']
end

#configHash

Returns Configurations for a `factor_type`.

Returns:

  • (Hash)

    Configurations for a `factor_type`.


375
376
377
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 375

def config
  @properties['config']
end

#contextFactorContext

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

Returns:


301
302
303
304
305
306
307
308
309
310
311
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 301

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

#date_createdTime

Returns The date this Factor was created.

Returns:

  • (Time)

    The date this Factor was created


345
346
347
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 345

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date this Factor was updated.

Returns:

  • (Time)

    The date this Factor was updated


351
352
353
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 351

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Delete the FactorInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


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

def delete
  context.delete
end

#entity_sidString

Returns Entity Sid.

Returns:

  • (String)

    Entity Sid.


333
334
335
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 333

def entity_sid
  @properties['entity_sid']
end

#factor_typefactor.FactorTypes

Returns The Type of this Factor.

Returns:

  • (factor.FactorTypes)

    The Type of this Factor


369
370
371
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 369

def factor_type
  @properties['factor_type']
end

#fetchFactorInstance

Fetch the FactorInstance

Returns:


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

def fetch
  context.fetch
end

#friendly_nameString

Returns A human readable description of this resource.

Returns:

  • (String)

    A human readable description of this resource.


357
358
359
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 357

def friendly_name
  @properties['friendly_name']
end

#identityString

Returns Unique external identifier of the Entity.

Returns:

  • (String)

    Unique external identifier of the Entity


339
340
341
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 339

def identity
  @properties['identity']
end

#inspectObject

Provide a detailed, user friendly representation


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

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

#service_sidString

Returns Service Sid.

Returns:

  • (String)

    Service Sid.


327
328
329
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 327

def service_sid
  @properties['service_sid']
end

#sidString

Returns A string that uniquely identifies this Factor.

Returns:

  • (String)

    A string that uniquely identifies this Factor.


315
316
317
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 315

def sid
  @properties['sid']
end

#statusfactor.FactorStatuses

Returns The Status of this Factor.

Returns:

  • (factor.FactorStatuses)

    The Status of this Factor


363
364
365
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 363

def status
  @properties['status']
end

#to_sObject

Provide a user friendly representation


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

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

#update(auth_payload: :unset, friendly_name: :unset, config_notification_token: :unset, config_sdk_version: :unset, config_time_step: :unset, config_skew: :unset, config_code_length: :unset, config_alg: :unset) ⇒ FactorInstance

Update the FactorInstance

Parameters:

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

    The optional payload needed to verify the Factor for the first time. E.g. for a TOTP, the numeric code.

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

    The new friendly name of this Factor. It can be up to 64 characters.

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

    For APN, the device token. For FCM the registration token. It used to send the push notifications. Required when `factor_type` is `push`. If specified, this value must be between 32 and 255 characters long.

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

    The Verify Push SDK version used to configure the factor

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

    Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive

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

    The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive

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

    Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive

  • config_alg (factor.TotpAlgorithms) (defaults to: :unset)

    The algorithm used to derive the TOTP codes. Can be `sha1`, `sha256` or `sha512`

Returns:


421
422
423
424
425
426
427
428
429
430
431
432
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 421

def update(auth_payload: :unset, friendly_name: :unset, config_notification_token: :unset, config_sdk_version: :unset, config_time_step: :unset, config_skew: :unset, config_code_length: :unset, config_alg: :unset)
  context.update(
      auth_payload: auth_payload,
      friendly_name: friendly_name,
      config_notification_token: config_notification_token,
      config_sdk_version: config_sdk_version,
      config_time_step: config_time_step,
      config_skew: config_skew,
      config_code_length: config_code_length,
      config_alg: config_alg,
  )
end

#urlString

Returns The URL of this resource.

Returns:

  • (String)

    The URL of this resource.


381
382
383
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 381

def url
  @properties['url']
end