Class: Twilio::REST::Autopilot::V1::AssistantContext::TaskContext::SampleContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.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, task_sid, sid) ⇒ SampleContext

Initialize the SampleContext

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 Task associated with the resource to fetch.

  • task_sid (String)

    The SID of the [Task](www.twilio.com/docs/autopilot/api/task) associated with the Sample resource to create.

  • sid (String)

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



216
217
218
219
220
221
222
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.rb', line 216

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

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

Instance Method Details

#deleteBoolean

Deletes the SampleInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



281
282
283
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.rb', line 281

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

#fetchSampleInstance

Fetch a SampleInstance

Returns:



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.rb', line 227

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

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

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

#inspectObject

Provide a detailed, user friendly representation



294
295
296
297
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.rb', line 294

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

#to_sObject

Provide a user friendly representation



287
288
289
290
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.rb', line 287

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

#update(language: :unset, tagged_text: :unset, source_channel: :unset) ⇒ SampleInstance

Update the SampleInstance

Parameters:

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

    The [ISO language-country](docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html) string that specifies the language used for the sample. For example: ‘en-US`.

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

    The text example of how end users might express the task. The sample can contain [Field tag blocks](www.twilio.com/docs/autopilot/api/task-sample#field-tagging).

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

    The communication channel from which the sample was captured. Can be: ‘voice`, `sms`, `chat`, `alexa`, `google-assistant`, `slack`, or null if not included.

Returns:



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.rb', line 256

def update(language: :unset, tagged_text: :unset, source_channel: :unset)
  data = Twilio::Values.of({
      'Language' => language,
      'TaggedText' => tagged_text,
      'SourceChannel' => source_channel,
  })

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

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