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)

    A 34 character string that uniquely identifies this resource.



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

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 unique id of the Account responsible for this session.

Returns:

  • (String)

    The unique id of the Account responsible for this session.



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

def 
  @properties['account_sid']
end

#attributesString

Returns An optional string metadata field you can use to store any data you wish.

Returns:

  • (String)

    An optional string metadata field you can use to store any data you wish.



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

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:



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

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

#created_byString

Returns Identity of the session’s creator.

Returns:

  • (String)

    Identity of the session’s creator.



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

def created_by
  @properties['created_by']
end

#date_createdTime

Returns The date that this resource was created.

Returns:

  • (Time)

    The date that this resource was created.



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

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date that this resource was last updated.

Returns:

  • (Time)

    The date that this resource was last updated.



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

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the SessionInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



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

def delete
  context.delete
end

#fetchSessionInstance

Fetch a SessionInstance

Returns:



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

def fetch
  context.fetch
end

#friendly_nameString

Returns The human-readable name of this session.

Returns:

  • (String)

    The human-readable name of this session.



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

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



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

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

Returns Absolute URLs to access the Participants and Messages for this Session.

Returns:

  • (String)

    Absolute URLs to access the Participants and Messages for this Session.



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

def links
  @properties['links']
end

#messagesmessages

Access the messages

Returns:



481
482
483
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 481

def messages
  context.messages
end

#messaging_service_sidString

Returns The unique id of the SMS Service this session belongs to.

Returns:

  • (String)

    The unique id of the SMS Service this session belongs to.



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

def messaging_service_sid
  @properties['messaging_service_sid']
end

#participantsparticipants

Access the participants

Returns:



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

def participants
  context.participants
end

#service_sidString

Returns The unique id of the Chat Service this session belongs to.

Returns:

  • (String)

    The unique id of the Chat Service this session belongs to.



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

def service_sid
  @properties['service_sid']
end

#sidString

Returns A 34 character string that uniquely identifies this resource.

Returns:

  • (String)

    A 34 character string that uniquely identifies this resource.



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

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



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

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)

    The human-readable name of this session. Optional.

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

    An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set “{}” will be returned.

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

    The date that this resource was created.

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

    The date that this resource was last updated.

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

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

Returns:



461
462
463
464
465
466
467
468
469
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 461

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 An absolute URL for this session.

Returns:

  • (String)

    An absolute URL for this session.



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

def url
  @properties['url']
end

#webhookswebhooks

Access the webhooks

Returns:



488
489
490
# File 'lib/twilio-ruby/rest/messaging/v1/session.rb', line 488

def webhooks
  context.webhooks
end