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

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/verify/v2/service/entity/challenge.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) ⇒ ChallengeContext

Initialize the ChallengeContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The unique SID identifier of the Service.

  • identity (String)

    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)

    A 34 character string that uniquely identifies this Challenge.



233
234
235
236
237
238
239
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 233

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

Instance Method Details

#fetch(twilio_sandbox_mode: :unset) ⇒ ChallengeInstance

Fetch the ChallengeInstance

Parameters:

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

    The Twilio-Sandbox-Mode HTTP request header

Returns:



245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 245

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

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

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

#inspectObject

Provide a detailed, user friendly representation



289
290
291
292
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 289

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

#to_sObject

Provide a user friendly representation



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

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

#update(auth_payload: :unset, twilio_sandbox_mode: :unset) ⇒ ChallengeInstance

Update the ChallengeInstance

Parameters:

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

    The optional payload needed to verify the Challenge. E.g., a TOTP would use the numeric code.

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

    The Twilio-Sandbox-Mode HTTP request header

Returns:



265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb', line 265

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

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

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