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

Inherits:
InstanceContext
  • 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, service_sid, identity, sid) ⇒ FactorContext

Initialize the FactorContext

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 Factor. This value must be between 8 and 64 characters long.

  • sid (String)

    A 34 character string that uniquely identifies this Factor.


169
170
171
172
173
174
175
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 169

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]}/Factors/#{@solution[:sid]}"
end

Instance Method Details

#deleteBoolean

Delete the FactorInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


180
181
182
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 180

def delete
   @version.delete('DELETE', @uri)
end

#fetchFactorInstance

Fetch the FactorInstance

Returns:


187
188
189
190
191
192
193
194
195
196
197
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 187

def fetch
  payload = @version.fetch('GET', @uri)

  FactorInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      identity: @solution[:identity],
      sid: @solution[:sid],
  )
end

#inspectObject

Provide a detailed, user friendly representation


253
254
255
256
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 253

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

#to_sObject

Provide a user friendly representation


246
247
248
249
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 246

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Verify.V2.FactorContext #{context}>"
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:


221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 221

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)
  data = Twilio::Values.of({
      'AuthPayload' => auth_payload,
      'FriendlyName' => friendly_name,
      'Config.NotificationToken' => config_notification_token,
      'Config.SdkVersion' => config_sdk_version,
      'Config.TimeStep' => config_time_step,
      'Config.Skew' => config_skew,
      'Config.CodeLength' => config_code_length,
      'Config.Alg' => config_alg,
  })

  payload = @version.update('POST', @uri, data: data)

  FactorInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      identity: @solution[:identity],
      sid: @solution[:sid],
  )
end