Class: Twilio::REST::Conversations::V1::ServiceContext::ConversationContext::ParticipantContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, chat_service_sid, conversation_sid, sid) ⇒ ParticipantContext

Initialize the ParticipantContext

Parameters:

  • version (Version)

    Version that contains the resource

  • chat_service_sid (String)

    The SID of the Conversation Service the Participant resource is associated with.

  • conversation_sid (String)

    The unique ID of the Conversation for this participant.

  • sid (String)

    A 34 character string that uniquely identifies this resource.



222
223
224
225
226
227
228
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 222

def initialize(version, chat_service_sid, conversation_sid, sid)
  super(version)

  # Path Solution
  @solution = {chat_service_sid: chat_service_sid, conversation_sid: conversation_sid, sid: sid, }
  @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Participants/#{@solution[:sid]}"
end

Instance Method Details

#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the ParticipantInstance

Parameters:

  • x_twilio_webhook_enabled (participant.WebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



281
282
283
284
285
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 281

def delete(x_twilio_webhook_enabled: :unset)
  headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

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

#fetchParticipantInstance

Fetch the ParticipantInstance

Returns:



290
291
292
293
294
295
296
297
298
299
300
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 290

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

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

#inspectObject

Provide a detailed, user friendly representation



311
312
313
314
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 311

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

#to_sObject

Provide a user friendly representation



304
305
306
307
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 304

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

#update(date_created: :unset, date_updated: :unset, identity: :unset, attributes: :unset, role_sid: :unset, messaging_binding_proxy_address: :unset, messaging_binding_projected_address: :unset, x_twilio_webhook_enabled: :unset) ⇒ ParticipantInstance

Update the ParticipantInstance

Parameters:

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

    The date that this resource was created.

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

    The date that this resource was last updated.

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

    A unique string identifier for the conversation participant as Conversation User. This parameter is non-null if (and only if) the participant is using the Conversation SDK to communicate. Limited to 256 characters.

  • 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.

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

    The SID of a conversation-level Role to assign to the participant.

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

    The address of the Twilio phone number that the participant is in contact with. ‘null’ value will remove it.

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

    The address of the Twilio phone number that is used in Group MMS. ‘null’ value will remove it.

  • x_twilio_webhook_enabled (participant.WebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 253

def update(date_created: :unset, date_updated: :unset, identity: :unset, attributes: :unset, role_sid: :unset, messaging_binding_proxy_address: :unset, messaging_binding_projected_address: :unset, x_twilio_webhook_enabled: :unset)
  data = Twilio::Values.of({
      'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
      'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
      'Identity' => identity,
      'Attributes' => attributes,
      'RoleSid' => role_sid,
      'MessagingBinding.ProxyAddress' => messaging_binding_proxy_address,
      'MessagingBinding.ProjectedAddress' => messaging_binding_projected_address,
  })
  headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

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

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