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

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Defined Under Namespace

Classes: ChallengeContext, ChallengeInstance, ChallengeList, ChallengePage, FactorContext, FactorInstance, FactorList, FactorPage, NewFactorInstance, NewFactorList, NewFactorPage

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


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

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

Instance Method Details

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

Access the challenges

Returns:

Raises:

  • (ArgumentError)

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

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

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


191
192
193
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 191

def delete
   @version.delete('DELETE', @uri)
end

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

Access the factors

Returns:

Raises:

  • (ArgumentError)

213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 213

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

Returns:


198
199
200
201
202
203
204
205
206
207
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 198

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

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

#inspectObject

Provide a detailed, user friendly representation


278
279
280
281
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 278

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

#new_factorsNewFactorList, NewFactorContext

Access the new_factors

Returns:


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

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


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

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