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 unique SID identifier of the Service.

  • sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this Session.



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
362
363
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 337

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 Account Sid.

Returns:

  • (String)

    Account Sid.



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

def 
  @properties['account_sid']
end

#closed_reasonString

Returns Reason Session ended.

Returns:

  • (String)

    Reason Session ended.



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

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:



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

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

#date_createdTime

Returns The date this Session was created.

Returns:

  • (Time)

    The date this Session was created



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

def date_created
  @properties['date_created']
end

#date_endedTime

Returns The date this Session was ended.

Returns:

  • (Time)

    The date this Session was ended



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

def date_ended
  @properties['date_ended']
end

#date_expiryTime

Returns The date this Session was expiry.

Returns:

  • (Time)

    The date this Session was expiry



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

def date_expiry
  @properties['date_expiry']
end

#date_last_interactionTime

Returns The date this Session was interaction.

Returns:

  • (Time)

    The date this Session was interaction



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

def date_last_interaction
  @properties['date_last_interaction']
end

#date_startedTime

Returns The date this Session was started.

Returns:

  • (Time)

    The date this Session was started



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

def date_started
  @properties['date_started']
end

#date_updatedTime

Returns The date this Session was updated.

Returns:

  • (Time)

    The date this Session was updated



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

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the SessionInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



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

def delete
  context.delete
end

#fetchSessionInstance

Fetch a SessionInstance

Returns:



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

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



534
535
536
537
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 534

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

#interactionsinteractions

Access the interactions

Returns:



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

def interactions
  context.interactions
end

Returns Nested resource URLs.

Returns:

  • (String)

    Nested resource URLs.



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

def links
  @properties['links']
end

#modesession.Mode

Returns The Mode of this Session.

Returns:

  • (session.Mode)

    The Mode of this Session



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

def mode
  @properties['mode']
end

#participantsparticipants

Access the participants

Returns:



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

def participants
  context.participants
end

#service_sidString

Returns Service Sid.

Returns:

  • (String)

    Service Sid.



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

def service_sid
  @properties['service_sid']
end

#sidString

Returns A string that uniquely identifies this Session.

Returns:

  • (String)

    A string that uniquely identifies this Session.



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

def sid
  @properties['sid']
end

#statussession.Status

Returns The Status of this Session.

Returns:

  • (session.Status)

    The Status of this Session



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

def status
  @properties['status']
end

#to_sObject

Provide a user friendly representation



527
528
529
530
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 527

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

#ttlString

Returns TTL for a Session, in seconds.

Returns:

  • (String)

    TTL for a Session, in seconds.



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

def ttl
  @properties['ttl']
end

#unique_nameString

Returns A unique, developer assigned name of this Session.

Returns:

  • (String)

    A unique, developer assigned name of this Session.



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

def unique_name
  @properties['unique_name']
end

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

Update the SessionInstance

Parameters:

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

    Provides a unique and addressable name to be assigned to this Session, assigned by the developer, to be optionally used in addition to SID.

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

    The date that this Session was expiry, given in ISO 8601 format.

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

    The Time to Live for a Session, in seconds.

  • mode (session.Mode) (defaults to: :unset)

    The Mode of this Session. One of ‘message-only`, `voice-only` or `voice-and-message`.

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

    The Status of this Session. One of ‘in-progress`, `closed`, `failed`, `unknown` or `completed`.

  • participants (Hash) (defaults to: :unset)

    A list of phone numbers to add to this Session.

Returns:



500
501
502
503
504
505
506
507
508
509
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 500

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

#urlString

Returns The URL of this resource.

Returns:

  • (String)

    The URL of this resource.



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

def url
  @properties['url']
end