class Twilio::REST::Proxy::V1::ServiceContext::SessionContext
PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
Public Class Methods
Initialize the SessionContext
@param [Version] version Version
that contains the resource @param [String] service_sid The SID of the parent
{Service}[https://www.twilio.com/docs/proxy/api/service] of the resource to fetch.
@param [String] sid The Twilio-provided string that uniquely identifies the
Session resource to fetch.
@return [SessionContext] SessionContext
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/proxy/v1/service/session.rb 209 def initialize(version, service_sid, sid) 210 super(version) 211 212 # Path Solution 213 @solution = {service_sid: service_sid, sid: sid, } 214 @uri = "/Services/#{@solution[:service_sid]}/Sessions/#{@solution[:sid]}" 215 216 # Dependents 217 @interactions = nil 218 @participants = nil 219 end
Public Instance Methods
Delete the SessionInstance
@return [Boolean] true if delete succeeds, false otherwise
# File lib/twilio-ruby/rest/proxy/v1/service/session.rb 233 def delete 234 @version.delete('DELETE', @uri) 235 end
Fetch the SessionInstance
@return [SessionInstance] Fetched SessionInstance
# File lib/twilio-ruby/rest/proxy/v1/service/session.rb 224 def fetch 225 payload = @version.fetch('GET', @uri) 226 227 SessionInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) 228 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/proxy/v1/service/session.rb 324 def inspect 325 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 326 "#<Twilio.Proxy.V1.SessionContext #{context}>" 327 end
Access the interactions @return [InteractionList] @return [InteractionContext] if sid was passed.
# File lib/twilio-ruby/rest/proxy/v1/service/session.rb 275 def interactions(sid=:unset) 276 raise ArgumentError, 'sid cannot be nil' if sid.nil? 277 278 if sid != :unset 279 return InteractionContext.new(@version, @solution[:service_sid], @solution[:sid], sid, ) 280 end 281 282 unless @interactions 283 @interactions = InteractionList.new( 284 @version, 285 service_sid: @solution[:service_sid], 286 session_sid: @solution[:sid], 287 ) 288 end 289 290 @interactions 291 end
Access the participants @return [ParticipantList] @return [ParticipantContext] if sid was passed.
# File lib/twilio-ruby/rest/proxy/v1/service/session.rb 297 def participants(sid=:unset) 298 raise ArgumentError, 'sid cannot be nil' if sid.nil? 299 300 if sid != :unset 301 return ParticipantContext.new(@version, @solution[:service_sid], @solution[:sid], sid, ) 302 end 303 304 unless @participants 305 @participants = ParticipantList.new( 306 @version, 307 service_sid: @solution[:service_sid], 308 session_sid: @solution[:sid], 309 ) 310 end 311 312 @participants 313 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/proxy/v1/service/session.rb 317 def to_s 318 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 319 "#<Twilio.Proxy.V1.SessionContext #{context}>" 320 end
Update the SessionInstance
@param [Time] date_expiry The ISO 8601
date when the Session should expire. If this is value is present, it overrides the `ttl` value.
@param [String] ttl The time, in seconds, when the session will expire. The time
is measured from the last Session create or the Session's last Interaction.
@param [session.Status] status The new status of the resource. Can be:
`in-progress` to re-open a session or `closed` to close a session.
@param [Boolean] fail_on_participant_conflict [Experimental] For accounts with
the ProxyAllowParticipantConflict account flag, setting to true enables per-request opt-in to allowing Proxy to return a 400 error (Twilio error code 80604) when a request to set a Session to in-progress would cause Participants with the same Identifier/ProxyIdentifier pair to be active in multiple Sessions. If not provided, requests will be allowed to succeed, and a Debugger notification (80801) will be emitted. Having multiple, active Participants with the same Identifier/ProxyIdentifier pair causes calls and messages from affected Participants to be routed incorrectly. Please note, the default behavior for accounts without the ProxyAllowParticipantConflict flag is to reject the request as described. This will eventually be the default for all accounts.
@return [SessionInstance] Updated SessionInstance
# File lib/twilio-ruby/rest/proxy/v1/service/session.rb 258 def update(date_expiry: :unset, ttl: :unset, status: :unset, fail_on_participant_conflict: :unset) 259 data = Twilio::Values.of({ 260 'DateExpiry' => Twilio.serialize_iso8601_datetime(date_expiry), 261 'Ttl' => ttl, 262 'Status' => status, 263 'FailOnParticipantConflict' => fail_on_participant_conflict, 264 }) 265 266 payload = @version.update('POST', @uri, data: data) 267 268 SessionInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) 269 end