Class: Twilio::REST::Conversations::V1::ServiceContext::UserContext::UserConversationInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, chat_service_sid: nil, user_sid: nil, conversation_sid: nil) ⇒ UserConversationInstance

Initialize the UserConversationInstance

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 UserConversation resource.

  • sid (String)

    The SID of the Call resource to fetch.



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 251

def initialize(version, payload , chat_service_sid: nil, user_sid: nil, conversation_sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'chat_service_sid' => payload['chat_service_sid'],
        'conversation_sid' => payload['conversation_sid'],
        'unread_messages_count' => payload['unread_messages_count'] == nil ? payload['unread_messages_count'] : payload['unread_messages_count'].to_i,
        'last_read_message_index' => payload['last_read_message_index'] == nil ? payload['last_read_message_index'] : payload['last_read_message_index'].to_i,
        'participant_sid' => payload['participant_sid'],
        'user_sid' => payload['user_sid'],
        'friendly_name' => payload['friendly_name'],
        'conversation_state' => payload['conversation_state'],
        'timers' => payload['timers'],
        'attributes' => payload['attributes'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
        'created_by' => payload['created_by'],
        'notification_level' => payload['notification_level'],
        'unique_name' => payload['unique_name'],
        'url' => payload['url'],
        'links' => payload['links'],
    }

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

Instance Method Details

#account_sidString

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

Returns:



294
295
296
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 294

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.



354
355
356
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 354

def attributes
    @properties['attributes']
end

#chat_service_sidString

Returns The unique ID of the [Conversation Service](www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to.

Returns:



300
301
302
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 300

def chat_service_sid
    @properties['chat_service_sid']
end

#contextUserConversationContext

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

Returns:



285
286
287
288
289
290
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 285

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

#conversation_sidString

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

Returns:



306
307
308
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 306

def conversation_sid
    @properties['conversation_sid']
end

#conversation_stateState

Returns:

  • (State)


342
343
344
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 342

def conversation_state
    @properties['conversation_state']
end

#created_byString

Returns Identity of the creator of this Conversation.

Returns:

  • (String)

    Identity of the creator of this Conversation.



372
373
374
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 372

def created_by
    @properties['created_by']
end

#date_createdTime

Returns The date that this conversation was created, given in ISO 8601 format.

Returns:

  • (Time)

    The date that this conversation was created, given in ISO 8601 format.



360
361
362
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 360

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date that this conversation was last updated, given in ISO 8601 format.

Returns:

  • (Time)

    The date that this conversation was last updated, given in ISO 8601 format.



366
367
368
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 366

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the UserConversationInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



403
404
405
406
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 403

def delete

    context.delete
end

#fetchUserConversationInstance

Fetch the UserConversationInstance

Returns:



411
412
413
414
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 411

def fetch

    context.fetch
end

#friendly_nameString

Returns The human-readable name of this conversation, limited to 256 characters. Optional.

Returns:

  • (String)

    The human-readable name of this conversation, limited to 256 characters. Optional.



336
337
338
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 336

def friendly_name
    @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



444
445
446
447
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 444

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

#last_read_message_indexString

Returns The index of the last Message in the Conversation that the Participant has read.

Returns:

  • (String)

    The index of the last Message in the Conversation that the Participant has read.



318
319
320
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 318

def last_read_message_index
    @properties['last_read_message_index']
end

Returns Contains absolute URLs to access the [participant](www.twilio.com/docs/conversations/api/conversation-participant-resource) and [conversation](www.twilio.com/docs/conversations/api/conversation-resource) of this conversation.

Returns:



396
397
398
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 396

def links
    @properties['links']
end

#notification_levelNotificationLevel

Returns:

  • (NotificationLevel)


378
379
380
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 378

def notification_level
    @properties['notification_level']
end

#participant_sidString

Returns The unique ID of the [participant](www.twilio.com/docs/conversations/api/conversation-participant-resource) the user conversation belongs to.

Returns:



324
325
326
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 324

def participant_sid
    @properties['participant_sid']
end

#timersHash

Returns Timer date values representing state update for this conversation.

Returns:

  • (Hash)

    Timer date values representing state update for this conversation.



348
349
350
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 348

def timers
    @properties['timers']
end

#to_sObject

Provide a user friendly representation



437
438
439
440
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 437

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

#unique_nameString

Returns An application-defined string that uniquely identifies the Conversation resource. It can be used to address the resource in place of the resource’s ‘conversation_sid` in the URL.

Returns:

  • (String)

    An application-defined string that uniquely identifies the Conversation resource. It can be used to address the resource in place of the resource’s ‘conversation_sid` in the URL.



384
385
386
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 384

def unique_name
    @properties['unique_name']
end

#unread_messages_countString

Returns The number of unread Messages in the Conversation for the Participant.

Returns:

  • (String)

    The number of unread Messages in the Conversation for the Participant.



312
313
314
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 312

def unread_messages_count
    @properties['unread_messages_count']
end

#update(notification_level: :unset, last_read_timestamp: :unset, last_read_message_index: :unset) ⇒ UserConversationInstance

Update the UserConversationInstance

Parameters:

  • notification_level (NotificationLevel) (defaults to: :unset)
  • last_read_timestamp (Time) (defaults to: :unset)

    The date of the last message read in conversation by the user, given in ISO 8601 format.

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

    The index of the last Message in the Conversation that the Participant has read.

Returns:



422
423
424
425
426
427
428
429
430
431
432
433
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 422

def update(
    notification_level: :unset, 
    last_read_timestamp: :unset, 
    last_read_message_index: :unset
)

    context.update(
        notification_level: notification_level, 
        last_read_timestamp: last_read_timestamp, 
        last_read_message_index: last_read_message_index, 
    )
end

#urlString

Returns:

  • (String)


390
391
392
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 390

def url
    @properties['url']
end

#user_sidString

Returns The unique string that identifies the [User resource](www.twilio.com/docs/conversations/api/user-resource).

Returns:



330
331
332
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 330

def user_sid
    @properties['user_sid']
end