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,
lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb,
lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb

Defined Under Namespace

Classes: ChallengeContext, ChallengeInstance, ChallengeInstanceMetadata, ChallengeList, ChallengeListResponse, ChallengePage, ChallengePageMetadata, FactorContext, FactorInstance, FactorInstanceMetadata, FactorList, FactorListResponse, FactorPage, FactorPageMetadata, NewFactorInstance, NewFactorList, NewFactorListResponse, NewFactorPage, NewFactorPageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, identity) ⇒ EntityContext

Initialize the EntityContext



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

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
    @new_factors = nil
    @factors = nil
    @challenges = nil
end

Instance Method Details

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

Access the challenges

Raises:

  • (ArgumentError)


345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 345

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

#deleteBoolean

Delete the EntityInstance



236
237
238
239
240
241
242
243
244
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 236

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 EntityInstanceMetadata



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 249

def 

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

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

Access the factors

Raises:

  • (ArgumentError)


326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 326

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

#fetchEntityInstance

Fetch the EntityInstance



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 268

def fetch

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

#fetch_with_metadataEntityInstance

Fetch the EntityInstanceMetadata



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 288

def 

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

#inspectObject

Provide a detailed, user friendly representation



370
371
372
373
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 370

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

#new_factorsNewFactorList, NewFactorContext

Access the new_factors



315
316
317
318
319
320
321
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 315

def new_factors
  unless @new_factors
    @new_factors = NewFactorList.new(
            @version, service_sid: @solution[:service_sid], identity: @solution[:identity], )
  end
  @new_factors
end

#to_sObject

Provide a user friendly representation



363
364
365
366
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 363

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