class Twilio::REST::Autopilot::V1::AssistantContext::TaskContext
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 help@twilio.com.
Public Class Methods
Initialize the TaskContext
@param [Version] version Version
that contains the resource @param [String] assistant_sid The SID of the
{Assistant}[https://www.twilio.com/docs/autopilot/api/assistant] that is the parent of the resource to fetch.
@param [String] sid The Twilio-provided string that uniquely identifies the Task
resource to fetch.
@return [TaskContext] TaskContext
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task.rb 188 def initialize(version, assistant_sid, sid) 189 super(version) 190 191 # Path Solution 192 @solution = {assistant_sid: assistant_sid, sid: sid, } 193 @uri = "/Assistants/#{@solution[:assistant_sid]}/Tasks/#{@solution[:sid]}" 194 195 # Dependents 196 @fields = nil 197 @samples = nil 198 @task_actions = nil 199 @statistics = nil 200 end
Public Instance Methods
Delete the TaskInstance
@return [Boolean] true if delete succeeds, false otherwise
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task.rb 240 def delete 241 @version.delete('DELETE', @uri) 242 end
Fetch the TaskInstance
@return [TaskInstance] Fetched TaskInstance
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task.rb 205 def fetch 206 payload = @version.fetch('GET', @uri) 207 208 TaskInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], sid: @solution[:sid], ) 209 end
Access the fields @return [FieldList] @return [FieldContext] if sid was passed.
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task.rb 248 def fields(sid=:unset) 249 raise ArgumentError, 'sid cannot be nil' if sid.nil? 250 251 if sid != :unset 252 return FieldContext.new(@version, @solution[:assistant_sid], @solution[:sid], sid, ) 253 end 254 255 unless @fields 256 @fields = FieldList.new( 257 @version, 258 assistant_sid: @solution[:assistant_sid], 259 task_sid: @solution[:sid], 260 ) 261 end 262 263 @fields 264 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task.rb 313 def inspect 314 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 315 "#<Twilio.Autopilot.V1.TaskContext #{context}>" 316 end
Access the samples @return [SampleList] @return [SampleContext] if sid was passed.
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task.rb 270 def samples(sid=:unset) 271 raise ArgumentError, 'sid cannot be nil' if sid.nil? 272 273 if sid != :unset 274 return SampleContext.new(@version, @solution[:assistant_sid], @solution[:sid], sid, ) 275 end 276 277 unless @samples 278 @samples = SampleList.new( 279 @version, 280 assistant_sid: @solution[:assistant_sid], 281 task_sid: @solution[:sid], 282 ) 283 end 284 285 @samples 286 end
Access the statistics @return [TaskStatisticsList] @return [TaskStatisticsContext]
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task.rb 300 def statistics 301 TaskStatisticsContext.new(@version, @solution[:assistant_sid], @solution[:sid], ) 302 end
Access the task_actions
@return [TaskActionsList] @return [TaskActionsContext]
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task.rb 292 def task_actions 293 TaskActionsContext.new(@version, @solution[:assistant_sid], @solution[:sid], ) 294 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task.rb 306 def to_s 307 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 308 "#<Twilio.Autopilot.V1.TaskContext #{context}>" 309 end
Update the TaskInstance
@param [String] friendly_name A descriptive string that you create to describe
the resource. It is not unique and can be up to 255 characters long.
@param [String] unique_name An application-defined string that uniquely
identifies the resource. This value must be 64 characters or less in length and be unique. It can be used as an alternative to the `sid` in the URL path to address the resource.
@param [Hash] actions The JSON string that specifies the
{actions}[https://www.twilio.com/docs/autopilot/actions] that instruct the Assistant on how to perform the task.
@param [String] actions_url The URL from which the Assistant can fetch actions. @return [TaskInstance] Updated TaskInstance
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task.rb 224 def update(friendly_name: :unset, unique_name: :unset, actions: :unset, actions_url: :unset) 225 data = Twilio::Values.of({ 226 'FriendlyName' => friendly_name, 227 'UniqueName' => unique_name, 228 'Actions' => Twilio.serialize_object(actions), 229 'ActionsUrl' => actions_url, 230 }) 231 232 payload = @version.update('POST', @uri, data: data) 233 234 TaskInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], sid: @solution[:sid], ) 235 end