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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, 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

  • account_sid (String)

    The SID of the Account that created this Participant resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 316

def initialize(version, payload , conversation_sid: nil, sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_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 = { 'conversation_sid' => conversation_sid  || @properties['conversation_sid']  ,'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#account_sidString

Returns The unique ID of the [Account](www.twilio.com/docs/iam/api/account) responsible for this participant.

Returns:



353
354
355
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 353

def 
    @properties['account_sid']
end

#attributesString

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

Returns:

  • (String)

    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.



377
378
379
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 377

def attributes
    @properties['attributes']
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:



344
345
346
347
348
349
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 344

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

#conversation_sidString

Returns The unique ID of the [Conversation](www.twilio.com/docs/conversations/api/conversation-resource) for this participant.

Returns:



359
360
361
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 359

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.



395
396
397
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 395

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.



401
402
403
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 401

def date_updated
    @properties['date_updated']
end

#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the ParticipantInstance

Parameters:

  • x_twilio_webhook_enabled (ConversationParticipantEnumWebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



427
428
429
430
431
432
433
434
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 427

def delete(
    x_twilio_webhook_enabled: :unset
)

    context.delete(
        x_twilio_webhook_enabled: x_twilio_webhook_enabled, 
    )
end

#fetchParticipantInstance

Fetch the ParticipantInstance

Returns:



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

def fetch

    context.fetch
end

#identityString

Returns A unique string identifier for the conversation participant as [Conversation User](www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.

Returns:

  • (String)

    A unique string identifier for the conversation participant as [Conversation User](www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.



371
372
373
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 371

def identity
    @properties['identity']
end

#inspectObject

Provide a detailed, user friendly representation



493
494
495
496
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 493

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](www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.

Returns:



413
414
415
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 413

def last_read_message_index
    @properties['last_read_message_index']
end

#last_read_timestampString

Returns Timestamp of last “read” message in the [Conversation](www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.

Returns:



419
420
421
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 419

def last_read_timestamp
    @properties['last_read_timestamp']
end

#messaging_bindingHash

Returns Information about how this participant exchanges messages with the conversation. A JSON parameter consisting of type and address fields of the participant.

Returns:

  • (Hash)

    Information about how this participant exchanges messages with the conversation. A JSON parameter consisting of type and address fields of the participant.



383
384
385
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 383

def messaging_binding
    @properties['messaging_binding']
end

#role_sidString

Returns The SID of a conversation-level [Role](www.twilio.com/docs/conversations/api/role-resource) to assign to the participant.

Returns:



389
390
391
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 389

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.



365
366
367
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 365

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



486
487
488
489
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 486

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

#update(date_created: :unset, date_updated: :unset, attributes: :unset, role_sid: :unset, messaging_binding_proxy_address: :unset, messaging_binding_projected_address: :unset, identity: :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.

  • 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](www.twilio.com/docs/conversations/api/role-resource) 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.

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

    A unique string identifier for the conversation participant as [Conversation User](www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.

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

    Index of last “read” message in the [Conversation](www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.

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

    Timestamp of last “read” message in the [Conversation](www.twilio.com/docs/conversations/api/conversation-resource) for the Participant.

  • x_twilio_webhook_enabled (ConversationParticipantEnumWebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:



457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 457

def update(
    date_created: :unset, 
    date_updated: :unset, 
    attributes: :unset, 
    role_sid: :unset, 
    messaging_binding_proxy_address: :unset, 
    messaging_binding_projected_address: :unset, 
    identity: :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, 
        attributes: attributes, 
        role_sid: role_sid, 
        messaging_binding_proxy_address: messaging_binding_proxy_address, 
        messaging_binding_projected_address: messaging_binding_projected_address, 
        identity: identity, 
        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 API resource URL for this participant.

Returns:

  • (String)

    An absolute API resource URL for this participant.



407
408
409
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 407

def url
    @properties['url']
end