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

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/video/v1/room/room_participant.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: PublishedTrackContext, PublishedTrackInstance, PublishedTrackList, PublishedTrackPage, SubscribeRulesInstance, SubscribeRulesList, SubscribeRulesPage, SubscribedTrackContext, SubscribedTrackInstance, SubscribedTrackList, SubscribedTrackPage

Instance Method Summary collapse

Constructor Details

#initialize(version, room_sid, sid) ⇒ ParticipantContext

Initialize the ParticipantContext

Parameters:

  • version (Version)

    Version that contains the resource

  • room_sid (String)

    The SID of the room with the Participant resource to fetch.

  • sid (String)

    The SID of the RoomParticipant resource to fetch.


199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/twilio-ruby/rest/video/v1/room/room_participant.rb', line 199

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

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

  # Dependents
  @published_tracks = nil
  @subscribed_tracks = nil
  @subscribe_rules = nil
end

Instance Method Details

#fetchParticipantInstance

Fetch the ParticipantInstance

Returns:


215
216
217
218
219
# File 'lib/twilio-ruby/rest/video/v1/room/room_participant.rb', line 215

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

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

#inspectObject

Provide a detailed, user friendly representation


305
306
307
308
# File 'lib/twilio-ruby/rest/video/v1/room/room_participant.rb', line 305

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

#published_tracks(sid = :unset) ⇒ PublishedTrackList, PublishedTrackContext

Access the published_tracks

Returns:

Raises:

  • (ArgumentError)

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

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

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

  unless @published_tracks
    @published_tracks = PublishedTrackList.new(
        @version,
        room_sid: @solution[:room_sid],
        participant_sid: @solution[:sid],
    )
  end

  @published_tracks
end

#subscribe_rulesSubscribeRulesList, SubscribeRulesContext

Access the subscribe_rules

Returns:


284
285
286
287
288
289
290
291
292
293
294
# File 'lib/twilio-ruby/rest/video/v1/room/room_participant.rb', line 284

def subscribe_rules
  unless @subscribe_rules
    @subscribe_rules = SubscribeRulesList.new(
        @version,
        room_sid: @solution[:room_sid],
        participant_sid: @solution[:sid],
    )
  end

  @subscribe_rules
end

#subscribed_tracks(sid = :unset) ⇒ SubscribedTrackList, SubscribedTrackContext

Access the subscribed_tracks

Returns:

Raises:

  • (ArgumentError)

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

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

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

  unless @subscribed_tracks
    @subscribed_tracks = SubscribedTrackList.new(
        @version,
        room_sid: @solution[:room_sid],
        participant_sid: @solution[:sid],
    )
  end

  @subscribed_tracks
end

#to_sObject

Provide a user friendly representation


298
299
300
301
# File 'lib/twilio-ruby/rest/video/v1/room/room_participant.rb', line 298

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

#update(status: :unset) ⇒ ParticipantInstance

Update the ParticipantInstance

Parameters:

  • status (participant.Status) (defaults to: :unset)

    The new status of the resource. Can be: `connected` or `disconnected`. For `in-progress` Rooms the default Status is `connected`, for `completed` Rooms only `disconnected` Participants are returned.

Returns:


228
229
230
231
232
233
234
# File 'lib/twilio-ruby/rest/video/v1/room/room_participant.rb', line 228

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

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

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