Class: Twilio::REST::Preview::Understand::AssistantContext::QueryInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/understand/assistant/query.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, assistant_sid: nil, sid: nil) ⇒ QueryInstance

Initialize the QueryInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • assistant_sid (String) (defaults to: nil)

    The unique ID of the parent Assistant.

  • sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this resource.



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 297

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

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'results' => payload['results'],
      'language' => payload['language'],
      'model_build_sid' => payload['model_build_sid'],
      'query' => payload['query'],
      'sample_sid' => payload['sample_sid'],
      'assistant_sid' => payload['assistant_sid'],
      'sid' => payload['sid'],
      'status' => payload['status'],
      'url' => payload['url'],
      'source_channel' => payload['source_channel'],
  }

  # Context
  @instance_context = nil
  @params = {'assistant_sid' => assistant_sid, 'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sidString

Returns The unique ID of the Account that created this Query.

Returns:

  • (String)

    The unique ID of the Account that created this Query.



335
336
337
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 335

def 
  @properties['account_sid']
end

#assistant_sidString

Returns The unique ID of the parent Assistant.

Returns:

  • (String)

    The unique ID of the parent Assistant.



383
384
385
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 383

def assistant_sid
  @properties['assistant_sid']
end

#contextQueryContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



326
327
328
329
330
331
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 326

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

#date_createdTime

Returns The date that this resource was created.

Returns:

  • (Time)

    The date that this resource was created



341
342
343
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 341

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



347
348
349
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 347

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the QueryInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



432
433
434
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 432

def delete
  context.delete
end

#fetchQueryInstance

Fetch a QueryInstance

Returns:



414
415
416
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 414

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



445
446
447
448
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 445

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

#languageString

Returns An ISO language-country string of the sample.

Returns:

  • (String)

    An ISO language-country string of the sample.



359
360
361
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 359

def language
  @properties['language']
end

#model_build_sidString

Returns The unique ID of the Model Build queried.

Returns:

  • (String)

    The unique ID of the Model Build queried.



365
366
367
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 365

def model_build_sid
  @properties['model_build_sid']
end

#queryString

Returns The end-user’s natural language input.

Returns:

  • (String)

    The end-user’s natural language input.



371
372
373
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 371

def query
  @properties['query']
end

#resultsHash

Returns The natural language analysis results which include the Task recognized, the confidence score and a list of identified Fields.

Returns:

  • (Hash)

    The natural language analysis results which include the Task recognized, the confidence score and a list of identified Fields.



353
354
355
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 353

def results
  @properties['results']
end

#sample_sidString

Returns An optional reference to the Sample created from this query.

Returns:

  • (String)

    An optional reference to the Sample created from this query.



377
378
379
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 377

def sample_sid
  @properties['sample_sid']
end

#sidString

Returns A 34 character string that uniquely identifies this resource.

Returns:

  • (String)

    A 34 character string that uniquely identifies this resource.



389
390
391
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 389

def sid
  @properties['sid']
end

#source_channelString

Returns The communication channel where this end-user input came from.

Returns:

  • (String)

    The communication channel where this end-user input came from



407
408
409
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 407

def source_channel
  @properties['source_channel']
end

#statusString

Returns A string that described the query status. The values can be: pending_review, reviewed, discarded.

Returns:

  • (String)

    A string that described the query status. The values can be: pending_review, reviewed, discarded



395
396
397
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 395

def status
  @properties['status']
end

#to_sObject

Provide a user friendly representation



438
439
440
441
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 438

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

#update(sample_sid: :unset, status: :unset) ⇒ QueryInstance

Update the QueryInstance

Parameters:

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

    An optional reference to the Sample created from this query.

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

    A string that described the query status. The values can be: pending_review, reviewed, discarded

Returns:



425
426
427
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 425

def update(sample_sid: :unset, status: :unset)
  context.update(sample_sid: sample_sid, status: status, )
end

#urlString

Returns The url.

Returns:

  • (String)

    The url



401
402
403
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 401

def url
  @properties['url']
end