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

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, user_sid: nil, channel_sid: nil) ⇒ UserChannelInstance

Initialize the UserChannelInstance

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 UserChannel resource.

  • sid (String)

    The SID of the Call resource to fetch.



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 255

def initialize(version, payload , service_sid: nil, user_sid: nil, channel_sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'service_sid' => payload['service_sid'],
        'channel_sid' => payload['channel_sid'],
        'user_sid' => payload['user_sid'],
        'member_sid' => payload['member_sid'],
        'status' => payload['status'],
        'last_consumed_message_index' => payload['last_consumed_message_index'] == nil ? payload['last_consumed_message_index'] : payload['last_consumed_message_index'].to_i,
        'unread_messages_count' => payload['unread_messages_count'] == nil ? payload['unread_messages_count'] : payload['unread_messages_count'].to_i,
        'links' => payload['links'],
        'url' => payload['url'],
        'notification_level' => payload['notification_level'],
    }

    # Context
    @instance_context = nil
    @params = { 'service_sid' => service_sid  || @properties['service_sid']  ,'user_sid' => user_sid  || @properties['user_sid']  ,'channel_sid' => channel_sid  || @properties['channel_sid']  , }
end

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the User Channel resource.

Returns:



291
292
293
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 291

def 
    @properties['account_sid']
end

#channel_sidString

Returns The SID of the [Channel](www.twilio.com/docs/chat/channels) the User Channel resource belongs to.

Returns:



303
304
305
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 303

def channel_sid
    @properties['channel_sid']
end

#contextUserChannelContext

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

Returns:



282
283
284
285
286
287
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 282

def context
    unless @instance_context
        @instance_context = UserChannelContext.new(@version , @params['service_sid'], @params['user_sid'], @params['channel_sid'])
    end
    @instance_context
end

#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the UserChannelInstance

Parameters:

  • x_twilio_webhook_enabled (UserChannelEnumWebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



359
360
361
362
363
364
365
366
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 359

def delete(
    x_twilio_webhook_enabled: :unset
)

    context.delete(
        x_twilio_webhook_enabled: x_twilio_webhook_enabled, 
    )
end

#fetchUserChannelInstance

Fetch the UserChannelInstance

Returns:



371
372
373
374
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 371

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



404
405
406
407
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 404

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

#last_consumed_message_indexString

Returns The index of the last [Message](www.twilio.com/docs/chat/rest/message-resource) in the [Channel](www.twilio.com/docs/chat/channels) that the Member has read.

Returns:



327
328
329
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 327

def last_consumed_message_index
    @properties['last_consumed_message_index']
end

Returns The absolute URLs of the [Members](www.twilio.com/docs/chat/rest/member-resource), [Messages](www.twilio.com/docs/chat/rest/message-resource) , [Invites](www.twilio.com/docs/chat/rest/invite-resource) and, if it exists, the last [Message](www.twilio.com/docs/chat/rest/message-resource) for the Channel.

Returns:



339
340
341
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 339

def links
    @properties['links']
end

#member_sidString

Returns The SID of a [Member](www.twilio.com/docs/chat/rest/member-resource) that represents the User on the Channel.

Returns:



315
316
317
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 315

def member_sid
    @properties['member_sid']
end

#notification_levelNotificationLevel

Returns:

  • (NotificationLevel)


351
352
353
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 351

def notification_level
    @properties['notification_level']
end

#service_sidString

Returns The SID of the [Service](www.twilio.com/docs/chat/rest/service-resource) the User Channel resource is associated with.

Returns:



297
298
299
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 297

def service_sid
    @properties['service_sid']
end

#statusChannelStatus

Returns:

  • (ChannelStatus)


321
322
323
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 321

def status
    @properties['status']
end

#to_sObject

Provide a user friendly representation



397
398
399
400
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 397

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

#unread_messages_countString

Returns The number of unread Messages in the Channel for the User. Note that retrieving messages on a client endpoint does not mean that messages are consumed or read. See [Consumption Horizon feature](www.twilio.com/docs/chat/consumption-horizon) to learn how to mark messages as consumed.

Returns:

  • (String)

    The number of unread Messages in the Channel for the User. Note that retrieving messages on a client endpoint does not mean that messages are consumed or read. See [Consumption Horizon feature](www.twilio.com/docs/chat/consumption-horizon) to learn how to mark messages as consumed.



333
334
335
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 333

def unread_messages_count
    @properties['unread_messages_count']
end

#update(notification_level: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset) ⇒ UserChannelInstance

Update the UserChannelInstance

Parameters:

Returns:



382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 382

def update(
    notification_level: :unset, 
    last_consumed_message_index: :unset, 
    last_consumption_timestamp: :unset
)

    context.update(
        notification_level: notification_level, 
        last_consumed_message_index: last_consumed_message_index, 
        last_consumption_timestamp: last_consumption_timestamp, 
    )
end

#urlString

Returns The absolute URL of the User Channel resource.

Returns:

  • (String)

    The absolute URL of the User Channel resource.



345
346
347
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 345

def url
    @properties['url']
end

#user_sidString

Returns The SID of the [User](www.twilio.com/docs/chat/rest/user-resource) the User Channel belongs to.

Returns:



309
310
311
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 309

def user_sid
    @properties['user_sid']
end