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.


240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 240

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:


256
257
258
259
260
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 256

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

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

#inspectObject

Provide a detailed, user friendly representation


332
333
334
335
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 332

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)

297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 297

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:


315
316
317
318
319
320
321
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 315

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)

279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 279

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


325
326
327
328
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 325

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:


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

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