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.



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

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.



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

def 
  @properties['account_sid']
end

#closed_reasonString

Returns Reason Session ended.

Returns:

  • (String)

    Reason Session ended.



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

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:



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

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



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

def date_created
  @properties['date_created']
end

#date_endedTime

Returns The date this Session was ended.

Returns:

  • (Time)

    The date this Session was ended



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

def date_ended
  @properties['date_ended']
end

#date_expiryTime

Returns The date this Session was expiry.

Returns:

  • (Time)

    The date this Session was expiry



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

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



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

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



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

def date_started
  @properties['date_started']
end

#date_updatedTime

Returns The date this Session was updated.

Returns:

  • (Time)

    The date this Session was updated



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

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the SessionInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



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

def delete
  context.delete
end

#fetchSessionInstance

Fetch a SessionInstance

Returns:



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

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#interactionsinteractions

Access the interactions

Returns:



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

def interactions
  context.interactions
end

Returns Nested resource URLs.

Returns:

  • (String)

    Nested resource URLs.



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

def links
  @properties['links']
end

#modesession.Mode

Returns The Mode of this Session.

Returns:

  • (session.Mode)

    The Mode of this Session



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

def mode
  @properties['mode']
end

#participantsparticipants

Access the participants

Returns:



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

def participants
  context.participants
end

#service_sidString

Returns Service Sid.

Returns:

  • (String)

    Service Sid.



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

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.



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

def sid
  @properties['sid']
end

#statussession.Status

Returns The Status of this Session.

Returns:

  • (session.Status)

    The Status of this Session



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

def status
  @properties['status']
end

#to_sObject

Provide a user friendly representation



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

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.



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

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.



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

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)

    The unique_name

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

    The date that this Session should be expired, given in ISO 8601 format.

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

    The time delay, in seconds, after which a session will be expired. Keyed off of last interaction time.

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

    The mode

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

    The Status of this Session. Set ‘in-progress` to re-open a session, `closed` to close a session.

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

    The participants

Returns:



495
496
497
498
499
500
501
502
503
504
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 495

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.



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

def url
  @properties['url']
end