Class: Twilio::REST::Autopilot::V1::AssistantContext::QueryContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/autopilot/v1/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, assistant_sid, sid) ⇒ QueryContext

Initialize the QueryContext

Parameters:

  • version (Version)

    Version that contains the resource

  • assistant_sid (String)

    The SID of the [Assistant](www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource to fetch.

  • sid (String)

    The Twilio-provided string that uniquely identifies the Query resource to fetch.



227
228
229
230
231
232
233
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb', line 227

def initialize(version, assistant_sid, sid)
  super(version)

  # Path Solution
  @solution = {assistant_sid: assistant_sid, sid: sid, }
  @uri = "/Assistants/#{@solution[:assistant_sid]}/Queries/#{@solution[:sid]}"
end

Instance Method Details

#deleteBoolean

Deletes the QueryInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



273
274
275
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb', line 273

def delete
  @version.delete('delete', @uri)
end

#fetchQueryInstance

Fetch a QueryInstance

Returns:



238
239
240
241
242
243
244
245
246
247
248
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb', line 238

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  QueryInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], sid: @solution[:sid], )
end

#inspectObject

Provide a detailed, user friendly representation



286
287
288
289
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb', line 286

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Autopilot.V1.QueryContext #{context}>"
end

#to_sObject

Provide a user friendly representation



279
280
281
282
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb', line 279

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Autopilot.V1.QueryContext #{context}>"
end

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

Update the QueryInstance

Parameters:

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

    The SID of an optional reference to the [Sample](www.twilio.com/docs/autopilot/api/task-sample) created from the query.

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

    The new status of the resource. Can be: ‘pending_review`, `reviewed`, or `discarded`

Returns:



258
259
260
261
262
263
264
265
266
267
268
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb', line 258

def update(sample_sid: :unset, status: :unset)
  data = Twilio::Values.of({'SampleSid' => sample_sid, 'Status' => status, })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  QueryInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], sid: @solution[:sid], )
end