class Twilio::REST::Chat::V2::ServiceContext::UserContext::UserChannelInstance

Public Class Methods

new(version, payload, service_sid: nil, user_sid: nil, channel_sid: nil) click to toggle source

Initialize the UserChannelInstance @param [Version] version Version that contains the resource @param [Hash] payload payload that contains response from Twilio @param [String] service_sid The SID of the

{Service}[https://www.twilio.com/docs/chat/rest/service-resource] the User
Channel resource is associated with.

@param [String] user_sid The SID of the

{User}[https://www.twilio.com/docs/chat/rest/user-resource] the User Channel
belongs to.

@param [String] channel_sid The SID of the

{Channel}[https://www.twilio.com/docs/chat/channels] that has the User Channel
to fetch. This value can be either the `sid` or the `unique_name` of the Channel
to fetch.

@return [UserChannelInstance] UserChannelInstance

Calls superclass method Twilio::REST::InstanceResource::new
    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
262 def initialize(version, payload, service_sid: nil, user_sid: nil, channel_sid: nil)
263   super(version)
264 
265   # Marshaled Properties
266   @properties = {
267       'account_sid' => payload['account_sid'],
268       'service_sid' => payload['service_sid'],
269       'channel_sid' => payload['channel_sid'],
270       'user_sid' => payload['user_sid'],
271       'member_sid' => payload['member_sid'],
272       'status' => payload['status'],
273       'last_consumed_message_index' => payload['last_consumed_message_index'] == nil ? payload['last_consumed_message_index'] : payload['last_consumed_message_index'].to_i,
274       'unread_messages_count' => payload['unread_messages_count'] == nil ? payload['unread_messages_count'] : payload['unread_messages_count'].to_i,
275       'links' => payload['links'],
276       'url' => payload['url'],
277       'notification_level' => payload['notification_level'],
278   }
279 
280   # Context
281   @instance_context = nil
282   @params = {
283       'service_sid' => service_sid,
284       'user_sid' => user_sid,
285       'channel_sid' => channel_sid || @properties['channel_sid'],
286   }
287 end

Public Instance Methods

account_sid() click to toggle source

@return [String] The SID of the Account that created the resource

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
307 def account_sid
308   @properties['account_sid']
309 end
channel_sid() click to toggle source

@return [String] The SID of the Channel the resource belongs to

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
319 def channel_sid
320   @properties['channel_sid']
321 end
context() click to toggle source

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context @return [UserChannelContext] UserChannelContext for this UserChannelInstance

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
293 def context
294   unless @instance_context
295     @instance_context = UserChannelContext.new(
296         @version,
297         @params['service_sid'],
298         @params['user_sid'],
299         @params['channel_sid'],
300     )
301   end
302   @instance_context
303 end
delete() click to toggle source

Delete the UserChannelInstance @return [Boolean] true if delete succeeds, false otherwise

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
381 def delete
382   context.delete
383 end
fetch() click to toggle source

Fetch the UserChannelInstance @return [UserChannelInstance] Fetched UserChannelInstance

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
374 def fetch
375   context.fetch
376 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
414 def inspect
415   values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
416   "<Twilio.Chat.V2.UserChannelInstance #{values}>"
417 end
last_consumed_message_index() click to toggle source

@return [String] The index of the last Message in the Channel the Member has read

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
343 def last_consumed_message_index
344   @properties['last_consumed_message_index']
345 end
member_sid() click to toggle source

@return [String] The SID of the User as a Member in the Channel

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
331 def member_sid
332   @properties['member_sid']
333 end
notification_level() click to toggle source

@return [user_channel.NotificationLevel] The push notification level of the User for the Channel

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
367 def notification_level
368   @properties['notification_level']
369 end
service_sid() click to toggle source

@return [String] The SID of the Service that the resource is associated with

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
313 def service_sid
314   @properties['service_sid']
315 end
status() click to toggle source

@return [user_channel.ChannelStatus] The status of the User on the Channel

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
337 def status
338   @properties['status']
339 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
407 def to_s
408   values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
409   "<Twilio.Chat.V2.UserChannelInstance #{values}>"
410 end
unread_messages_count() click to toggle source

@return [String] The number of unread Messages in the Channel for the User

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
349 def unread_messages_count
350   @properties['unread_messages_count']
351 end
update(notification_level: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset) click to toggle source

Update the UserChannelInstance @param [user_channel.NotificationLevel] notification_level The push notification

level to assign to the User Channel. Can be: `default` or `muted`.

@param [String] last_consumed_message_index The index of the last

{Message}[https://www.twilio.com/docs/chat/rest/message-resource] in the
{Channel}[https://www.twilio.com/docs/chat/channels] that the Member has read.

@param [Time] last_consumption_timestamp The {ISO

8601}[https://en.wikipedia.org/wiki/ISO_8601] timestamp of the last
{Message}[https://www.twilio.com/docs/chat/rest/message-resource] read event for
the Member within the {Channel}[https://www.twilio.com/docs/chat/channels].

@return [UserChannelInstance] Updated UserChannelInstance

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
397 def update(notification_level: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset)
398   context.update(
399       notification_level: notification_level,
400       last_consumed_message_index: last_consumed_message_index,
401       last_consumption_timestamp: last_consumption_timestamp,
402   )
403 end
url() click to toggle source

@return [String] The absolute URL of the resource

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
361 def url
362   @properties['url']
363 end
user_sid() click to toggle source

@return [String] The SID of the User the User Channel belongs to

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
325 def user_sid
326   @properties['user_sid']
327 end