Class: Twilio::REST::Video::V1::RoomContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/video/v1/room.rb,
lib/twilio-ruby/rest/video/v1/room/recording.rb,
lib/twilio-ruby/rest/video/v1/room/room_participant.rb,
lib/twilio-ruby/rest/video/v1/room/room_recording_rule.rb,
lib/twilio-ruby/rest/video/v1/room/room_participant/room_participant_subscribe_rule.rb,
lib/twilio-ruby/rest/video/v1/room/room_participant/room_participant_published_track.rb,
lib/twilio-ruby/rest/video/v1/room/room_participant/room_participant_subscribed_track.rb

Defined Under Namespace

Classes: ParticipantContext, ParticipantInstance, ParticipantList, ParticipantPage, RecordingRulesInstance, RecordingRulesList, RecordingRulesPage, RoomRecordingContext, RoomRecordingInstance, RoomRecordingList, RoomRecordingPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ RoomContext

Initialize the RoomContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The SID of the Room resource to fetch.


262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 262

def initialize(version, sid)
  super(version)

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

  # Dependents
  @recordings = nil
  @participants = nil
  @recording_rules = nil
end

Instance Method Details

#fetchRoomInstance

Fetch the RoomInstance

Returns:


278
279
280
281
282
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 278

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

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

#inspectObject

Provide a detailed, user friendly representation


354
355
356
357
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 354

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

#participants(sid = :unset) ⇒ ParticipantList, ParticipantContext

Access the participants

Returns:

Raises:

  • (ArgumentError)

319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 319

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

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

  unless @participants
    @participants = ParticipantList.new(@version, room_sid: @solution[:sid], )
  end

  @participants
end

#recording_rulesRecordingRulesList, RecordingRulesContext

Access the recording_rules

Returns:


337
338
339
340
341
342
343
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 337

def recording_rules
  unless @recording_rules
    @recording_rules = RecordingRulesList.new(@version, room_sid: @solution[:sid], )
  end

  @recording_rules
end

#recordings(sid = :unset) ⇒ RoomRecordingList, RoomRecordingContext

Access the recordings

Returns:

Raises:

  • (ArgumentError)

301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 301

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

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

  unless @recordings
    @recordings = RoomRecordingList.new(@version, room_sid: @solution[:sid], )
  end

  @recordings
end

#to_sObject

Provide a user friendly representation


347
348
349
350
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 347

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

#update(status: nil) ⇒ RoomInstance

Update the RoomInstance

Parameters:

  • status (room.RoomStatus) (defaults to: nil)

    The new status of the resource. Set to `completed` to end the room.

Returns:


289
290
291
292
293
294
295
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 289

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

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

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