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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, chat_service_sid, user_sid, conversation_sid) ⇒ UserConversationContext

Initialize the UserConversationContext

Parameters:

  • version (Version)

    Version that contains the resource

  • chat_service_sid (String)

    The SID of the Conversation Service the Conversation resource is associated with.

  • user_sid (String)

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

  • conversation_sid (String)

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


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

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

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

Instance Method Details

#deleteBoolean

Delete the UserConversationInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


210
211
212
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 210

def delete
   @version.delete('DELETE', @uri)
end

#fetchUserConversationInstance

Fetch the UserConversationInstance

Returns:


217
218
219
220
221
222
223
224
225
226
227
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 217

def fetch
  payload = @version.fetch('GET', @uri)

  UserConversationInstance.new(
      @version,
      payload,
      chat_service_sid: @solution[:chat_service_sid],
      user_sid: @solution[:user_sid],
      conversation_sid: @solution[:conversation_sid],
  )
end

#inspectObject

Provide a detailed, user friendly representation


238
239
240
241
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 238

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

#to_sObject

Provide a user friendly representation


231
232
233
234
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 231

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


189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb', line 189

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,
  })

  payload = @version.update('POST', @uri, data: data)

  UserConversationInstance.new(
      @version,
      payload,
      chat_service_sid: @solution[:chat_service_sid],
      user_sid: @solution[:user_sid],
      conversation_sid: @solution[:conversation_sid],
  )
end