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)

    A system-generated 34-character string that uniquely identifies a Room.

  • sid (String)

    A system-generated 34-character string that uniquely identifies this Participant.



206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/twilio-ruby/rest/video/v1/room/room_participant.rb', line 206

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 a ParticipantInstance

Returns:



222
223
224
225
226
227
228
229
230
231
232
# File 'lib/twilio-ruby/rest/video/v1/room/room_participant.rb', line 222

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

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

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

#inspectObject

Provide a detailed, user friendly representation



319
320
321
322
# File 'lib/twilio-ruby/rest/video/v1/room/room_participant.rb', line 319

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)


254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/twilio-ruby/rest/video/v1/room/room_participant.rb', line 254

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:



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

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)


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

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



312
313
314
315
# File 'lib/twilio-ruby/rest/video/v1/room/room_participant.rb', line 312

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)

    Set to ‘disconnected` to remove participant.

Returns:



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

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