Class: Twilio::REST::Assistants::V1::SessionInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, id: 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)

    The SID of the Call resource to fetch.



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 230

def initialize(version, payload , id: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'id' => payload['id'],
        'account_sid' => payload['account_sid'],
        'assistant_id' => payload['assistant_id'],
        'verified' => payload['verified'],
        'identity' => payload['identity'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
    }

    # Context
    @instance_context = nil
    @params = { 'id' => id  || @properties['id']  , }
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:



268
269
270
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 268

def 
    @properties['account_sid']
end

#assistant_idString

Returns The Assistant ID.

Returns:

  • (String)

    The Assistant ID.



274
275
276
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 274

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



253
254
255
256
257
258
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 253

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

#date_createdTime

Returns The date and time in GMT when the Session was created specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



292
293
294
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 292

def date_created
    @properties['date_created']
end

#date_updatedTime

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

Returns:



298
299
300
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 298

def date_updated
    @properties['date_updated']
end

#fetchSessionInstance

Fetch the SessionInstance

Returns:



305
306
307
308
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 305

def fetch

    context.fetch
end

#idString

Returns The Session ID.

Returns:

  • (String)

    The Session ID.



262
263
264
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 262

def id
    @properties['id']
end

#identityString

Returns The unique identity of user for the session.

Returns:

  • (String)

    The unique identity of user for the session.



286
287
288
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 286

def identity
    @properties['identity']
end

#inspectObject

Provide a detailed, user friendly representation



326
327
328
329
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 326

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

#messagesmessages

Access the messages

Returns:



313
314
315
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 313

def messages
    context.messages
end

#to_sObject

Provide a user friendly representation



319
320
321
322
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 319

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

#verifiedBoolean

Returns True if the session is verified.

Returns:

  • (Boolean)

    True if the session is verified.



280
281
282
# File 'lib/twilio-ruby/rest/assistants/v1/session.rb', line 280

def verified
    @properties['verified']
end