Class: Twilio::REST::Proxy::V1::ServiceContext::SessionContext
- Inherits:
-
InstanceContext
- Object
- InstanceContext
- Twilio::REST::Proxy::V1::ServiceContext::SessionContext
- Defined in:
- lib/twilio-ruby/rest/proxy/v1/service/session.rb,
lib/twilio-ruby/rest/proxy/v1/service/session/interaction.rb,
lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb,
lib/twilio-ruby/rest/proxy/v1/service/session/participant/message_interaction.rb
Defined Under Namespace
Classes: InteractionContext, InteractionInstance, InteractionList, InteractionPage, ParticipantContext, ParticipantInstance, ParticipantList, ParticipantPage
Instance Method Summary collapse
-
#delete ⇒ Boolean
Delete the SessionInstance.
-
#fetch ⇒ SessionInstance
Fetch the SessionInstance.
-
#initialize(version, service_sid, sid) ⇒ SessionContext
constructor
Initialize the SessionContext.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#interactions(sid = :unset) ⇒ InteractionList, InteractionContext
Access the interactions.
-
#participants(sid = :unset) ⇒ ParticipantList, ParticipantContext
Access the participants.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#update(date_expiry: :unset, ttl: :unset, status: :unset) ⇒ SessionInstance
Update the SessionInstance.
Constructor Details
#initialize(version, service_sid, sid) ⇒ SessionContext
Initialize the SessionContext
180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 180 def initialize(version, service_sid, sid) super(version) # Path Solution @solution = { service_sid: service_sid, sid: sid, } @uri = "/Services/#{@solution[:service_sid]}/Sessions/#{@solution[:sid]}" # Dependents @interactions = nil @participants = nil end |
Instance Method Details
#delete ⇒ Boolean
Delete the SessionInstance
194 195 196 197 198 199 200 201 |
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 194 def delete headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) @version.delete('DELETE', @uri, headers: headers) end |
#fetch ⇒ SessionInstance
Fetch the SessionInstance
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 206 def fetch headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) payload = @version.fetch('GET', @uri, headers: headers) SessionInstance.new( @version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end |
#inspect ⇒ Object
Provide a detailed, user friendly representation
304 305 306 307 |
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 304 def inspect context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Proxy.V1.SessionContext #{context}>" end |
#interactions(sid = :unset) ⇒ InteractionList, InteractionContext
Access the interactions
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 260 def interactions(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return InteractionContext.new(@version, @solution[:service_sid], @solution[:sid],sid ) end unless @interactions @interactions = InteractionList.new( @version, service_sid: @solution[:service_sid], session_sid: @solution[:sid], ) end @interactions end |
#participants(sid = :unset) ⇒ ParticipantList, ParticipantContext
Access the participants
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 279 def participants(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return ParticipantContext.new(@version, @solution[:service_sid], @solution[:sid],sid ) end unless @participants @participants = ParticipantList.new( @version, service_sid: @solution[:service_sid], session_sid: @solution[:sid], ) end @participants end |
#to_s ⇒ Object
Provide a user friendly representation
297 298 299 300 |
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 297 def to_s context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Proxy.V1.SessionContext #{context}>" end |
#update(date_expiry: :unset, ttl: :unset, status: :unset) ⇒ SessionInstance
Update the SessionInstance
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/proxy/v1/service/session.rb', line 229 def update( date_expiry: :unset, ttl: :unset, status: :unset ) data = Twilio::Values.of({ 'DateExpiry' => Twilio.serialize_iso8601_datetime(date_expiry), 'Ttl' => ttl, 'Status' => status, }) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) payload = @version.update('POST', @uri, data: data, headers: headers) SessionInstance.new( @version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end |