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

  • sid (String)

    A 34 character string that uniquely identifies this Factor.



209
210
211
212
213
214
215
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 209

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

#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



221
222
223
224
225
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 221

def delete(twilio_sandbox_mode: :unset)
  headers = Twilio::Values.of({'Twilio-Sandbox-Mode' => twilio_sandbox_mode, })

   @version.delete('DELETE', @uri, headers: headers)
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:



231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 231

def fetch(twilio_sandbox_mode: :unset)
  headers = Twilio::Values.of({'Twilio-Sandbox-Mode' => twilio_sandbox_mode, })

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

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

#inspectObject

Provide a detailed, user friendly representation



282
283
284
285
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 282

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

#to_sObject

Provide a user friendly representation



275
276
277
278
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 275

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



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb', line 254

def update(auth_payload: :unset, friendly_name: :unset, config: :unset, twilio_sandbox_mode: :unset)
  data = Twilio::Values.of({
      'AuthPayload' => auth_payload,
      'FriendlyName' => friendly_name,
      'Config' => config,
  })
  headers = Twilio::Values.of({'Twilio-Sandbox-Mode' => twilio_sandbox_mode, })

  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