Class: EodFacade::Fundamentals

Inherits:
Base
  • Object
show all
Defined in:
lib/eod_facade/fundamentals.rb

Class Method Summary collapse

Methods inherited from Base

make_request

Class Method Details

.call(symbol) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/eod_facade/fundamentals.rb', line 9

def call(symbol)
  unless Cache::RedisCache.get(redis_key(symbol))
    response = make_request(url_path(symbol))
    
    unless response.success?
      raise ArgumentError, "Error fetching fundamentals data for #{symbol}"
    end

    Cache::RedisCache.set(
      redis_key(symbol),
      response.parsed_response.to_json
    )
  end

  Oj.load(Cache::RedisCache.get(redis_key(symbol)))
end