class Twilio::REST::Conversations::V1::ServiceContext::ConversationContext

Public Class Methods

new(version, chat_service_sid, sid) click to toggle source

Initialize the ConversationContext @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] the
Conversation resource is associated with.

@param [String] sid A 34 character string that uniquely identifies this

resource. Can also be the `unique_name` of the Conversation.

@return [ConversationContext] ConversationContext

Calls superclass method Twilio::REST::InstanceContext::new
    # File lib/twilio-ruby/rest/conversations/v1/service/conversation.rb
200 def initialize(version, chat_service_sid, sid)
201   super(version)
202 
203   # Path Solution
204   @solution = {chat_service_sid: chat_service_sid, sid: sid, }
205   @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:sid]}"
206 
207   # Dependents
208   @participants = nil
209   @messages = nil
210   @webhooks = nil
211 end

Public Instance Methods

delete(x_twilio_webhook_enabled: :unset) click to toggle source

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/service/conversation.rb
267 def delete(x_twilio_webhook_enabled: :unset)
268   headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
269 
270    @version.delete('DELETE', @uri, headers: headers)
271 end
fetch() click to toggle source

Fetch the ConversationInstance @return [ConversationInstance] Fetched ConversationInstance

    # File lib/twilio-ruby/rest/conversations/v1/service/conversation.rb
276 def fetch
277   payload = @version.fetch('GET', @uri)
278 
279   ConversationInstance.new(
280       @version,
281       payload,
282       chat_service_sid: @solution[:chat_service_sid],
283       sid: @solution[:sid],
284   )
285 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/conversations/v1/service/conversation.rb
362 def inspect
363   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
364   "#<Twilio.Conversations.V1.ConversationContext #{context}>"
365 end
messages(sid=:unset) click to toggle source

Access the messages @return [MessageList] @return [MessageContext] if sid was passed.

    # File lib/twilio-ruby/rest/conversations/v1/service/conversation.rb
313 def messages(sid=:unset)
314   raise ArgumentError, 'sid cannot be nil' if sid.nil?
315 
316   if sid != :unset
317     return MessageContext.new(@version, @solution[:chat_service_sid], @solution[:sid], sid, )
318   end
319 
320   unless @messages
321     @messages = MessageList.new(
322         @version,
323         chat_service_sid: @solution[:chat_service_sid],
324         conversation_sid: @solution[:sid],
325     )
326   end
327 
328   @messages
329 end
participants(sid=:unset) click to toggle source

Access the participants @return [ParticipantList] @return [ParticipantContext] if sid was passed.

    # File lib/twilio-ruby/rest/conversations/v1/service/conversation.rb
291 def participants(sid=:unset)
292   raise ArgumentError, 'sid cannot be nil' if sid.nil?
293 
294   if sid != :unset
295     return ParticipantContext.new(@version, @solution[:chat_service_sid], @solution[:sid], sid, )
296   end
297 
298   unless @participants
299     @participants = ParticipantList.new(
300         @version,
301         chat_service_sid: @solution[:chat_service_sid],
302         conversation_sid: @solution[:sid],
303     )
304   end
305 
306   @participants
307 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/conversations/v1/service/conversation.rb
355 def to_s
356   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
357   "#<Twilio.Conversations.V1.ConversationContext #{context}>"
358 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, x_twilio_webhook_enabled: :unset) click to toggle source

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/service/conversation.rb
238 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)
239   data = Twilio::Values.of({
240       'FriendlyName' => friendly_name,
241       'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
242       'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
243       'Attributes' => attributes,
244       'MessagingServiceSid' => messaging_service_sid,
245       'State' => state,
246       'Timers.Inactive' => timers_inactive,
247       'Timers.Closed' => timers_closed,
248       'UniqueName' => unique_name,
249   })
250   headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
251 
252   payload = @version.update('POST', @uri, data: data, headers: headers)
253 
254   ConversationInstance.new(
255       @version,
256       payload,
257       chat_service_sid: @solution[:chat_service_sid],
258       sid: @solution[:sid],
259   )
260 end
webhooks(sid=:unset) click to toggle source

Access the webhooks @return [WebhookList] @return [WebhookContext] if sid was passed.

    # File lib/twilio-ruby/rest/conversations/v1/service/conversation.rb
335 def webhooks(sid=:unset)
336   raise ArgumentError, 'sid cannot be nil' if sid.nil?
337 
338   if sid != :unset
339     return WebhookContext.new(@version, @solution[:chat_service_sid], @solution[:sid], sid, )
340   end
341 
342   unless @webhooks
343     @webhooks = WebhookList.new(
344         @version,
345         chat_service_sid: @solution[:chat_service_sid],
346         conversation_sid: @solution[:sid],
347     )
348   end
349 
350   @webhooks
351 end