Class: Twilio::REST::Proxy::V1::ServiceContext::SessionContext::ParticipantContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb,
lib/twilio-ruby/rest/proxy/v1/service/session/participant/message_interaction.rb

Defined Under Namespace

Classes: MessageInteractionContext, MessageInteractionInstance, MessageInteractionInstanceMetadata, MessageInteractionList, MessageInteractionListResponse, MessageInteractionPage, MessageInteractionPageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, session_sid, sid) ⇒ ParticipantContext

Initialize the ParticipantContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the parent [Service](www.twilio.com/docs/proxy/api/service) of the resource to fetch.

  • session_sid (String)

    The SID of the parent [Session](www.twilio.com/docs/proxy/api/session) of the resource to fetch.

  • sid (String)

    The Twilio-provided string that uniquely identifies the Participant resource to fetch.



242
243
244
245
246
247
248
249
250
251
252
# File 'lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb', line 242

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

    # Path Solution
    @solution = { service_sid: service_sid, session_sid: session_sid, sid: sid,  }
    @uri = "/Services/#{@solution[:service_sid]}/Sessions/#{@solution[:session_sid]}/Participants/#{@solution[:sid]}"

    # Dependents
    @message_interactions = nil
end

Instance Method Details

#deleteBoolean

Delete the ParticipantInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



256
257
258
259
260
261
262
263
264
# File 'lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb', line 256

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the ParticipantInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb', line 269

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      participant_instance = ParticipantInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      ParticipantInstanceMetadata.new(@version, participant_instance, response.headers, response.status_code)
end

#fetchParticipantInstance

Fetch the ParticipantInstance

Returns:



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb', line 288

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    ParticipantInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        session_sid: @solution[:session_sid],
        sid: @solution[:sid],
    )
end

#fetch_with_metadataParticipantInstance

Fetch the ParticipantInstanceMetadata

Returns:



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb', line 309

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    participant_instance = ParticipantInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        session_sid: @solution[:session_sid],
        sid: @solution[:sid],
    )
    ParticipantInstanceMetadata.new(
        @version,
        participant_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



362
363
364
365
# File 'lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb', line 362

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

#message_interactions(sid = :unset) ⇒ MessageInteractionList, MessageInteractionContext

Access the message_interactions

Returns:

Raises:

  • (ArgumentError)


337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb', line 337

def message_interactions(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

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

    unless @message_interactions
        @message_interactions = MessageInteractionList.new(
            @version, service_sid: @solution[:service_sid], session_sid: @solution[:session_sid], participant_sid: @solution[:sid], )
    end

 @message_interactions
end

#to_sObject

Provide a user friendly representation



355
356
357
358
# File 'lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb', line 355

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