Class: Twilio::REST::Messaging::V1::SessionContext::ParticipantContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/messaging/v1/session/participant.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].

Instance Method Summary collapse

Constructor Details

#initialize(version, session_sid, sid) ⇒ ParticipantContext

Initialize the ParticipantContext

Parameters:

  • version (Version)

    Version that contains the resource

  • session_sid (String)

    The unique id of the [Session](www.twilio.com/docs/sessions/api/session) for this participant.

  • sid (String)

    A 34 character string that uniquely identifies this resource.



209
210
211
212
213
214
215
# File 'lib/twilio-ruby/rest/messaging/v1/session/participant.rb', line 209

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

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

Instance Method Details

#deleteBoolean

Deletes the ParticipantInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



272
273
274
# File 'lib/twilio-ruby/rest/messaging/v1/session/participant.rb', line 272

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

#fetchParticipantInstance

Fetch a ParticipantInstance

Returns:



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/twilio-ruby/rest/messaging/v1/session/participant.rb', line 252

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

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

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

#inspectObject

Provide a detailed, user friendly representation



285
286
287
288
# File 'lib/twilio-ruby/rest/messaging/v1/session/participant.rb', line 285

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

#to_sObject

Provide a user friendly representation



278
279
280
281
# File 'lib/twilio-ruby/rest/messaging/v1/session/participant.rb', line 278

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

#update(attributes: :unset, date_created: :unset, date_updated: :unset) ⇒ ParticipantInstance

Update the ParticipantInstance

Parameters:

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

    An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set “{}” will be returned.

  • date_created (Time) (defaults to: :unset)

    The date that this resource was created. This is useful when bulk-importing messages from another system, as the provided value will be trusted and displayed on SDK clients.

  • date_updated (Time) (defaults to: :unset)

    The date that this resource was last updated.

Returns:



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/twilio-ruby/rest/messaging/v1/session/participant.rb', line 228

def update(attributes: :unset, date_created: :unset, date_updated: :unset)
  data = Twilio::Values.of({
      'Attributes' => attributes,
      'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
      'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
  })

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

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