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

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

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Defined Under Namespace

Classes: MessageInteractionContext, MessageInteractionInstance, MessageInteractionList, MessageInteractionPage

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 unique SID identifier of the Service.

  • session_sid (String)

    The unique SID identifier of the Session.

  • sid (String)

    A 34 character string that uniquely identifies this Participant.



225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb', line 225

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

Deletes the ParticipantInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



264
265
266
# File 'lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb', line 264

def delete
  @version.delete('delete', @uri)
end

#fetchParticipantInstance

Fetch a ParticipantInstance

Returns:



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb', line 243

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

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

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

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

Access the message_interactions

Returns:

Raises:

  • (ArgumentError)


303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb', line 303

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



330
331
332
333
# File 'lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb', line 330

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

#update(participant_type: :unset, identifier: :unset, friendly_name: :unset) ⇒ ParticipantInstance

Update the ParticipantInstance

Parameters:

  • participant_type (participant.ParticipantType) (defaults to: :unset)

    The Type of this Participant. One of ‘sms`, `voice` or `phone`.

  • identifier (String) (defaults to: :unset)

    The Participant’s contact identifier, normally a phone number.

  • friendly_name (String) (defaults to: :unset)

    A human readable description of this resource, up to 64 characters.

Returns:



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb', line 277

def update(participant_type: :unset, identifier: :unset, friendly_name: :unset)
  data = Twilio::Values.of({
      'ParticipantType' => participant_type,
      'Identifier' => identifier,
      'FriendlyName' => friendly_name,
  })

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

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