lib/answersengine/client/base.rb in answersengine-0.2.33 vs lib/answersengine/client/base.rb in answersengine-0.3.0

- old
+ new

@@ -2,24 +2,28 @@ module AnswersEngine module Client class Base include HTTParty - base_uri(ENV['ANSWERSENGINE_API_URL'].nil? ? 'https://fetch.answersengine.com/api/v1' : ENV['ANSWERSENGINE_API_URL']) def self.env_auth_token ENV['ANSWERSENGINE_TOKEN'] end + def env_api_url + ENV['ANSWERSENGINE_API_URL'].nil? ? 'https://fetch.answersengine.com/api/v1' : ENV['ANSWERSENGINE_API_URL'] + end + def auth_token @auth_token ||= self.class.env_auth_token end def auth_token= value @auth_token = value end def initialize(opts={}) + self.class.base_uri(env_api_url) self.auth_token = opts[:auth_token] unless opts[:auth_token].nil? @options = { headers: { "Authorization" => "Bearer #{auth_token}", "Content-Type" => "application/json", }}