class Twilio::REST::Chat::V2::ServiceContext::UserContext::UserChannelContext

Public Class Methods

new(version, service_sid, user_sid, channel_sid) click to toggle source

Initialize the UserChannelContext @param [Version] version Version that contains the resource @param [String] service_sid The SID of the

{Service}[https://www.twilio.com/docs/chat/rest/service-resource] to fetch the
User Channel resource from.

@param [String] user_sid The SID of the

{User}[https://www.twilio.com/docs/chat/rest/user-resource] to fetch the User
Channel resource from. This value can be either the `sid` or the `identity` of
the User resource.

@param [String] channel_sid The SID of the

{Channel}[https://www.twilio.com/docs/chat/channels] that has the User Channel
to fetch. This value can be either the `sid` or the `unique_name` of the Channel
to fetch.

@return [UserChannelContext] UserChannelContext

Calls superclass method Twilio::REST::InstanceContext::new
    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
171 def initialize(version, service_sid, user_sid, channel_sid)
172   super(version)
173 
174   # Path Solution
175   @solution = {service_sid: service_sid, user_sid: user_sid, channel_sid: channel_sid, }
176   @uri = "/Services/#{@solution[:service_sid]}/Users/#{@solution[:user_sid]}/Channels/#{@solution[:channel_sid]}"
177 end

Public Instance Methods

delete() click to toggle source

Delete the UserChannelInstance @return [Boolean] true if delete succeeds, false otherwise

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
197 def delete
198    @version.delete('DELETE', @uri)
199 end
fetch() click to toggle source

Fetch the UserChannelInstance @return [UserChannelInstance] Fetched UserChannelInstance

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
182 def fetch
183   payload = @version.fetch('GET', @uri)
184 
185   UserChannelInstance.new(
186       @version,
187       payload,
188       service_sid: @solution[:service_sid],
189       user_sid: @solution[:user_sid],
190       channel_sid: @solution[:channel_sid],
191   )
192 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
240 def inspect
241   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
242   "#<Twilio.Chat.V2.UserChannelContext #{context}>"
243 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
233 def to_s
234   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
235   "#<Twilio.Chat.V2.UserChannelContext #{context}>"
236 end
update(notification_level: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset) click to toggle source

Update the UserChannelInstance @param [user_channel.NotificationLevel] notification_level The push notification

level to assign to the User Channel. Can be: `default` or `muted`.

@param [String] last_consumed_message_index The index of the last

{Message}[https://www.twilio.com/docs/chat/rest/message-resource] in the
{Channel}[https://www.twilio.com/docs/chat/channels] that the Member has read.

@param [Time] last_consumption_timestamp The {ISO

8601}[https://en.wikipedia.org/wiki/ISO_8601] timestamp of the last
{Message}[https://www.twilio.com/docs/chat/rest/message-resource] read event for
the Member within the {Channel}[https://www.twilio.com/docs/chat/channels].

@return [UserChannelInstance] Updated UserChannelInstance

    # File lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb
213 def update(notification_level: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset)
214   data = Twilio::Values.of({
215       'NotificationLevel' => notification_level,
216       'LastConsumedMessageIndex' => last_consumed_message_index,
217       'LastConsumptionTimestamp' => Twilio.serialize_iso8601_datetime(last_consumption_timestamp),
218   })
219 
220   payload = @version.update('POST', @uri, data: data)
221 
222   UserChannelInstance.new(
223       @version,
224       payload,
225       service_sid: @solution[:service_sid],
226       user_sid: @solution[:user_sid],
227       channel_sid: @solution[:channel_sid],
228   )
229 end