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



504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 504

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



541
542
543
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 541

def 
    @properties['account_sid']
end

#channel_sid ⇒ String



553
554
555
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 553

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



532
533
534
535
536
537
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 532

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



609
610
611
612
613
614
615
616
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 609

def delete(
  x_twilio_webhook_enabled: :unset
)

    context.delete(
        x_twilio_webhook_enabled: x_twilio_webhook_enabled, 
    )
end

#fetch ⇒ UserChannelInstance

Fetch the UserChannelInstance



621
622
623
624
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 621

def fetch

    context.fetch
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



654
655
656
657
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 654

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

#last_consumed_message_index ⇒ String



577
578
579
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 577

def last_consumed_message_index
    @properties['last_consumed_message_index']
end


589
590
591
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 589

def links
    @properties['links']
end

#member_sid ⇒ String



565
566
567
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 565

def member_sid
    @properties['member_sid']
end

#notification_level ⇒ NotificationLevel



601
602
603
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 601

def notification_level
    @properties['notification_level']
end

#service_sid ⇒ String



547
548
549
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 547

def service_sid
    @properties['service_sid']
end

#status ⇒ ChannelStatus



571
572
573
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 571

def status
    @properties['status']
end

#to_s ⇒ Object

Provide a user friendly representation



647
648
649
650
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 647

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

#unread_messages_count ⇒ String



583
584
585
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 583

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



632
633
634
635
636
637
638
639
640
641
642
643
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 632

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



595
596
597
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 595

def url
    @properties['url']
end

#user_sid ⇒ String



559
560
561
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 559

def user_sid
    @properties['user_sid']
end