Sha256: 70ebc5fc42dd166b4d44df3f5902405d9374c0d43bccb95f9ac27394e60354ed
Contents?: true
Size: 811 Bytes
Versions: 5
Compression:
Stored size: 811 Bytes
Contents
# frozen_string_literal: true require 'oj' require_relative '../cache/redis.rb' module EodFacade class Fundamentals < ::EodFacade::Base class << self 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 private def url_path(symbol) "/fundamentals/#{symbol}" end def redis_key(symbol) "#{symbol}_fundamentals" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems