Module: Quandl::Client

Defined in:
lib/quandl/client.rb,
lib/quandl/client/her.rb,
lib/quandl/client/base.rb,
lib/quandl/client/models.rb,
lib/quandl/client/version.rb,
lib/quandl/client/concerns.rb,
lib/quandl/client/middleware.rb,
lib/quandl/client/models/sheet.rb,
lib/quandl/client/models/source.rb,
lib/quandl/client/models/dataset.rb,
lib/quandl/client/concerns/search.rb,
lib/quandl/client/concerns/properties.rb,
lib/quandl/client/middleware/parse_json.rb

Defined Under Namespace

Modules: Concerns, Middleware, Models Classes: Base, Dataset, Sheet, Source, TokenAuthentication

Constant Summary collapse

VERSION =
'0.1.8'
API_VERSION =
'v1'

Class Method Summary collapse

Class Method Details

.api_versionObject



8
9
10
# File 'lib/quandl/client/version.rb', line 8

def api_version
  API_VERSION
end

.her_apiObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/quandl/client/her.rb', line 20

def her_api
  # setup api
  api = Her::API.new
  api.setup url: rest_url do |c|
    c.use TokenAuthentication
    c.use Faraday::Request::UrlEncoded
    # c.use Her::Middleware::DefaultParseJSON
    c.use Quandl::Client::Middleware::ParseJSON
    c.use Faraday::Adapter::NetHttp
  end
end

.reload_modelsObject



44
45
46
# File 'lib/quandl/client/her.rb', line 44

def reload_models
  Models.use_api( her_api )
end

.rest_urlObject



32
33
34
# File 'lib/quandl/client/her.rb', line 32

def rest_url
  @rest_url ||= "http://localhost:3000/api/#{API_VERSION}/"
end

.rest_url=(url) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/quandl/client/her.rb', line 36

def rest_url=(url)
  url = "http://#{url}" if ( url =~ /^http:\/\// ) == nil
  url = File.join(url, "#{API_VERSION}/")
  @rest_url = url
  reload_models
  @rest_url
end

.tokenObject



12
13
14
# File 'lib/quandl/client/her.rb', line 12

def token
  @token
end

.token=(token) ⇒ Object



15
16
17
18
# File 'lib/quandl/client/her.rb', line 15

def token=(token)
  @token = token
  reload_models
end

.use(url) ⇒ Object



8
9
10
# File 'lib/quandl/client/her.rb', line 8

def use(url)
  self.rest_url = url
end