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/access_token.rb,
lib/twilio-ruby/rest/verify/v2/service/entity/factor/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: AccessTokenInstance, AccessTokenList, AccessTokenPage, 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)

    Customer unique identity for the Entity of the Service



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

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

Instance Method Details

#access_tokensAccessTokenList, AccessTokenContext

Access the access_tokens

Returns:



241
242
243
244
245
246
247
248
249
250
251
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 241

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

  @access_tokens
end

#deleteBoolean

Deletes 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)


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

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 a EntityInstance

Returns:



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

def fetch
  params = Twilio::Values.of({})

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

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

#inspectObject

Provide a detailed, user friendly representation



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

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

#to_sObject

Provide a user friendly representation



255
256
257
258
# File 'lib/twilio-ruby/rest/verify/v2/service/entity.rb', line 255

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