class Twilio::REST::Autopilot::V1::AssistantContext::FieldTypeContext::FieldValueList
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 FieldValueList
@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 FieldType associated with the resource.
@param [String] field_type_sid The SID of the Field Type associated with the
Field Value.
@return [FieldValueList] FieldValueList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.rb 27 def initialize(version, assistant_sid: nil, field_type_sid: nil) 28 super(version) 29 30 # Path Solution 31 @solution = {assistant_sid: assistant_sid, field_type_sid: field_type_sid} 32 @uri = "/Assistants/#{@solution[:assistant_sid]}/FieldTypes/#{@solution[:field_type_sid]}/FieldValues" 33 end
Public Instance Methods
Create the FieldValueInstance
@param [String] language The {ISO
language-country}[https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html] tag that specifies the language of the value. Currently supported tags: `en-US`
@param [String] value The Field Value data. @param [String] synonym_of The string value that indicates which word the field
value is a synonym of.
@return [FieldValueInstance] Created FieldValueInstance
# File lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.rb 134 def create(language: nil, value: nil, synonym_of: :unset) 135 data = Twilio::Values.of({'Language' => language, 'Value' => value, 'SynonymOf' => synonym_of, }) 136 137 payload = @version.create('POST', @uri, data: data) 138 139 FieldValueInstance.new( 140 @version, 141 payload, 142 assistant_sid: @solution[:assistant_sid], 143 field_type_sid: @solution[:field_type_sid], 144 ) 145 end
When passed a block, yields FieldValueInstance
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/field_type/field_value.rb 79 def each 80 limits = @version.read_limits 81 82 page = self.page(page_size: limits[:page_size], ) 83 84 @version.stream(page, 85 limit: limits[:limit], 86 page_limit: limits[:page_limit]).each {|x| yield x} 87 end
Retrieve a single page of FieldValueInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of FieldValueInstance
# File lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.rb 117 def get_page(target_url) 118 response = @version.domain.request( 119 'GET', 120 target_url 121 ) 122 FieldValuePage.new(@version, response, @solution) 123 end
Lists FieldValueInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] language The {ISO
language-country}[https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html] tag that specifies the language of the value. Currently supported tags: `en-US`
@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/field_type/field_value.rb 49 def list(language: :unset, limit: nil, page_size: nil) 50 self.stream(language: language, limit: limit, page_size: page_size).entries 51 end
Retrieve a single page of FieldValueInstance
records from the API. Request
is executed immediately. @param [String] language The {ISO
language-country}[https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html] tag that specifies the language of the value. Currently supported tags: `en-US`
@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 FieldValueInstance
# File lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.rb 99 def page(language: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 100 params = Twilio::Values.of({ 101 'Language' => language, 102 'PageToken' => page_token, 103 'Page' => page_number, 104 'PageSize' => page_size, 105 }) 106 107 response = @version.page('GET', @uri, params: params) 108 109 FieldValuePage.new(@version, response, @solution) 110 end
Streams FieldValueInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] language The {ISO
language-country}[https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html] tag that specifies the language of the value. Currently supported tags: `en-US`
@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/field_type/field_value.rb 67 def stream(language: :unset, limit: nil, page_size: nil) 68 limits = @version.read_limits(limit, page_size) 69 70 page = self.page(language: language, page_size: limits[:page_size], ) 71 72 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 73 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.rb 149 def to_s 150 '#<Twilio.Autopilot.V1.FieldValueList>' 151 end