9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/eod_facade/dividends.rb', line 9
def call(symbol, params = {})
unless Cache::RedisCache.get(redis_key(symbol, params[:from], params[:to]))
response = make_request(url_path(symbol), params.merge(fmt: 'json'))
unless response.success?
raise ArgumentError, "Error fetching dividend data for #{symbol}"
end
Cache::RedisCache.set(
redis_key(symbol, params[:from], params[:to]),
response.parsed_response.to_json
)
end
Oj.load(Cache::RedisCache.get(redis_key(symbol, params[:from], params[:to])))
end
|