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.



498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 498

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_sid ⇒ String

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

Returns:

  • (String) —

    The unique ID of the Account responsible for this conversation.



542
543
544
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 542

def 
    @properties['account_sid']
end

#attributes ⇒ String

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.



602
603
604
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 602

def attributes
    @properties['attributes']
end

#chat_service_sid ⇒ String

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

Returns:



548
549
550
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 548

def chat_service_sid
    @properties['chat_service_sid']
end

#context ⇒ UserConversationContext

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

Returns:



533
534
535
536
537
538
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 533

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_sid ⇒ String

Returns The unique ID of the Conversation for this User Conversation.

Returns:

  • (String) —

    The unique ID of the Conversation for this User Conversation.



554
555
556
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 554

def conversation_sid
    @properties['conversation_sid']
end

#conversation_state ⇒ State

Returns:

  • (State)


590
591
592
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 590

def conversation_state
    @properties['conversation_state']
end

#created_by ⇒ String

Returns Identity of the creator of this Conversation.

Returns:

  • (String) —

    Identity of the creator of this Conversation.



620
621
622
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 620

def created_by
    @properties['created_by']
end

#date_created ⇒ Time

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.



608
609
610
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 608

def date_created
    @properties['date_created']
end

#date_updated ⇒ Time

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.



614
615
616
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 614

def date_updated
    @properties['date_updated']
end

#delete ⇒ Boolean

Delete the UserConversationInstance

Returns:

  • (Boolean) —

    True if delete succeeds, false otherwise



651
652
653
654
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 651

def delete

    context.delete
end

#fetch ⇒ UserConversationInstance

Fetch the UserConversationInstance

Returns:



659
660
661
662
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 659

def fetch

    context.fetch
end

#friendly_name ⇒ String

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.



584
585
586
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 584

def friendly_name
    @properties['friendly_name']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



692
693
694
695
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 692

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

#last_read_message_index ⇒ String

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.



566
567
568
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 566

def last_read_message_index
    @properties['last_read_message_index']
end

Returns Contains absolute URLs to access the participant and conversation of this conversation.

Returns:



644
645
646
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 644

def links
    @properties['links']
end

#notification_level ⇒ NotificationLevel

Returns:

  • (NotificationLevel)


626
627
628
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 626

def notification_level
    @properties['notification_level']
end

#participant_sid ⇒ String

Returns The unique ID of the participant the user conversation belongs to.

Returns:

  • (String) —

    The unique ID of the participant the user conversation belongs to.



572
573
574
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 572

def participant_sid
    @properties['participant_sid']
end

#timers ⇒ Hash

Returns Timer date values representing state update for this conversation.

Returns:

  • (Hash) —

    Timer date values representing state update for this conversation.



596
597
598
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 596

def timers
    @properties['timers']
end

#to_s ⇒ Object

Provide a user friendly representation



685
686
687
688
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 685

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

#unique_name ⇒ String

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.



632
633
634
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 632

def unique_name
    @properties['unique_name']
end

#unread_messages_count ⇒ String

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.



560
561
562
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 560

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:



670
671
672
673
674
675
676
677
678
679
680
681
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 670

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

#url ⇒ String

Returns:

  • (String)


638
639
640
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 638

def url
    @properties['url']
end

#user_sid ⇒ String

Returns The unique string that identifies the User resource.

Returns:

  • (String) —

    The unique string that identifies the User resource.



578
579
580
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 578

def user_sid
    @properties['user_sid']
end