class Twilio::REST::Conversations::V1::ConversationContext
Public Class Methods
Initialize the ConversationContext
@param [Version] version Version
that contains the resource @param [String] sid A 34 character string that uniquely identifies this
resource. Can also be the `unique_name` of the Conversation.
@return [ConversationContext] ConversationContext
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/conversations/v1/conversation.rb 193 def initialize(version, sid) 194 super(version) 195 196 # Path Solution 197 @solution = {sid: sid, } 198 @uri = "/Conversations/#{@solution[:sid]}" 199 200 # Dependents 201 @participants = nil 202 @messages = nil 203 @webhooks = nil 204 end
Public Instance Methods
Delete the ConversationInstance
@param [conversation.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/conversation.rb 255 def delete(x_twilio_webhook_enabled: :unset) 256 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 257 258 @version.delete('DELETE', @uri, headers: headers) 259 end
Fetch the ConversationInstance
@return [ConversationInstance] Fetched ConversationInstance
# File lib/twilio-ruby/rest/conversations/v1/conversation.rb 264 def fetch 265 payload = @version.fetch('GET', @uri) 266 267 ConversationInstance.new(@version, payload, sid: @solution[:sid], ) 268 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/conversation.rb 333 def inspect 334 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 335 "#<Twilio.Conversations.V1.ConversationContext #{context}>" 336 end
Access the messages @return [MessageList] @return [MessageContext] if sid was passed.
# File lib/twilio-ruby/rest/conversations/v1/conversation.rb 292 def messages(sid=:unset) 293 raise ArgumentError, 'sid cannot be nil' if sid.nil? 294 295 if sid != :unset 296 return MessageContext.new(@version, @solution[:sid], sid, ) 297 end 298 299 unless @messages 300 @messages = MessageList.new(@version, conversation_sid: @solution[:sid], ) 301 end 302 303 @messages 304 end
Access the participants @return [ParticipantList] @return [ParticipantContext] if sid was passed.
# File lib/twilio-ruby/rest/conversations/v1/conversation.rb 274 def participants(sid=:unset) 275 raise ArgumentError, 'sid cannot be nil' if sid.nil? 276 277 if sid != :unset 278 return ParticipantContext.new(@version, @solution[:sid], sid, ) 279 end 280 281 unless @participants 282 @participants = ParticipantList.new(@version, conversation_sid: @solution[:sid], ) 283 end 284 285 @participants 286 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/conversation.rb 326 def to_s 327 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 328 "#<Twilio.Conversations.V1.ConversationContext #{context}>" 329 end
Update the ConversationInstance
@param [String] friendly_name The human-readable name of this conversation,
limited to 256 characters. Optional.
@param [Time] date_created The date that this resource was created. @param [Time] date_updated The date that this resource was last updated. @param [String] attributes An optional string metadata field you can use to
store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set "{}" will be returned.
@param [String] messaging_service_sid The unique ID of the {Messaging
Service}[https://www.twilio.com/docs/sms/services/api] this conversation belongs to.
@param [conversation.State] state Current state of this conversation. Can be
either `active`, `inactive` or `closed` and defaults to `active`
@param [String] timers_inactive ISO8601 duration when conversation will be
switched to `inactive` state. Minimum value for this timer is 1 minute.
@param [String] timers_closed ISO8601 duration when conversation will be
switched to `closed` state. Minimum value for this timer is 10 minutes.
@param [String] unique_name An application-defined string that uniquely
identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL.
@param [conversation.WebhookEnabledType] x_twilio_webhook_enabled The
X-Twilio-Webhook-Enabled HTTP request header
@return [ConversationInstance] Updated ConversationInstance
# File lib/twilio-ruby/rest/conversations/v1/conversation.rb 231 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, x_twilio_webhook_enabled: :unset) 232 data = Twilio::Values.of({ 233 'FriendlyName' => friendly_name, 234 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), 235 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), 236 'Attributes' => attributes, 237 'MessagingServiceSid' => messaging_service_sid, 238 'State' => state, 239 'Timers.Inactive' => timers_inactive, 240 'Timers.Closed' => timers_closed, 241 'UniqueName' => unique_name, 242 }) 243 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 244 245 payload = @version.update('POST', @uri, data: data, headers: headers) 246 247 ConversationInstance.new(@version, payload, sid: @solution[:sid], ) 248 end
Access the webhooks @return [WebhookList] @return [WebhookContext] if sid was passed.
# File lib/twilio-ruby/rest/conversations/v1/conversation.rb 310 def webhooks(sid=:unset) 311 raise ArgumentError, 'sid cannot be nil' if sid.nil? 312 313 if sid != :unset 314 return WebhookContext.new(@version, @solution[:sid], sid, ) 315 end 316 317 unless @webhooks 318 @webhooks = WebhookList.new(@version, conversation_sid: @solution[:sid], ) 319 end 320 321 @webhooks 322 end