Class: Twilio::REST::Authy::V1::ServiceContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/authy/v1/service.rb,
lib/twilio-ruby/rest/authy/v1/service/entity.rb,
lib/twilio-ruby/rest/authy/v1/service/entity/factor.rb,
lib/twilio-ruby/rest/authy/v1/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: EntityContext, EntityInstance, EntityList, EntityPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ServiceContext

Initialize the ServiceContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    A 34 character string that uniquely identifies this Service.



174
175
176
177
178
179
180
181
182
183
# File 'lib/twilio-ruby/rest/authy/v1/service.rb', line 174

def initialize(version, sid)
  super(version)

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

  # Dependents
  @entities = nil
end

Instance Method Details

#deleteBoolean

Deletes the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



188
189
190
# File 'lib/twilio-ruby/rest/authy/v1/service.rb', line 188

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

#entities(identity = :unset) ⇒ EntityList, EntityContext

Access the entities

Returns:

Raises:

  • (ArgumentError)


228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/twilio-ruby/rest/authy/v1/service.rb', line 228

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

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

  unless @entities
    @entities = EntityList.new(@version, service_sid: @solution[:sid], )
  end

  @entities
end

#fetchServiceInstance

Fetch a ServiceInstance

Returns:



195
196
197
198
199
200
201
202
203
204
205
# File 'lib/twilio-ruby/rest/authy/v1/service.rb', line 195

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

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

  ServiceInstance.new(@version, payload, sid: @solution[:sid], )
end

#to_sObject

Provide a user friendly representation



244
245
246
247
# File 'lib/twilio-ruby/rest/authy/v1/service.rb', line 244

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

#update(friendly_name: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

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

    A human readable description of this resource, up to 64 characters.

Returns:



212
213
214
215
216
217
218
219
220
221
222
# File 'lib/twilio-ruby/rest/authy/v1/service.rb', line 212

def update(friendly_name: :unset)
  data = Twilio::Values.of({'FriendlyName' => friendly_name, })

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

  ServiceInstance.new(@version, payload, sid: @solution[:sid], )
end