Class: Twilio::REST::Conversations::V1::ServiceContext::UserContext
- Inherits:
-
InstanceContext
- Object
- InstanceContext
- Twilio::REST::Conversations::V1::ServiceContext::UserContext
- Defined in:
- lib/twilio-ruby/rest/conversations/v1/service/user.rb,
lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb
Defined Under Namespace
Classes: UserConversationContext, UserConversationInstance, UserConversationList, UserConversationPage
Instance Method Summary collapse
-
#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean
Delete the UserInstance.
-
#fetch ⇒ UserInstance
Fetch the UserInstance.
-
#initialize(version, chat_service_sid, sid) ⇒ UserContext
constructor
Initialize the UserContext.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#update(friendly_name: :unset, attributes: :unset, role_sid: :unset, x_twilio_webhook_enabled: :unset) ⇒ UserInstance
Update the UserInstance.
-
#user_conversations(conversation_sid = :unset) ⇒ UserConversationList, UserConversationContext
Access the user_conversations.
Constructor Details
#initialize(version, chat_service_sid, sid) ⇒ UserContext
Initialize the UserContext
176 177 178 179 180 181 182 183 184 185 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/user.rb', line 176 def initialize(version, chat_service_sid, sid) super(version) # Path Solution @solution = { chat_service_sid: chat_service_sid, sid: sid, } @uri = "/Services/#{@solution[:chat_service_sid]}/Users/#{@solution[:sid]}" # Dependents @user_conversations = nil end |
Instance Method Details
#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean
Delete the UserInstance
190 191 192 193 194 195 196 197 198 199 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/user.rb', line 190 def delete( x_twilio_webhook_enabled: :unset ) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) @version.delete('DELETE', @uri, headers: headers) end |
#fetch ⇒ UserInstance
Fetch the UserInstance
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/user.rb', line 204 def fetch headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) payload = @version.fetch('GET', @uri, headers: headers) UserInstance.new( @version, payload, chat_service_sid: @solution[:chat_service_sid], sid: @solution[:sid], ) end |
#inspect ⇒ Object
Provide a detailed, user friendly representation
285 286 287 288 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/user.rb', line 285 def inspect context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Conversations.V1.UserContext #{context}>" end |
#to_s ⇒ Object
Provide a user friendly representation
278 279 280 281 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/user.rb', line 278 def to_s context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Conversations.V1.UserContext #{context}>" end |
#update(friendly_name: :unset, attributes: :unset, role_sid: :unset, x_twilio_webhook_enabled: :unset) ⇒ UserInstance
Update the UserInstance
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/user.rb', line 228 def update( friendly_name: :unset, attributes: :unset, role_sid: :unset, x_twilio_webhook_enabled: :unset ) data = Twilio::Values.of({ 'FriendlyName' => friendly_name, 'Attributes' => attributes, 'RoleSid' => role_sid, }) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) payload = @version.update('POST', @uri, data: data, headers: headers) UserInstance.new( @version, payload, chat_service_sid: @solution[:chat_service_sid], sid: @solution[:sid], ) end |
#user_conversations(conversation_sid = :unset) ⇒ UserConversationList, UserConversationContext
Access the user_conversations
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/user.rb', line 260 def user_conversations(conversation_sid=:unset) raise ArgumentError, 'conversation_sid cannot be nil' if conversation_sid.nil? if conversation_sid != :unset return UserConversationContext.new(@version, @solution[:chat_service_sid], @solution[:sid],conversation_sid ) end unless @user_conversations @user_conversations = UserConversationList.new( @version, chat_service_sid: @solution[:chat_service_sid], user_sid: @solution[:sid], ) end @user_conversations end |