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 preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

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.

  • sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this Factor.



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 301

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.



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

def 
  @properties['account_sid']
end

#configHash

Returns The config.

Returns:

  • (Hash)

    The config



403
404
405
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 403

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:



329
330
331
332
333
334
335
336
337
338
339
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 329

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



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

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date this Factor was updated.

Returns:

  • (Time)

    The date this Factor was updated



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

def date_updated
  @properties['date_updated']
end

#delete(twilio_sandbox_mode: :unset) ⇒ Boolean

Delete the FactorInstance

Parameters:

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

    The Twilio-Sandbox-Mode HTTP request header

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



417
418
419
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 417

def delete(twilio_sandbox_mode: :unset)
  context.delete(twilio_sandbox_mode: twilio_sandbox_mode, )
end

#entity_sidString

Returns Entity Sid.

Returns:

  • (String)

    Entity Sid.



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

def entity_sid
  @properties['entity_sid']
end

#factor_typefactor.FactorTypes

Returns The Type of this Factor.

Returns:

  • (factor.FactorTypes)

    The Type of this Factor



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

def factor_type
  @properties['factor_type']
end

#fetch(twilio_sandbox_mode: :unset) ⇒ FactorInstance

Fetch the FactorInstance

Parameters:

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

    The Twilio-Sandbox-Mode HTTP request header

Returns:



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

def fetch(twilio_sandbox_mode: :unset)
  context.fetch(twilio_sandbox_mode: twilio_sandbox_mode, )
end

#friendly_nameString

Returns A human readable description of this resource.

Returns:

  • (String)

    A human readable description of this resource.



385
386
387
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 385

def friendly_name
  @properties['friendly_name']
end

#identityString

Returns Unique external identifier of the Entity.

Returns:

  • (String)

    Unique external identifier of the Entity



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

def identity
  @properties['identity']
end

#inspectObject

Provide a detailed, user friendly representation



456
457
458
459
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 456

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.



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

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.



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

def sid
  @properties['sid']
end

#statusfactor.FactorStatuses

Returns The Status of this Factor.

Returns:

  • (factor.FactorStatuses)

    The Status of this Factor



391
392
393
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 391

def status
  @properties['status']
end

#to_sObject

Provide a user friendly representation



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

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: :unset, twilio_sandbox_mode: :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

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

    The new config for this Factor. It must be a json string with the required properties for the given factor type

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

    The Twilio-Sandbox-Mode HTTP request header

Returns:



438
439
440
441
442
443
444
445
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 438

def update(auth_payload: :unset, friendly_name: :unset, config: :unset, twilio_sandbox_mode: :unset)
  context.update(
      auth_payload: auth_payload,
      friendly_name: friendly_name,
      config: config,
      twilio_sandbox_mode: twilio_sandbox_mode,
  )
end

#urlString

Returns The URL of this resource.

Returns:

  • (String)

    The URL of this resource.



409
410
411
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 409

def url
  @properties['url']
end