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

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 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)

    A 34 character string that uniquely identifies this Factor.



164
165
166
167
168
169
170
171
172
173
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 164

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



177
178
179
180
181
182
183
184
185
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 177

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the FactorInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 190

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      factor_instance = FactorInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      .new(@version, factor_instance, response.headers, response.status_code)
end

#fetchFactorInstance

Fetch the FactorInstance

Returns:



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 209

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    FactorInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
        sid: @solution[:sid],
    )
end

#fetch_with_metadataFactorInstance

Fetch the FactorInstanceMetadata

Returns:



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 230

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    factor_instance = FactorInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
        sid: @solution[:sid],
    )
    .new(
        @version,
        factor_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#to_sObject

Provide a user friendly representation



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

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, config_notification_platform: :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 is 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 (TotpAlgorithms) (defaults to: :unset)
  • config_notification_platform (String) (defaults to: :unset)

    The transport technology used to generate the Notification Token. Can be apn, fcm or none. Required when factor_type is push.

Returns:



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 266

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, 
    config_notification_platform: :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,
        'Config.NotificationPlatform' => config_notification_platform,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    FactorInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
        sid: @solution[:sid],
    )
end

#update_with_metadata(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, config_notification_platform: :unset) ⇒ FactorInstance

Update the FactorInstanceMetadata

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 is 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 (TotpAlgorithms) (defaults to: :unset)
  • config_notification_platform (String) (defaults to: :unset)

    The transport technology used to generate the Notification Token. Can be apn, fcm or none. Required when factor_type is push.

Returns:



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 318

def (
  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, 
  config_notification_platform: :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,
        'Config.NotificationPlatform' => config_notification_platform,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    factor_instance = FactorInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
        sid: @solution[:sid],
    )
    .new(
        @version,
        factor_instance,
        response.headers,
        response.status_code
    )
end