lib/quandl/client/base.rb in quandl_client-2.2.2 vs lib/quandl/client/base.rb in quandl_client-2.3.0
- old
+ new
@@ -13,31 +13,35 @@
class << self
attr_accessor :url, :token
def use(url)
- self.url = File.join( url, Quandl::Client.api_version )
+ self.url = url
models_use_her_api!
end
def token=(token)
@token = token
models_use_her_api!
end
def her_api
- Her::API.new.setup url: url do |c|
+ Her::API.new.setup url: url_with_version do |c|
c.use TokenAuthentication
c.use Faraday::Request::UrlEncoded
c.use Quandl::Client::Middleware::ParseJSON
c.use Faraday::Adapter::NetHttp
end
end
def url
- @url ||= "http://localhost:3000/api/#{Quandl::Client.api_version}/"
+ @url ||= "http://quandl.com/api/"
end
+
+ def url_with_version
+ File.join( url.to_s, Quandl::Client.api_version.to_s )
+ end
def inherited(subclass)
# remember models that inherit from base
models << subclass unless models.include?(subclass)
# include model behaviour
@@ -55,10 +59,10 @@
protected
def models_use_her_api!
models.each{|m|
- m.url = url
+ m.url = url_with_version
m.use_api( her_api )
}
end
class TokenAuthentication < Faraday::Middleware
\ No newline at end of file