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



274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 274

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



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

def 
    @properties['account_sid']
end

#channel_sidString



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

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



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

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



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

def delete(
    x_twilio_webhook_enabled: :unset
)

    context.delete(
        x_twilio_webhook_enabled: x_twilio_webhook_enabled, 
    )
end

#fetchUserChannelInstance

Fetch the UserChannelInstance



390
391
392
393
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 390

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



423
424
425
426
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 423

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

#last_consumed_message_indexString



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

def last_consumed_message_index
    @properties['last_consumed_message_index']
end


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

def links
    @properties['links']
end

#member_sidString



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

def member_sid
    @properties['member_sid']
end

#notification_levelNotificationLevel



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

def notification_level
    @properties['notification_level']
end

#service_sidString



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

def service_sid
    @properties['service_sid']
end

#statusChannelStatus



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

def status
    @properties['status']
end

#to_sObject

Provide a user friendly representation



416
417
418
419
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 416

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

#unread_messages_countString



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

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



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

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



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

def url
    @properties['url']
end

#user_sidString



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

def user_sid
    @properties['user_sid']
end