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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, chat_service_sid: nil, conversation_sid: nil, sid: nil) ⇒ ParticipantInstance

Initialize the ParticipantInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • chat_service_sid (String) (defaults to: nil)

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

  • conversation_sid (String) (defaults to: nil)

    The unique ID of the Conversation for this participant.

  • sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this resource.


339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 339

def initialize(version, payload, chat_service_sid: nil, conversation_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'chat_service_sid' => payload['chat_service_sid'],
      'conversation_sid' => payload['conversation_sid'],
      'sid' => payload['sid'],
      'identity' => payload['identity'],
      'attributes' => payload['attributes'],
      'messaging_binding' => payload['messaging_binding'],
      'role_sid' => payload['role_sid'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
      'last_read_message_index' => payload['last_read_message_index'] == nil ? payload['last_read_message_index'] : payload['last_read_message_index'].to_i,
      'last_read_timestamp' => payload['last_read_timestamp'],
  }

  # Context
  @instance_context = nil
  @params = {
      'chat_service_sid' => chat_service_sid,
      'conversation_sid' => conversation_sid,
      'sid' => sid || @properties['sid'],
  }
end

Instance Method Details

#account_sidString

Returns The unique ID of the Account responsible for this participant.

Returns:

  • (String)

    The unique ID of the Account responsible for this participant.


386
387
388
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 386

def 
  @properties['account_sid']
end

#attributesString

Returns An optional string metadata field you can use to store any data you wish.

Returns:

  • (String)

    An optional string metadata field you can use to store any data you wish.


416
417
418
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 416

def attributes
  @properties['attributes']
end

#chat_service_sidString

Returns The SID of the Conversation Service that the resource is associated with.

Returns:

  • (String)

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


392
393
394
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 392

def chat_service_sid
  @properties['chat_service_sid']
end

#contextParticipantContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:


372
373
374
375
376
377
378
379
380
381
382
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 372

def context
  unless @instance_context
    @instance_context = ParticipantContext.new(
        @version,
        @params['chat_service_sid'],
        @params['conversation_sid'],
        @params['sid'],
    )
  end
  @instance_context
end

#conversation_sidString

Returns The unique ID of the Conversation for this participant.

Returns:

  • (String)

    The unique ID of the Conversation for this participant.


398
399
400
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 398

def conversation_sid
  @properties['conversation_sid']
end

#date_createdTime

Returns The date that this resource was created.

Returns:

  • (Time)

    The date that this resource was created.


434
435
436
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 434

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date that this resource was last updated.

Returns:

  • (Time)

    The date that this resource was last updated.


440
441
442
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 440

def date_updated
  @properties['date_updated']
end

#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


511
512
513
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 511

def delete(x_twilio_webhook_enabled: :unset)
  context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, )
end

#fetchParticipantInstance

Fetch the ParticipantInstance

Returns:


518
519
520
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 518

def fetch
  context.fetch
end

#identityString

Returns A unique string identifier for the conversation participant as Conversation User.

Returns:

  • (String)

    A unique string identifier for the conversation participant as Conversation User.


410
411
412
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 410

def identity
  @properties['identity']
end

#inspectObject

Provide a detailed, user friendly representation


531
532
533
534
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 531

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Conversations.V1.ParticipantInstance #{values}>"
end

#last_read_message_indexString

Returns Index of last “read” message in the Conversation for the Participant.

Returns:

  • (String)

    Index of last “read” message in the Conversation for the Participant.


452
453
454
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 452

def last_read_message_index
  @properties['last_read_message_index']
end

#last_read_timestampString

Returns Timestamp of last “read” message in the Conversation for the Participant.

Returns:

  • (String)

    Timestamp of last “read” message in the Conversation for the Participant.


458
459
460
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 458

def last_read_timestamp
  @properties['last_read_timestamp']
end

#messaging_bindingHash

Returns Information about how this participant exchanges messages with the conversation.

Returns:

  • (Hash)

    Information about how this participant exchanges messages with the conversation.


422
423
424
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 422

def messaging_binding
  @properties['messaging_binding']
end

#role_sidString

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

Returns:

  • (String)

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


428
429
430
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 428

def role_sid
  @properties['role_sid']
end

#sidString

Returns A 34 character string that uniquely identifies this resource.

Returns:

  • (String)

    A 34 character string that uniquely identifies this resource.


404
405
406
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 404

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation


524
525
526
527
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 524

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Conversations.V1.ParticipantInstance #{values}>"
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, last_read_message_index: :unset, last_read_timestamp: :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.

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

    Index of last “read” message in the Conversation for the Participant.

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

    Timestamp of last “read” message in the Conversation for the Participant.

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

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:


491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 491

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, last_read_message_index: :unset, last_read_timestamp: :unset, x_twilio_webhook_enabled: :unset)
  context.update(
      date_created: date_created,
      date_updated: date_updated,
      identity: identity,
      attributes: attributes,
      role_sid: role_sid,
      messaging_binding_proxy_address: messaging_binding_proxy_address,
      messaging_binding_projected_address: messaging_binding_projected_address,
      last_read_message_index: last_read_message_index,
      last_read_timestamp: last_read_timestamp,
      x_twilio_webhook_enabled: x_twilio_webhook_enabled,
  )
end

#urlString

Returns An absolute URL for this participant.

Returns:

  • (String)

    An absolute URL for this participant.


446
447
448
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb', line 446

def url
  @properties['url']
end