Class: Twilio::REST::Chat::V1::ServiceContext::RoleContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/chat/v1/service/role.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ RoleContext

Initialize the RoleContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The service_sid

  • sid (String)

    The sid



191
192
193
194
195
196
197
198
199
200
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 191

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

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

Instance Method Details

#deleteBoolean

Deletes the RoleInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



225
226
227
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 225

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

#fetchRoleInstance

Fetch a RoleInstance

Returns:



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 205

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

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

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

#to_sObject

Provide a user friendly representation



254
255
256
257
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 254

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

#update(permission: nil) ⇒ RoleInstance

Update the RoleInstance

Parameters:

  • permission (String) (defaults to: nil)

    The permission

Returns:



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 233

def update(permission: nil)
  data = Twilio::Values.of({
      'Permission' => permission,
  })

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

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