## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 # / / # # frozen_string_literal: true module Twilio module REST class Preview < Domain class Understand < Version ## # 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. class AssistantList < ListResource ## # Initialize the AssistantList # @param [Version] version Version that contains the resource # @return [AssistantList] AssistantList def initialize(version) super(version) # Path Solution @solution = {} @uri = "/Assistants" end ## # Lists AssistantInstance 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 def list(limit: nil, page_size: nil) self.stream(limit: limit, page_size: page_size).entries end ## # Streams AssistantInstance 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 def stream(limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page(page_size: limits[:page_size], ) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end ## # When passed a block, yields AssistantInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit # is reached. def each limits = @version.read_limits page = self.page(page_size: limits[:page_size], ) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]).each {|x| yield x} end ## # Retrieve a single page of AssistantInstance 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 AssistantInstance def page(page_token: :unset, page_number: :unset, page_size: :unset) params = Twilio::Values.of({ 'PageToken' => page_token, 'Page' => page_number, 'PageSize' => page_size, }) response = @version.page( 'GET', @uri, params ) AssistantPage.new(@version, response, @solution) end ## # Retrieve a single page of AssistantInstance records from the API. # Request is executed immediately. # @param [String] target_url API-generated URL for the requested results page # @return [Page] Page of AssistantInstance def get_page(target_url) response = @version.domain.request( 'GET', target_url ) AssistantPage.new(@version, response, @solution) end ## # Retrieve a single page of AssistantInstance records from the API. # Request is executed immediately. # @param [String] friendly_name The friendly_name # @param [Boolean] log_queries The log_queries # @param [String] ttl The ttl # @param [String] unique_name The unique_name # @param [String] response_url The response_url # @param [String] callback_url The callback_url # @param [String] callback_events The callback_events # @return [AssistantInstance] Newly created AssistantInstance def create(friendly_name: :unset, log_queries: :unset, ttl: :unset, unique_name: :unset, response_url: :unset, callback_url: :unset, callback_events: :unset) data = Twilio::Values.of({ 'FriendlyName' => friendly_name, 'LogQueries' => log_queries, 'Ttl' => ttl, 'UniqueName' => unique_name, 'ResponseUrl' => response_url, 'CallbackUrl' => callback_url, 'CallbackEvents' => callback_events, }) payload = @version.create( 'POST', @uri, data: data ) AssistantInstance.new(@version, payload, ) end ## # Provide a user friendly representation def to_s '#' end end ## # 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. class AssistantPage < Page ## # Initialize the AssistantPage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API # @param [Hash] solution Path solution for the resource # @return [AssistantPage] AssistantPage def initialize(version, response, solution) super(version, response) # Path Solution @solution = solution end ## # Build an instance of AssistantInstance # @param [Hash] payload Payload response from the API # @return [AssistantInstance] AssistantInstance def get_instance(payload) AssistantInstance.new(@version, payload, ) end ## # Provide a user friendly representation def to_s '' end end ## # 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. class AssistantContext < InstanceContext ## # Initialize the AssistantContext # @param [Version] version Version that contains the resource # @param [String] sid The sid # @return [AssistantContext] AssistantContext def initialize(version, sid) super(version) # Path Solution @solution = {sid: sid, } @uri = "/Assistants/#{@solution[:sid]}" # Dependents @field_types = nil @intents = nil @model_builds = nil @queries = nil end ## # Fetch a AssistantInstance # @return [AssistantInstance] Fetched AssistantInstance def fetch params = Twilio::Values.of({}) payload = @version.fetch( 'GET', @uri, params, ) AssistantInstance.new(@version, payload, sid: @solution[:sid], ) end ## # Update the AssistantInstance # @param [String] friendly_name The friendly_name # @param [Boolean] log_queries The log_queries # @param [String] ttl The ttl # @param [String] unique_name The unique_name # @param [String] response_url The response_url # @param [String] callback_url The callback_url # @param [String] callback_events The callback_events # @return [AssistantInstance] Updated AssistantInstance def update(friendly_name: :unset, log_queries: :unset, ttl: :unset, unique_name: :unset, response_url: :unset, callback_url: :unset, callback_events: :unset) data = Twilio::Values.of({ 'FriendlyName' => friendly_name, 'LogQueries' => log_queries, 'Ttl' => ttl, 'UniqueName' => unique_name, 'ResponseUrl' => response_url, 'CallbackUrl' => callback_url, 'CallbackEvents' => callback_events, }) payload = @version.update( 'POST', @uri, data: data, ) AssistantInstance.new(@version, payload, sid: @solution[:sid], ) end ## # Deletes the AssistantInstance # @return [Boolean] true if delete succeeds, true otherwise def delete @version.delete('delete', @uri) end ## # Access the field_types # @return [FieldTypeList] # @return [FieldTypeContext] if sid was passed. def field_types(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return FieldTypeContext.new(@version, @solution[:sid], sid, ) end unless @field_types @field_types = FieldTypeList.new(@version, assistant_sid: @solution[:sid], ) end @field_types end ## # Access the intents # @return [IntentList] # @return [IntentContext] if sid was passed. def intents(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return IntentContext.new(@version, @solution[:sid], sid, ) end unless @intents @intents = IntentList.new(@version, assistant_sid: @solution[:sid], ) end @intents end ## # Access the model_builds # @return [ModelBuildList] # @return [ModelBuildContext] if sid was passed. def model_builds(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return ModelBuildContext.new(@version, @solution[:sid], sid, ) end unless @model_builds @model_builds = ModelBuildList.new(@version, assistant_sid: @solution[:sid], ) end @model_builds end ## # Access the queries # @return [QueryList] # @return [QueryContext] if sid was passed. def queries(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return QueryContext.new(@version, @solution[:sid], sid, ) end unless @queries @queries = QueryList.new(@version, assistant_sid: @solution[:sid], ) end @queries end ## # Provide a user friendly representation def to_s context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') "#" end end ## # 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. class AssistantInstance < InstanceResource ## # Initialize the AssistantInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio # @param [String] sid The sid # @return [AssistantInstance] AssistantInstance def initialize(version, payload, sid: nil) super(version) # Marshaled Properties @properties = { 'account_sid' => payload['account_sid'], 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 'friendly_name' => payload['friendly_name'], 'latest_model_build_sid' => payload['latest_model_build_sid'], 'links' => payload['links'], 'log_queries' => payload['log_queries'], 'sid' => payload['sid'], 'ttl' => payload['ttl'].to_i, 'unique_name' => payload['unique_name'], 'url' => payload['url'], 'response_url' => payload['response_url'], 'callback_url' => payload['callback_url'], 'callback_events' => payload['callback_events'], } # Context @instance_context = nil @params = {'sid' => sid || @properties['sid'], } end ## # Generate an instance context for the instance, the context is capable of # performing various actions. All instance actions are proxied to the context # @return [AssistantContext] AssistantContext for this AssistantInstance def context unless @instance_context @instance_context = AssistantContext.new(@version, @params['sid'], ) end @instance_context end ## # @return [String] The account_sid def account_sid @properties['account_sid'] end ## # @return [Time] The date_created def date_created @properties['date_created'] end ## # @return [Time] The date_updated def date_updated @properties['date_updated'] end ## # @return [String] The friendly_name def friendly_name @properties['friendly_name'] end ## # @return [String] The latest_model_build_sid def latest_model_build_sid @properties['latest_model_build_sid'] end ## # @return [String] The links def links @properties['links'] end ## # @return [Boolean] The log_queries def log_queries @properties['log_queries'] end ## # @return [String] The sid def sid @properties['sid'] end ## # @return [String] The ttl def ttl @properties['ttl'] end ## # @return [String] The unique_name def unique_name @properties['unique_name'] end ## # @return [String] The url def url @properties['url'] end ## # @return [String] The response_url def response_url @properties['response_url'] end ## # @return [String] The callback_url def callback_url @properties['callback_url'] end ## # @return [String] The callback_events def callback_events @properties['callback_events'] end ## # Fetch a AssistantInstance # @return [AssistantInstance] Fetched AssistantInstance def fetch context.fetch end ## # Update the AssistantInstance # @param [String] friendly_name The friendly_name # @param [Boolean] log_queries The log_queries # @param [String] ttl The ttl # @param [String] unique_name The unique_name # @param [String] response_url The response_url # @param [String] callback_url The callback_url # @param [String] callback_events The callback_events # @return [AssistantInstance] Updated AssistantInstance def update(friendly_name: :unset, log_queries: :unset, ttl: :unset, unique_name: :unset, response_url: :unset, callback_url: :unset, callback_events: :unset) context.update( friendly_name: friendly_name, log_queries: log_queries, ttl: ttl, unique_name: unique_name, response_url: response_url, callback_url: callback_url, callback_events: callback_events, ) end ## # Deletes the AssistantInstance # @return [Boolean] true if delete succeeds, true otherwise def delete context.delete end ## # Access the field_types # @return [field_types] field_types def field_types context.field_types end ## # Access the intents # @return [intents] intents def intents context.intents end ## # Access the model_builds # @return [model_builds] model_builds def model_builds context.model_builds end ## # Access the queries # @return [queries] queries def queries context.queries end ## # Provide a user friendly representation def to_s values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") "" end ## # Provide a detailed, user friendly representation def inspect values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") "" end end end end end end