Class: Twilio::REST::Chat::V2::ServiceContext::UserContext::UserChannelInstance
- Inherits:
-
InstanceResource
- Object
- InstanceResource
- Twilio::REST::Chat::V2::ServiceContext::UserContext::UserChannelInstance
- Defined in:
- lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
Instance Method Summary collapse
-
#account_sid ⇒ String
The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the User Channel resource.
-
#channel_sid ⇒ String
The SID of the [Channel](www.twilio.com/docs/chat/channels) the User Channel resource belongs to.
-
#context ⇒ UserChannelContext
Generate an instance context for the instance, the context is capable of performing various actions.
-
#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean
Delete the UserChannelInstance.
-
#fetch ⇒ UserChannelInstance
Fetch the UserChannelInstance.
-
#initialize(version, payload, service_sid: nil, user_sid: nil, channel_sid: nil) ⇒ UserChannelInstance
constructor
Initialize the UserChannelInstance.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#last_consumed_message_index ⇒ String
The index of the last [Message](www.twilio.com/docs/chat/rest/message-resource) in the [Channel](www.twilio.com/docs/chat/channels) that the Member has read.
-
#links ⇒ Hash
The absolute URLs of the [Members](www.twilio.com/docs/chat/rest/member-resource), [Messages](www.twilio.com/docs/chat/rest/message-resource) , [Invites](www.twilio.com/docs/chat/rest/invite-resource) and, if it exists, the last [Message](www.twilio.com/docs/chat/rest/message-resource) for the Channel.
-
#member_sid ⇒ String
The SID of a [Member](www.twilio.com/docs/chat/rest/member-resource) that represents the User on the Channel.
- #notification_level ⇒ NotificationLevel
-
#service_sid ⇒ String
The SID of the [Service](www.twilio.com/docs/chat/rest/service-resource) the User Channel resource is associated with.
- #status ⇒ ChannelStatus
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#unread_messages_count ⇒ String
The number of unread Messages in the Channel for the User.
-
#update(notification_level: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset) ⇒ UserChannelInstance
Update the UserChannelInstance.
-
#url ⇒ String
The absolute URL of the User Channel resource.
-
#user_sid ⇒ String
The SID of the [User](www.twilio.com/docs/chat/rest/user-resource) the User Channel belongs to.
Constructor Details
#initialize(version, payload, service_sid: nil, user_sid: nil, channel_sid: nil) ⇒ UserChannelInstance
Initialize the UserChannelInstance
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 496 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
Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the User Channel resource.
533 534 535 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 533 def account_sid @properties['account_sid'] end |
#channel_sid ⇒ String
Returns The SID of the [Channel](www.twilio.com/docs/chat/channels) the User Channel resource belongs to.
545 546 547 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 545 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
524 525 526 527 528 529 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 524 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
601 602 603 604 605 606 607 608 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 601 def delete( x_twilio_webhook_enabled: :unset ) context.delete( x_twilio_webhook_enabled: x_twilio_webhook_enabled, ) end |
#fetch ⇒ UserChannelInstance
Fetch the UserChannelInstance
613 614 615 616 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 613 def fetch context.fetch end |
#inspect ⇒ Object
Provide a detailed, user friendly representation
646 647 648 649 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 646 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](www.twilio.com/docs/chat/rest/message-resource) in the [Channel](www.twilio.com/docs/chat/channels) that the Member has read.
569 570 571 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 569 def @properties['last_consumed_message_index'] end |
#links ⇒ Hash
Returns The absolute URLs of the [Members](www.twilio.com/docs/chat/rest/member-resource), [Messages](www.twilio.com/docs/chat/rest/message-resource) , [Invites](www.twilio.com/docs/chat/rest/invite-resource) and, if it exists, the last [Message](www.twilio.com/docs/chat/rest/message-resource) for the Channel.
581 582 583 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 581 def links @properties['links'] end |
#member_sid ⇒ String
Returns The SID of a [Member](www.twilio.com/docs/chat/rest/member-resource) that represents the User on the Channel.
557 558 559 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 557 def member_sid @properties['member_sid'] end |
#notification_level ⇒ NotificationLevel
593 594 595 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 593 def notification_level @properties['notification_level'] end |
#service_sid ⇒ String
Returns The SID of the [Service](www.twilio.com/docs/chat/rest/service-resource) the User Channel resource is associated with.
539 540 541 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 539 def service_sid @properties['service_sid'] end |
#status ⇒ ChannelStatus
563 564 565 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 563 def status @properties['status'] end |
#to_s ⇒ Object
Provide a user friendly representation
639 640 641 642 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 639 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. Note that retrieving messages on a client endpoint does not mean that messages are consumed or read. See [Consumption Horizon feature](www.twilio.com/docs/chat/consumption-horizon) to learn how to mark messages as consumed.
575 576 577 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 575 def @properties['unread_messages_count'] end |
#update(notification_level: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset) ⇒ UserChannelInstance
Update the UserChannelInstance
624 625 626 627 628 629 630 631 632 633 634 635 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 624 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_consumption_timestamp: , ) end |
#url ⇒ String
Returns The absolute URL of the User Channel resource.
587 588 589 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 587 def url @properties['url'] end |
#user_sid ⇒ String
Returns The SID of the [User](www.twilio.com/docs/chat/rest/user-resource) the User Channel belongs to.
551 552 553 |
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 551 def user_sid @properties['user_sid'] end |