Class: Twilio::REST::Proxy::V1::ServiceContext::SessionInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/proxy/v1/service/session.rb

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, sid: nil) ⇒ SessionInstance

Initialize the SessionInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • service_sid (String) (defaults to: nil)

    The SID of the [Service](www.twilio.com/docs/proxy/api/service) the session is associated with.

  • sid (String) (defaults to: nil)

    The Twilio-provided string that uniquely identifies the Session resource to fetch.



335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 335

def initialize(version, payload, service_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'service_sid' => payload['service_sid'],
      'account_sid' => payload['account_sid'],
      'date_started' => Twilio.deserialize_iso8601_datetime(payload['date_started']),
      'date_ended' => Twilio.deserialize_iso8601_datetime(payload['date_ended']),
      'date_last_interaction' => Twilio.deserialize_iso8601_datetime(payload['date_last_interaction']),
      'date_expiry' => Twilio.deserialize_iso8601_datetime(payload['date_expiry']),
      'unique_name' => payload['unique_name'],
      'status' => payload['status'],
      'closed_reason' => payload['closed_reason'],
      'ttl' => payload['ttl'].to_i,
      'mode' => payload['mode'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
      'links' => payload['links'],
  }

  # Context
  @instance_context = nil
  @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sidString

Returns The SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource



388
389
390
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 388

def 
  @properties['account_sid']
end

#closed_reasonString

Returns The reason the Session ended.

Returns:

  • (String)

    The reason the Session ended



430
431
432
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 430

def closed_reason
  @properties['closed_reason']
end

#contextSessionContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



367
368
369
370
371
372
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 367

def context
  unless @instance_context
    @instance_context = SessionContext.new(@version, @params['service_sid'], @params['sid'], )
  end
  @instance_context
end

#date_createdTime

Returns The ISO 8601 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was created



448
449
450
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 448

def date_created
  @properties['date_created']
end

#date_endedTime

Returns The ISO 8601 date when the Session ended.

Returns:

  • (Time)

    The ISO 8601 date when the Session ended



400
401
402
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 400

def date_ended
  @properties['date_ended']
end

#date_expiryTime

Returns The ISO 8601 date when the Session should expire.

Returns:

  • (Time)

    The ISO 8601 date when the Session should expire



412
413
414
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 412

def date_expiry
  @properties['date_expiry']
end

#date_last_interactionTime

Returns The ISO 8601 date when the Session last had an interaction.

Returns:

  • (Time)

    The ISO 8601 date when the Session last had an interaction



406
407
408
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 406

def date_last_interaction
  @properties['date_last_interaction']
end

#date_startedTime

Returns The ISO 8601 date when the Session started.

Returns:

  • (Time)

    The ISO 8601 date when the Session started



394
395
396
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 394

def date_started
  @properties['date_started']
end

#date_updatedTime

Returns The ISO 8601 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was last updated



454
455
456
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 454

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the SessionInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



480
481
482
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 480

def delete
  context.delete
end

#fetchSessionInstance

Fetch a SessionInstance

Returns:



473
474
475
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 473

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



521
522
523
524
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 521

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Proxy.V1.SessionInstance #{values}>"
end

#interactionsinteractions

Access the interactions

Returns:



501
502
503
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 501

def interactions
  context.interactions
end

Returns The URLs of resources related to the Session.

Returns:

  • (String)

    The URLs of resources related to the Session



466
467
468
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 466

def links
  @properties['links']
end

#modesession.Mode

Returns The Mode of the Session.

Returns:

  • (session.Mode)

    The Mode of the Session



442
443
444
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 442

def mode
  @properties['mode']
end

#participantsparticipants

Access the participants

Returns:



508
509
510
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 508

def participants
  context.participants
end

#service_sidString

Returns The SID of the resource’s parent Service.

Returns:

  • (String)

    The SID of the resource’s parent Service



382
383
384
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 382

def service_sid
  @properties['service_sid']
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource



376
377
378
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 376

def sid
  @properties['sid']
end

#statussession.Status

Returns The status of the Session.

Returns:

  • (session.Status)

    The status of the Session



424
425
426
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 424

def status
  @properties['status']
end

#to_sObject

Provide a user friendly representation



514
515
516
517
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 514

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Proxy.V1.SessionInstance #{values}>"
end

#ttlString

Returns When the session will expire.

Returns:

  • (String)

    When the session will expire



436
437
438
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 436

def ttl
  @properties['ttl']
end

#unique_nameString

Returns An application-defined string that uniquely identifies the resource.

Returns:

  • (String)

    An application-defined string that uniquely identifies the resource



418
419
420
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 418

def unique_name
  @properties['unique_name']
end

#update(date_expiry: :unset, ttl: :unset, status: :unset) ⇒ SessionInstance

Update the SessionInstance

Parameters:

  • date_expiry (Time) (defaults to: :unset)

    The [ISO 8601](en.wikipedia.org/wiki/ISO_8601) date when the Session should expire. If this is value is present, it overrides the ‘ttl` value.

  • ttl (String) (defaults to: :unset)

    The time, in seconds, when the session will expire. The time is measured from the last Session create or the Session’s last Interaction.

  • status (session.Status) (defaults to: :unset)

    The new status of the resource. Can be: ‘in-progress` to re-open a session or `closed` to close a session.

Returns:



494
495
496
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 494

def update(date_expiry: :unset, ttl: :unset, status: :unset)
  context.update(date_expiry: date_expiry, ttl: ttl, status: status, )
end

#urlString

Returns The absolute URL of the Session resource.

Returns:

  • (String)

    The absolute URL of the Session resource



460
461
462
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 460

def url
  @properties['url']
end