Class: Twilio::REST::Messaging::V1::SessionInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/messaging/v1/session.rb

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Instance Method Summary collapse

Constructor Details

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

Initialize the SessionInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • sid (String) (defaults to: nil)

    The SID of the Session resource to fetch.



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

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

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'account_sid' => payload['account_sid'],
      'service_sid' => payload['service_sid'],
      'messaging_service_sid' => payload['messaging_service_sid'],
      'friendly_name' => payload['friendly_name'],
      'attributes' => payload['attributes'],
      'created_by' => payload['created_by'],
      '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 = {'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



379
380
381
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 379

def 
  @properties['account_sid']
end

#attributesString

Returns The JSON string that stores application-specific data.

Returns:

  • (String)

    The JSON string that stores application-specific data



403
404
405
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 403

def attributes
  @properties['attributes']
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:



364
365
366
367
368
369
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 364

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

#created_byString

Returns The Identity of the session’s creator.

Returns:

  • (String)

    The Identity of the session’s creator



409
410
411
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 409

def created_by
  @properties['created_by']
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



415
416
417
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 415

def date_created
  @properties['date_created']
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



421
422
423
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 421

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the SessionInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



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

def delete
  context.delete
end

#fetchSessionInstance

Fetch a SessionInstance

Returns:



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

def fetch
  context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the resource.

Returns:

  • (String)

    The string that you assigned to describe the resource



397
398
399
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 397

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



505
506
507
508
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 505

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

Returns The absolute URLs of the Participants, Interactions, and Messages for the Session.

Returns:

  • (String)

    The absolute URLs of the Participants, Interactions, and Messages for the Session



433
434
435
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 433

def links
  @properties['links']
end

#messagesmessages

Access the messages

Returns:



485
486
487
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 485

def messages
  context.messages
end

#messaging_service_sidString

Returns The SID of the SMS Service the session belongs to.

Returns:

  • (String)

    The SID of the SMS Service the session belongs to



391
392
393
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 391

def messaging_service_sid
  @properties['messaging_service_sid']
end

#participantsparticipants

Access the participants

Returns:



478
479
480
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 478

def participants
  context.participants
end

#service_sidString

Returns The SID of the Service that the resource is associated with.

Returns:

  • (String)

    The SID of the Service that the resource is associated with



385
386
387
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 385

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



373
374
375
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 373

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



498
499
500
501
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 498

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

#update(friendly_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset) ⇒ SessionInstance

Update the SessionInstance

Parameters:

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

    A descriptive string that you create to describe the resource. It can be up to 64 characters long.

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

    A JSON string that stores application-specific data.

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

    The date, specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created.

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

    The date, specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated.

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

    The Identity of the session’s creator. If the Session was created through the API, the value will be system

Returns:



465
466
467
468
469
470
471
472
473
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 465

def update(friendly_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset)
  context.update(
      friendly_name: friendly_name,
      attributes: attributes,
      date_created: date_created,
      date_updated: date_updated,
      created_by: created_by,
  )
end

#urlString

Returns The absolute URL of the session.

Returns:

  • (String)

    The absolute URL of the session



427
428
429
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 427

def url
  @properties['url']
end

#webhookswebhooks

Access the webhooks

Returns:



492
493
494
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 492

def webhooks
  context.webhooks
end