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

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

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

  • account_sid (String)

    The SID of the Account that created this Session resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 327

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'] == nil ? payload['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  || @properties['service_sid']  ,'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Session resource.

Returns:



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

def 
    @properties['account_sid']
end

#closed_reasonString

Returns The reason the Session ended.

Returns:

  • (String)

    The reason the Session ended.



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

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:



359
360
361
362
363
364
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 359

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](en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was created.

Returns:



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

def date_created
    @properties['date_created']
end

#date_endedTime

Returns The [ISO 8601](en.wikipedia.org/wiki/ISO_8601) date when the Session ended.

Returns:



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

def date_ended
    @properties['date_ended']
end

#date_expiryTime

Returns 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.

Returns:

  • (Time)

    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.



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

def date_expiry
    @properties['date_expiry']
end

#date_last_interactionTime

Returns The [ISO 8601](en.wikipedia.org/wiki/ISO_8601) date when the Session last had an interaction.

Returns:



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

def date_last_interaction
    @properties['date_last_interaction']
end

#date_startedTime

Returns The [ISO 8601](en.wikipedia.org/wiki/ISO_8601) date when the Session started.

Returns:



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

def date_started
    @properties['date_started']
end

#date_updatedTime

Returns The [ISO 8601](en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the resource was last updated.

Returns:



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

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the SessionInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

def delete

    context.delete
end

#fetchSessionInstance

Fetch the SessionInstance

Returns:



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

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#interactionsinteractions

Access the interactions

Returns:



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

def interactions
    context.interactions
end

Returns The URLs of resources related to the Session.

Returns:

  • (Hash)

    The URLs of resources related to the Session.



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

def links
    @properties['links']
end

#modeMode

Returns:

  • (Mode)


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

def mode
    @properties['mode']
end

#participantsparticipants

Access the participants

Returns:



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

def participants
    context.participants
end

#service_sidString

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

Returns:



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

def service_sid
    @properties['service_sid']
end

#sidString

Returns The unique string that we created to identify the Session resource.

Returns:

  • (String)

    The unique string that we created to identify the Session resource.



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

def sid
    @properties['sid']
end

#statusStatus

Returns:

  • (Status)


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

def status
    @properties['status']
end

#to_sObject

Provide a user friendly representation



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

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

#ttlString

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

Returns:

  • (String)

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



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

def ttl
    @properties['ttl']
end

#unique_nameString

Returns An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. Supports UTF-8 characters. **This value should not have PII.**.

Returns:

  • (String)

    An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. Supports UTF-8 characters. **This value should not have PII.**



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

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 (Status) (defaults to: :unset)

Returns:



484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/twilio-ruby/rest/proxy/v1/service/session.rb', line 484

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.



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

def url
    @properties['url']
end