Class: Twilio::REST::Preview::Understand::AssistantContext::TaskContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/understand/assistant/task.rb,
lib/twilio-ruby/rest/preview/understand/assistant/task/field.rb,
lib/twilio-ruby/rest/preview/understand/assistant/task/sample.rb,
lib/twilio-ruby/rest/preview/understand/assistant/task/task_actions.rb,
lib/twilio-ruby/rest/preview/understand/assistant/task/task_statistics.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]

Defined Under Namespace

Classes: FieldContext, FieldInstance, FieldList, FieldPage, SampleContext, SampleInstance, SampleList, SamplePage, TaskActionsContext, TaskActionsInstance, TaskActionsList, TaskActionsPage, TaskStatisticsContext, TaskStatisticsInstance, TaskStatisticsList, TaskStatisticsPage

Instance Method Summary collapse

Constructor Details

#initialize(version, assistant_sid, sid) ⇒ TaskContext

Initialize the TaskContext

Parameters:

  • version (Version)

    Version that contains the resource

  • assistant_sid (String)

    The unique ID of the Assistant.

  • sid (String)

    A 34 character string that uniquely identifies this resource.


182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task.rb', line 182

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

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

  # Dependents
  @fields = nil
  @samples = nil
  @task_actions = nil
  @statistics = nil
end

Instance Method Details

#deleteBoolean

Delete the TaskInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


232
233
234
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task.rb', line 232

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

#fetchTaskInstance

Fetch the TaskInstance

Returns:


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

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

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

#fields(sid = :unset) ⇒ FieldList, FieldContext

Access the fields

Returns:

Raises:

  • (ArgumentError)

240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task.rb', line 240

def fields(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return FieldContext.new(@version, @solution[:assistant_sid], @solution[:sid], sid, )
  end

  unless @fields
    @fields = FieldList.new(
        @version,
        assistant_sid: @solution[:assistant_sid],
        task_sid: @solution[:sid],
    )
  end

  @fields
end

#inspectObject

Provide a detailed, user friendly representation


305
306
307
308
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task.rb', line 305

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

#samples(sid = :unset) ⇒ SampleList, SampleContext

Access the samples

Returns:

Raises:

  • (ArgumentError)

262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task.rb', line 262

def samples(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return SampleContext.new(@version, @solution[:assistant_sid], @solution[:sid], sid, )
  end

  unless @samples
    @samples = SampleList.new(
        @version,
        assistant_sid: @solution[:assistant_sid],
        task_sid: @solution[:sid],
    )
  end

  @samples
end

#statisticsTaskStatisticsList, TaskStatisticsContext

Access the statistics


292
293
294
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task.rb', line 292

def statistics
  TaskStatisticsContext.new(@version, @solution[:assistant_sid], @solution[:sid], )
end

#task_actionsTaskActionsList, TaskActionsContext

Access the task_actions


284
285
286
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task.rb', line 284

def task_actions
  TaskActionsContext.new(@version, @solution[:assistant_sid], @solution[:sid], )
end

#to_sObject

Provide a user friendly representation


298
299
300
301
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task.rb', line 298

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

#update(friendly_name: :unset, unique_name: :unset, actions: :unset, actions_url: :unset) ⇒ TaskInstance

Update the TaskInstance

Parameters:

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

    A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.

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

    A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.

  • actions (Hash) (defaults to: :unset)

    A user-provided JSON object encoded as a string to specify the actions for this task. It is optional and non-unique.

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

    User-provided HTTP endpoint where from the assistant fetches actions

Returns:


216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task.rb', line 216

def update(friendly_name: :unset, unique_name: :unset, actions: :unset, actions_url: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'UniqueName' => unique_name,
      'Actions' => Twilio.serialize_object(actions),
      'ActionsUrl' => actions_url,
  })

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

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