class Twilio::REST::Chat::V1::ServiceContext::UserContext
Public Class Methods
Initialize the UserContext
@param [Version] version Version
that contains the resource @param [String] service_sid The SID of the
{Service}[https://www.twilio.com/docs/api/chat/rest/services] to fetch the resource from.
@param [String] sid The Twilio-provided string that uniquely identifies the User
resource to fetch.
@return [UserContext] UserContext
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/chat/v1/service/user.rb 184 def initialize(version, service_sid, sid) 185 super(version) 186 187 # Path Solution 188 @solution = {service_sid: service_sid, sid: sid, } 189 @uri = "/Services/#{@solution[:service_sid]}/Users/#{@solution[:sid]}" 190 191 # Dependents 192 @user_channels = nil 193 end
Public Instance Methods
Delete the UserInstance
@return [Boolean] true if delete succeeds, false otherwise
# File lib/twilio-ruby/rest/chat/v1/service/user.rb 207 def delete 208 @version.delete('DELETE', @uri) 209 end
Fetch the UserInstance
@return [UserInstance] Fetched UserInstance
# File lib/twilio-ruby/rest/chat/v1/service/user.rb 198 def fetch 199 payload = @version.fetch('GET', @uri) 200 201 UserInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) 202 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/chat/v1/service/user.rb 257 def inspect 258 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 259 "#<Twilio.Chat.V1.UserContext #{context}>" 260 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/chat/v1/service/user.rb 250 def to_s 251 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 252 "#<Twilio.Chat.V1.UserContext #{context}>" 253 end
Update the UserInstance
@param [String] role_sid The SID of the
{Role}[https://www.twilio.com/docs/api/chat/rest/roles] assigned to this user.
@param [String] attributes A valid JSON string that contains
application-specific data.
@param [String] friendly_name A descriptive string that you create to describe
the resource. It is often used for display purposes.
@return [UserInstance] Updated UserInstance
# File lib/twilio-ruby/rest/chat/v1/service/user.rb 220 def update(role_sid: :unset, attributes: :unset, friendly_name: :unset) 221 data = Twilio::Values.of({ 222 'RoleSid' => role_sid, 223 'Attributes' => attributes, 224 'FriendlyName' => friendly_name, 225 }) 226 227 payload = @version.update('POST', @uri, data: data) 228 229 UserInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) 230 end
Access the user_channels
@return [UserChannelList] @return [UserChannelContext]
# File lib/twilio-ruby/rest/chat/v1/service/user.rb 236 def user_channels 237 unless @user_channels 238 @user_channels = UserChannelList.new( 239 @version, 240 service_sid: @solution[:service_sid], 241 user_sid: @solution[:sid], 242 ) 243 end 244 245 @user_channels 246 end