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

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/verify/v2/service/entity.rb,
lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb,
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].

Defined Under Namespace

Classes: ChallengeContext, ChallengeInstance, ChallengeList, ChallengePage, FactorContext, FactorInstance, FactorList, FactorPage

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, identity) ⇒ EntityContext

Initialize the EntityContext

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



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

def initialize(version, service_sid, identity)
  super(version)

  # Path Solution
  @solution = {service_sid: service_sid, identity: identity, }
  @uri = "/Services/#{@solution[:service_sid]}/Entities/#{@solution[:identity]}"

  # Dependents
  @factors = nil
  @challenges = nil
end

Instance Method Details

#challenges(sid = :unset) ⇒ ChallengeList, ChallengeContext

Access the challenges

Returns:

Raises:

  • (ArgumentError)


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

def challenges(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return ChallengeContext.new(@version, @solution[:service_sid], @solution[:identity], sid, )
  end

  unless @challenges
    @challenges = ChallengeList.new(
        @version,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
    )
  end

  @challenges
end

#delete(twilio_sandbox_mode: :unset) ⇒ Boolean

Delete the EntityInstance

Parameters:

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

    The Twilio-Sandbox-Mode HTTP request header

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



193
194
195
196
197
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 193

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

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

#factors(sid = :unset) ⇒ FactorList, FactorContext

Access the factors

Returns:

Raises:

  • (ArgumentError)


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

def factors(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return FactorContext.new(@version, @solution[:service_sid], @solution[:identity], sid, )
  end

  unless @factors
    @factors = FactorList.new(
        @version,
        service_sid: @solution[:service_sid],
        identity: @solution[:identity],
    )
  end

  @factors
end

#fetch(twilio_sandbox_mode: :unset) ⇒ EntityInstance

Fetch the EntityInstance

Parameters:

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

    The Twilio-Sandbox-Mode HTTP request header

Returns:



203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 203

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

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

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

#inspectObject

Provide a detailed, user friendly representation



269
270
271
272
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 269

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

#to_sObject

Provide a user friendly representation



262
263
264
265
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 262

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