Class: Twilio::REST::Preview::Understand::AssistantContext::QueryContext

Inherits:
InstanceContext
  • 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, assistant_sid, sid) ⇒ QueryContext

Initialize the QueryContext

Parameters:

  • version (Version)

    Version that contains the resource

  • assistant_sid (String)

    The unique ID of the parent Assistant.

  • sid (String)

    A 34 character string that uniquely identifies this resource.



187
188
189
190
191
192
193
194
195
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 187

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

Delete the QueryInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



199
200
201
202
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 199

def delete

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

#fetchQueryInstance

Fetch the QueryInstance

Returns:



207
208
209
210
211
212
213
214
215
216
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 207

def fetch

    payload = @version.fetch('GET', @uri)
    QueryInstance.new(
        @version,
        payload,
        assistant_sid: @solution[:assistant_sid],
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



252
253
254
255
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 252

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

#to_sObject

Provide a user friendly representation



245
246
247
248
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 245

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Preview.Understand.QueryContext #{context}>"
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:



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/twilio-ruby/rest/preview/understand/assistant/query.rb', line 223

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