Sha256: e45b276f4d25c01451f1c88641c03c9c1d111852bde6664c5cfb726781f1464d

Contents?: true

Size: 825 Bytes

Versions: 1

Compression:

Stored size: 825 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::Redis.get(redis_key(symbol))
          response = make_request(url_path(symbol))
          
          unless response.success?
            raise ArgumentError, "Error fetching fundamentals data for #{symbol}"
          end

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

        Oj.load(Cache::Redis.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

1 entries across 1 versions & 1 rubygems

Version Path
sensei_eod_utils-0.0.38 lib/eod_facade/fundamentals.rb