class Twilio::REST::Conversations::V1::ServiceContext::UserContext
Public Class Methods
Initialize the UserContext
@param [Version] version Version
that contains the resource @param [String] chat_service_sid The SID of the {Conversation
Service}[https://www.twilio.com/docs/conversations/api/service-resource] to fetch the User resource from.
@param [String] sid The SID of the User resource to fetch. This value can be
either the `sid` or the `identity` of the User resource to fetch.
@return [UserContext] UserContext
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/conversations/v1/service/user.rb 186 def initialize(version, chat_service_sid, sid) 187 super(version) 188 189 # Path Solution 190 @solution = {chat_service_sid: chat_service_sid, sid: sid, } 191 @uri = "/Services/#{@solution[:chat_service_sid]}/Users/#{@solution[:sid]}" 192 193 # Dependents 194 @user_conversations = nil 195 end
Public Instance Methods
Delete the UserInstance
@param [user.WebhookEnabledType] x_twilio_webhook_enabled The
X-Twilio-Webhook-Enabled HTTP request header
@return [Boolean] true if delete succeeds, false otherwise
# File lib/twilio-ruby/rest/conversations/v1/service/user.rb 232 def delete(x_twilio_webhook_enabled: :unset) 233 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 234 235 @version.delete('DELETE', @uri, headers: headers) 236 end
Fetch the UserInstance
@return [UserInstance] Fetched UserInstance
# File lib/twilio-ruby/rest/conversations/v1/service/user.rb 241 def fetch 242 payload = @version.fetch('GET', @uri) 243 244 UserInstance.new( 245 @version, 246 payload, 247 chat_service_sid: @solution[:chat_service_sid], 248 sid: @solution[:sid], 249 ) 250 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/service/user.rb 288 def inspect 289 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 290 "#<Twilio.Conversations.V1.UserContext #{context}>" 291 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/service/user.rb 281 def to_s 282 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 283 "#<Twilio.Conversations.V1.UserContext #{context}>" 284 end
Update the UserInstance
@param [String] friendly_name The string that you assigned to describe the
resource.
@param [String] attributes The JSON Object string that stores
application-specific data. If attributes have not been set, `{}` is returned.
@param [String] role_sid The SID of a service-level
{Role}[https://www.twilio.com/docs/conversations/api/role-resource] to assign to the user.
@param [user.WebhookEnabledType] x_twilio_webhook_enabled The
X-Twilio-Webhook-Enabled HTTP request header
@return [UserInstance] Updated UserInstance
# File lib/twilio-ruby/rest/conversations/v1/service/user.rb 209 def update(friendly_name: :unset, attributes: :unset, role_sid: :unset, x_twilio_webhook_enabled: :unset) 210 data = Twilio::Values.of({ 211 'FriendlyName' => friendly_name, 212 'Attributes' => attributes, 213 'RoleSid' => role_sid, 214 }) 215 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 216 217 payload = @version.update('POST', @uri, data: data, headers: headers) 218 219 UserInstance.new( 220 @version, 221 payload, 222 chat_service_sid: @solution[:chat_service_sid], 223 sid: @solution[:sid], 224 ) 225 end
Access the user_conversations
@return [UserConversationList] @return [UserConversationContext] if conversation_sid was passed.
# File lib/twilio-ruby/rest/conversations/v1/service/user.rb 256 def user_conversations(conversation_sid=:unset) 257 raise ArgumentError, 'conversation_sid cannot be nil' if conversation_sid.nil? 258 259 if conversation_sid != :unset 260 return UserConversationContext.new( 261 @version, 262 @solution[:chat_service_sid], 263 @solution[:sid], 264 conversation_sid, 265 ) 266 end 267 268 unless @user_conversations 269 @user_conversations = UserConversationList.new( 270 @version, 271 chat_service_sid: @solution[:chat_service_sid], 272 user_sid: @solution[:sid], 273 ) 274 end 275 276 @user_conversations 277 end