Class: Twilio::REST::Conversations::V1::UserContext::UserConversationContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version, user_sid, conversation_sid) ⇒ UserConversationContext

Initialize the UserConversationContext

Parameters:



139
140
141
142
143
144
145
146
147
# File 'lib/twilio-ruby/rest/conversations/v1/user/user_conversation.rb', line 139

def initialize(version, user_sid, conversation_sid)
    super(version)

    # Path Solution
    @solution = { user_sid: user_sid, conversation_sid: conversation_sid,  }
    @uri = "/Users/#{@solution[:user_sid]}/Conversations/#{@solution[:conversation_sid]}"

    
end

Instance Method Details

#deleteBoolean

Delete the UserConversationInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



151
152
153
154
155
156
157
158
# File 'lib/twilio-ruby/rest/conversations/v1/user/user_conversation.rb', line 151

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

#fetchUserConversationInstance

Fetch the UserConversationInstance

Returns:



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/twilio-ruby/rest/conversations/v1/user/user_conversation.rb', line 163

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    UserConversationInstance.new(
        @version,
        payload,
        user_sid: @solution[:user_sid],
        conversation_sid: @solution[:conversation_sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



223
224
225
226
# File 'lib/twilio-ruby/rest/conversations/v1/user/user_conversation.rb', line 223

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Conversations.V1.UserConversationContext #{context}>"
end

#to_sObject

Provide a user friendly representation



216
217
218
219
# File 'lib/twilio-ruby/rest/conversations/v1/user/user_conversation.rb', line 216

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Conversations.V1.UserConversationContext #{context}>"
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:



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/twilio-ruby/rest/conversations/v1/user/user_conversation.rb', line 186

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

    data = Twilio::Values.of({
        'NotificationLevel' => notification_level,
        'LastReadTimestamp' => Twilio.serialize_iso8601_datetime(last_read_timestamp),
        'LastReadMessageIndex' => last_read_message_index,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    UserConversationInstance.new(
        @version,
        payload,
        user_sid: @solution[:user_sid],
        conversation_sid: @solution[:conversation_sid],
    )
end