Class: Twilio::REST::Conversations::V1::ServiceContext::ConversationContext
- Inherits:
-
InstanceContext
- Object
- InstanceContext
- Twilio::REST::Conversations::V1::ServiceContext::ConversationContext
- Defined in:
- lib/twilio-ruby/rest/conversations/v1/service/conversation.rb,
lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb,
lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb,
lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb,
lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb
Defined Under Namespace
Classes: MessageContext, MessageInstance, MessageList, MessagePage, ParticipantContext, ParticipantInstance, ParticipantList, ParticipantPage, WebhookContext, WebhookInstance, WebhookList, WebhookPage
Instance Method Summary collapse
-
#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean
Delete the ConversationInstance.
-
#fetch ⇒ ConversationInstance
Fetch the ConversationInstance.
-
#initialize(version, chat_service_sid, sid) ⇒ ConversationContext
constructor
Initialize the ConversationContext.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#messages(sid = :unset) ⇒ MessageList, MessageContext
Access the messages.
-
#participants(sid = :unset) ⇒ ParticipantList, ParticipantContext
Access the participants.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#update(friendly_name: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, messaging_service_sid: :unset, state: :unset, timers_inactive: :unset, timers_closed: :unset, unique_name: :unset, bindings_email_address: :unset, bindings_email_name: :unset, x_twilio_webhook_enabled: :unset) ⇒ ConversationInstance
Update the ConversationInstance.
-
#webhooks(sid = :unset) ⇒ WebhookList, WebhookContext
Access the webhooks.
Constructor Details
#initialize(version, chat_service_sid, sid) ⇒ ConversationContext
Initialize the ConversationContext
215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 215 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]}/Conversations/#{@solution[:sid]}" # Dependents @participants = nil @webhooks = nil @messages = nil end |
Instance Method Details
#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean
Delete the ConversationInstance
231 232 233 234 235 236 237 238 239 240 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 231 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 ⇒ ConversationInstance
Fetch the ConversationInstance
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 245 def fetch headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) payload = @version.fetch('GET', @uri, headers: headers) ConversationInstance.new( @version, payload, chat_service_sid: @solution[:chat_service_sid], sid: @solution[:sid], ) end |
#inspect ⇒ Object
Provide a detailed, user friendly representation
388 389 390 391 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 388 def inspect context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Conversations.V1.ConversationContext #{context}>" end |
#messages(sid = :unset) ⇒ MessageList, MessageContext
Access the messages
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 363 def (sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return MessageContext.new(@version, @solution[:chat_service_sid], @solution[:sid],sid ) end unless @messages @messages = MessageList.new( @version, chat_service_sid: @solution[:chat_service_sid], conversation_sid: @solution[:sid], ) end @messages end |
#participants(sid = :unset) ⇒ ParticipantList, ParticipantContext
Access the participants
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 325 def participants(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return ParticipantContext.new(@version, @solution[:chat_service_sid], @solution[:sid],sid ) end unless @participants @participants = ParticipantList.new( @version, chat_service_sid: @solution[:chat_service_sid], conversation_sid: @solution[:sid], ) end @participants end |
#to_s ⇒ Object
Provide a user friendly representation
381 382 383 384 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 381 def to_s context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Conversations.V1.ConversationContext #{context}>" end |
#update(friendly_name: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, messaging_service_sid: :unset, state: :unset, timers_inactive: :unset, timers_closed: :unset, unique_name: :unset, bindings_email_address: :unset, bindings_email_name: :unset, x_twilio_webhook_enabled: :unset) ⇒ ConversationInstance
Update the ConversationInstance
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 277 def update( friendly_name: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, messaging_service_sid: :unset, state: :unset, timers_inactive: :unset, timers_closed: :unset, unique_name: :unset, bindings_email_address: :unset, bindings_email_name: :unset, x_twilio_webhook_enabled: :unset ) data = Twilio::Values.of({ 'FriendlyName' => friendly_name, 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), 'Attributes' => attributes, 'MessagingServiceSid' => messaging_service_sid, 'State' => state, 'Timers.Inactive' => timers_inactive, 'Timers.Closed' => timers_closed, 'UniqueName' => unique_name, 'Bindings.Email.Address' => bindings_email_address, 'Bindings.Email.Name' => bindings_email_name, }) 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) ConversationInstance.new( @version, payload, chat_service_sid: @solution[:chat_service_sid], sid: @solution[:sid], ) end |
#webhooks(sid = :unset) ⇒ WebhookList, WebhookContext
Access the webhooks
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 344 def webhooks(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return WebhookContext.new(@version, @solution[:chat_service_sid], @solution[:sid],sid ) end unless @webhooks @webhooks = WebhookList.new( @version, chat_service_sid: @solution[:chat_service_sid], conversation_sid: @solution[:sid], ) end @webhooks end |