Sha256: 4929c3f75387aec72c51288cedb13460d7df33050261c3d97bd8e52a11f6e8d6

Contents?: true

Size: 840 Bytes

Versions: 2

Compression:

Stored size: 840 Bytes

Contents

# frozen_string_literal: true

require 'oj'
require_relative '../cache/redis.rb'

module EodFacade
  class Fundamentals < ::EodFacade::Base
    class << self
      def call(symbol)
        # raise Cache::Redis.inspect
        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
          )
        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

2 entries across 2 versions & 1 rubygems

Version Path
sensei_eod_utils-0.0.40 lib/eod_facade/fundamentals.rb
sensei_eod_utils-0.0.39 lib/eod_facade/fundamentals.rb