class Twilio::REST::Preview::Understand::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 unique ID of the Assistant. @param [String] field_type_sid The unique ID of the Field Type associated with
this Field Value.
@return [FieldValueList] FieldValueList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/preview/understand/assistant/field_type/field_value.rb 25 def initialize(version, assistant_sid: nil, field_type_sid: nil) 26 super(version) 27 28 # Path Solution 29 @solution = {assistant_sid: assistant_sid, field_type_sid: field_type_sid} 30 @uri = "/Assistants/#{@solution[:assistant_sid]}/FieldTypes/#{@solution[:field_type_sid]}/FieldValues" 31 end
Public Instance Methods
Create the FieldValueInstance
@param [String] language An ISO language-country string of the value. @param [String] value A user-provided string that uniquely identifies this
resource as an alternative to the sid. Unique up to 64 characters long.
@param [String] synonym_of A value that indicates this field value is a synonym
of. Empty if the value is not a synonym.
@return [FieldValueInstance] Created FieldValueInstance
# File lib/twilio-ruby/rest/preview/understand/assistant/field_type/field_value.rb 128 def create(language: nil, value: nil, synonym_of: :unset) 129 data = Twilio::Values.of({'Language' => language, 'Value' => value, 'SynonymOf' => synonym_of, }) 130 131 payload = @version.create('POST', @uri, data: data) 132 133 FieldValueInstance.new( 134 @version, 135 payload, 136 assistant_sid: @solution[:assistant_sid], 137 field_type_sid: @solution[:field_type_sid], 138 ) 139 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/preview/understand/assistant/field_type/field_value.rb 75 def each 76 limits = @version.read_limits 77 78 page = self.page(page_size: limits[:page_size], ) 79 80 @version.stream(page, 81 limit: limits[:limit], 82 page_limit: limits[:page_limit]).each {|x| yield x} 83 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/preview/understand/assistant/field_type/field_value.rb 112 def get_page(target_url) 113 response = @version.domain.request( 114 'GET', 115 target_url 116 ) 117 FieldValuePage.new(@version, response, @solution) 118 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 An ISO language-country string of the value. For
example: *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/preview/understand/assistant/field_type/field_value.rb 46 def list(language: :unset, limit: nil, page_size: nil) 47 self.stream(language: language, limit: limit, page_size: page_size).entries 48 end
Retrieve a single page of FieldValueInstance
records from the API. Request
is executed immediately. @param [String] language An ISO language-country string of the value. For
example: *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/preview/understand/assistant/field_type/field_value.rb 94 def page(language: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 95 params = Twilio::Values.of({ 96 'Language' => language, 97 'PageToken' => page_token, 98 'Page' => page_number, 99 'PageSize' => page_size, 100 }) 101 102 response = @version.page('GET', @uri, params: params) 103 104 FieldValuePage.new(@version, response, @solution) 105 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 An ISO language-country string of the value. For
example: *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/preview/understand/assistant/field_type/field_value.rb 63 def stream(language: :unset, limit: nil, page_size: nil) 64 limits = @version.read_limits(limit, page_size) 65 66 page = self.page(language: language, page_size: limits[:page_size], ) 67 68 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 69 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/preview/understand/assistant/field_type/field_value.rb 143 def to_s 144 '#<Twilio.Preview.Understand.FieldValueList>' 145 end