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

  • chat_service_sid (String) (defaults to: nil)

    The unique ID of the Conversation Service this conversation belongs to.

  • user_sid (String) (defaults to: nil)

    The unique string that identifies the User resource.

  • conversation_sid (String) (defaults to: nil)

    The unique SID identifier of the Conversation. This value can be either the `sid` or the `unique_name` of the Conversation resource.


258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 258

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,
      'user_sid' => user_sid,
      'conversation_sid' => conversation_sid || @properties['conversation_sid'],
  }
end

Instance Method Details

#account_sidString

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

Returns:

  • (String)

    The unique ID of the Account responsible for this conversation.


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

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.


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

def attributes
  @properties['attributes']
end

#chat_service_sidString

Returns The unique ID of the Conversation Service this conversation belongs to.

Returns:

  • (String)

    The unique ID of the Conversation Service this conversation belongs to.


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

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:


296
297
298
299
300
301
302
303
304
305
306
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 296

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 for this User Conversation.

Returns:

  • (String)

    The unique ID of the Conversation for this User Conversation.


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

def conversation_sid
  @properties['conversation_sid']
end

#conversation_stateuser_conversation.State

Returns The current state of this User Conversation.

Returns:

  • (user_conversation.State)

    The current state of this User Conversation


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

def conversation_state
  @properties['conversation_state']
end

#created_byString

Returns Creator of this conversation.

Returns:

  • (String)

    Creator of this conversation.


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

def created_by
  @properties['created_by']
end

#date_createdTime

Returns The date that this conversation was created.

Returns:

  • (Time)

    The date that this conversation was created.


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

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date that this conversation was last updated.

Returns:

  • (Time)

    The date that this conversation was last updated.


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

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Delete the UserConversationInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


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

def delete
  context.delete
end

#fetchUserConversationInstance

Fetch the UserConversationInstance

Returns:


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

def fetch
  context.fetch
end

#friendly_nameString

Returns The human-readable name of this conversation.

Returns:

  • (String)

    The human-readable name of this conversation.


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

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation


456
457
458
459
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 456

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 read Message .

Returns:

  • (String)

    The index of the last read Message .


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

def last_read_message_index
  @properties['last_read_message_index']
end

Returns Absolute URLs to access the participant and conversation of this user conversation.

Returns:

  • (String)

    Absolute URLs to access the participant and conversation of this user conversation.


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

def links
  @properties['links']
end

#notification_leveluser_conversation.NotificationLevel

Returns The Notification Level of this User Conversation.

Returns:

  • (user_conversation.NotificationLevel)

    The Notification Level of this User Conversation.


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

def notification_level
  @properties['notification_level']
end

#participant_sidString

Returns Participant Sid.

Returns:

  • (String)

    Participant Sid.


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

def participant_sid
  @properties['participant_sid']
end

#timersHash

Returns Timer date values for this conversation.

Returns:

  • (Hash)

    Timer date values for this conversation.


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

def timers
  @properties['timers']
end

#to_sObject

Provide a user friendly representation


449
450
451
452
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 449

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.

Returns:

  • (String)

    An application-defined string that uniquely identifies the Conversation resource.


400
401
402
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 400

def unique_name
  @properties['unique_name']
end

#unread_messages_countString

Returns The number of unread Messages in the Conversation.

Returns:

  • (String)

    The number of unread Messages in the Conversation.


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

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 (user_conversation.NotificationLevel) (defaults to: :unset)

    The Notification Level of this User Conversation. One of `default` or `muted`.

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


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

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 The url.

Returns:

  • (String)

    The url


406
407
408
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 406

def url
  @properties['url']
end

#user_sidString

Returns The unique ID for the User.

Returns:

  • (String)

    The unique ID for the User.


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

def user_sid
  @properties['user_sid']
end