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

  • service_sid (String) (defaults to: nil) —

    The SID of the Service the User Channel resource is associated with.

  • user_sid (String) (defaults to: nil) —

    The SID of the User the User Channel belongs to.

  • channel_sid (String) (defaults to: nil) —

    The SID of the Channel that has the User Channel to fetch. This value can be either the sid or the unique_name of the Channel to fetch.



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 266

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_sid ⇒ String

Returns The SID of the Account that created the resource.

Returns:

  • (String) —

    The SID of the Account that created the resource



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

def 
  @properties['account_sid']
end

#channel_sid ⇒ String

Returns The SID of the Channel the resource belongs to.

Returns:

  • (String) —

    The SID of the Channel the resource belongs to



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

def channel_sid
  @properties['channel_sid']
end

#context ⇒ UserChannelContext

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

Returns:



297
298
299
300
301
302
303
304
305
306
307
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 297

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 (user_channel.WebhookEnabledType) (defaults to: :unset) —

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean) —

    true if delete succeeds, false otherwise



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

def delete(x_twilio_webhook_enabled: :unset)
  context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, )
end

#fetch ⇒ UserChannelInstance

Fetch the UserChannelInstance

Returns:



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

def fetch
  context.fetch
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



420
421
422
423
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 420

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

#last_consumed_message_index ⇒ String

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



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

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



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

def links
  @properties['links']
end

#member_sid ⇒ String

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



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

def member_sid
  @properties['member_sid']
end

#notification_level ⇒ user_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



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

def notification_level
  @properties['notification_level']
end

#service_sid ⇒ String

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



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

def service_sid
  @properties['service_sid']
end

#status ⇒ user_channel.ChannelStatus

Returns The status of the User on the Channel.

Returns:

  • (user_channel.ChannelStatus) —

    The status of the User on the Channel



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

def status
  @properties['status']
end

#to_s ⇒ Object

Provide a user friendly representation



413
414
415
416
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 413

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

#unread_messages_count ⇒ String

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



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

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:

  • notification_level (user_channel.NotificationLevel) (defaults to: :unset) —

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

  • last_consumed_message_index (String) (defaults to: :unset) —

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

  • last_consumption_timestamp (Time) (defaults to: :unset) —

    The ISO 8601 timestamp of the last Message read event for the Member within the Channel.

Returns:



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

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

#url ⇒ String

Returns The absolute URL of the resource.

Returns:

  • (String) —

    The absolute URL of the resource



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

def url
  @properties['url']
end

#user_sid ⇒ String

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

Returns:

  • (String) —

    The SID of the User the User Channel belongs to



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

def user_sid
  @properties['user_sid']
end