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:



251
252
253
254
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 251

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,
      'user_sid' => user_sid,
      'channel_sid' => channel_sid || @properties['channel_sid'],
  }
end

Instance Method Details

#account_sidString

Returns The SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource



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

def 
  @properties['account_sid']
end

#channel_sidString

Returns The SID of the Channel the resource belongs to.

Returns:

  • (String)

    The SID of the Channel the resource belongs to



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

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
288
289
290
291
292
# 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

#fetchUserChannelInstance

Fetch a UserChannelInstance

Returns:



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

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



385
386
387
388
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 385

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 in the Channel the Member has read.

Returns:

  • (String)

    The index of the last Message in the Channel the Member has read



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

def last_consumed_message_index
  @properties['last_consumed_message_index']
end

Returns Absolute URLs to access the Members, Messages , Invites and, if it exists, the last Message for the Channel.

Returns:

  • (String)

    Absolute URLs to access the Members, Messages , Invites and, if it exists, the last Message for the Channel



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

def links
  @properties['links']
end

#member_sidString

Returns The SID of the User as a Member in the Channel.

Returns:

  • (String)

    The SID of the User as a Member in the Channel



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

def member_sid
  @properties['member_sid']
end

#notification_leveluser_channel.NotificationLevel

Returns The push notification level of the User for the Channel.

Returns:

  • (user_channel.NotificationLevel)

    The push notification level of the User for the Channel



356
357
358
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 356

def notification_level
  @properties['notification_level']
end

#service_sidString

Returns The SID of the Service that the resource is associated with.

Returns:

  • (String)

    The SID of the Service that the resource is associated with



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

def service_sid
  @properties['service_sid']
end

#statususer_channel.ChannelStatus

Returns The status of the User on the Channel.

Returns:

  • (user_channel.ChannelStatus)

    The status of the User on the Channel



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

def status
  @properties['status']
end

#to_sObject

Provide a user friendly representation



378
379
380
381
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 378

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.

Returns:

  • (String)

    The number of unread Messages in the Channel for the User



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

def unread_messages_count
  @properties['unread_messages_count']
end

#update(notification_level: nil) ⇒ UserChannelInstance

Update the UserChannelInstance

Parameters:

  • notification_level (user_channel.NotificationLevel) (defaults to: nil)

    The push notification level to assign to the User Channel. Can be: ‘default` or `muted`.

Returns:



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

def update(notification_level: nil)
  context.update(notification_level: notification_level, )
end

#urlString

Returns The absolute URL of the resource.

Returns:

  • (String)

    The absolute URL of the resource



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

def url
  @properties['url']
end

#user_sidString

Returns The SID of the User the User Channel belongs to.

Returns:

  • (String)

    The SID of the User the User Channel belongs to



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

def user_sid
  @properties['user_sid']
end