class ApiAiWrapper::Engine
Constants
- AUTOLOAD_CLASSES
Attributes
base_url[RW]
client[RW]
client_timeout[RW]
client_token[RW]
developer_token[RW]
entity_trainer[RW]
headers[RW]
intent_trainer[RW]
locale[RW]
meaning_extractor[RW]
version[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/api_ai_wrapper/engine.rb, line 19 def initialize(options = {}) self.client = HTTPClient.new self.client.receive_timeout = options[:client_timeout].presence || ApiAiWrapper::Constants::DEFAULT_CLIENT_TIMEOUT self.locale = options[:locale].presence || ApiAiWrapper::Constants::DEFAULT_LOCALE self.base_url = ApiAiWrapper::Constants::DEFAULT_BASE_URL self.version = options[:version].presence || ApiAiWrapper::Constants::DEFAULT_VERSION self.client_token = options[:client_token].presence self.developer_token = options[:developer_token].presence # RAISE ERROR IF NO TOKEN PRESENT raise ApiAiWrapper::Errors::Engine::MissingTokens.new if self.client_token.blank? && self.developer_token.blank? # define entity_trainer and intent_trainer on the fly AUTOLOAD_CLASSES.each{ |class_name| instance = class_name.new instance.engine = self self.send("#{class_name.to_s.demodulize.underscore}=", instance) } end