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

Inherits:
Twilio::REST::InstanceResource show all
Defined in:
lib/twilio-ruby/rest/ip_messaging/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



490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 490

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



527
528
529
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 527

def 
    @properties['account_sid']
end

#channel_sidString



539
540
541
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 539

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



518
519
520
521
522
523
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 518

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

#deleteBoolean

Delete the UserChannelInstance



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

def delete

    context.delete
end

#fetchUserChannelInstance

Fetch the UserChannelInstance



602
603
604
605
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 602

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



635
636
637
638
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 635

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

#last_consumed_message_indexString



563
564
565
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 563

def last_consumed_message_index
    @properties['last_consumed_message_index']
end


575
576
577
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 575

def links
    @properties['links']
end

#member_sidString



551
552
553
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 551

def member_sid
    @properties['member_sid']
end

#notification_levelNotificationLevel



587
588
589
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 587

def notification_level
    @properties['notification_level']
end

#service_sidString



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

def service_sid
    @properties['service_sid']
end

#statusChannelStatus



557
558
559
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 557

def status
    @properties['status']
end

#to_sObject

Provide a user friendly representation



628
629
630
631
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 628

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

#unread_messages_countString



569
570
571
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 569

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



613
614
615
616
617
618
619
620
621
622
623
624
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 613

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



581
582
583
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 581

def url
    @properties['url']
end

#user_sidString



545
546
547
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 545

def user_sid
    @properties['user_sid']
end