class Twilio::REST::Autopilot::V1::AssistantContext::TaskContext::FieldList
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 FieldList
@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 Task associated with the resource.
@param [String] task_sid The SID of the
{Task}[https://www.twilio.com/docs/autopilot/api/task] resource associated with this Field.
@return [FieldList] FieldList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task/field.rb 28 def initialize(version, assistant_sid: nil, task_sid: nil) 29 super(version) 30 31 # Path Solution 32 @solution = {assistant_sid: assistant_sid, task_sid: task_sid} 33 @uri = "/Assistants/#{@solution[:assistant_sid]}/Tasks/#{@solution[:task_sid]}/Fields" 34 end
Public Instance Methods
Create the FieldInstance
@param [String] field_type The Field Type of the new field. Can be: a {Built-in
Field Type}[https://www.twilio.com/docs/autopilot/built-in-field-types], the `unique_name`, or the `sid` of a custom Field Type.
@param [String] unique_name An application-defined string that uniquely
identifies the new resource. This value must be a unique string of no more than 64 characters. It can be used as an alternative to the `sid` in the URL path to address the resource.
@return [FieldInstance] Created FieldInstance
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task/field.rb 126 def create(field_type: nil, unique_name: nil) 127 data = Twilio::Values.of({'FieldType' => field_type, 'UniqueName' => unique_name, }) 128 129 payload = @version.create('POST', @uri, data: data) 130 131 FieldInstance.new( 132 @version, 133 payload, 134 assistant_sid: @solution[:assistant_sid], 135 task_sid: @solution[:task_sid], 136 ) 137 end
When passed a block, yields FieldInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task/field.rb 74 def each 75 limits = @version.read_limits 76 77 page = self.page(page_size: limits[:page_size], ) 78 79 @version.stream(page, 80 limit: limits[:limit], 81 page_limit: limits[:page_limit]).each {|x| yield x} 82 end
Retrieve a single page of FieldInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of FieldInstance
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task/field.rb 108 def get_page(target_url) 109 response = @version.domain.request( 110 'GET', 111 target_url 112 ) 113 FieldPage.new(@version, response, @solution) 114 end
Lists FieldInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Array] Array of up to limit results
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task/field.rb 47 def list(limit: nil, page_size: nil) 48 self.stream(limit: limit, page_size: page_size).entries 49 end
Retrieve a single page of FieldInstance
records from the API. Request
is executed immediately. @param [String] page_token PageToken provided by the API @param [Integer] page_number Page
Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page
of FieldInstance
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task/field.rb 91 def page(page_token: :unset, page_number: :unset, page_size: :unset) 92 params = Twilio::Values.of({ 93 'PageToken' => page_token, 94 'Page' => page_number, 95 'PageSize' => page_size, 96 }) 97 98 response = @version.page('GET', @uri, params: params) 99 100 FieldPage.new(@version, response, @solution) 101 end
Streams FieldInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit.
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Enumerable] Enumerable that will yield up to limit results
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task/field.rb 62 def stream(limit: nil, page_size: nil) 63 limits = @version.read_limits(limit, page_size) 64 65 page = self.page(page_size: limits[:page_size], ) 66 67 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 68 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/autopilot/v1/assistant/task/field.rb 141 def to_s 142 '#<Twilio.Autopilot.V1.FieldList>' 143 end